@@ -31,7 +31,7 @@ void Manager::init()
3131 LogManager::logErrorMessage (ErrorType::IMAGE_ERROR, " image not found" );
3232 return ;
3333 }
34- Distance & distance = Distance::getInstance (calibrationImage);
34+ distance. setFocalLength (calibrationImage);
3535 iterationCnt = 1 ;
3636 bool isCuda = false ;
3737 detector.init (isCuda);
@@ -67,7 +67,6 @@ void Manager::mainDemo()
6767 return ;
6868 }
6969 // intialize focal length
70- Distance &distance = Distance::getInstance ();
7170 distance.setFocalLength (focalLength);
7271 runOnVideo (videoPath);
7372 }
@@ -104,21 +103,28 @@ void Manager::runOnVideo(string videoPath)
104103 }
105104}
106105
107- bool Manager::isDetect (bool isTravel )
106+ bool Manager::isDetect ()
108107{
109108 if (!isTravel || iterationCnt == 1 )
110109 return true ;
111110 return false ;
112111}
113112
114- bool Manager::isResetTracker (bool isTravel )
113+ bool Manager::isResetTracker ()
115114{
116115 if (isTravel && iterationCnt == 1 )
117116 return true ;
118117 return false ;
119118}
120119
121- bool Manager::isTrack (bool isTravel)
120+ bool Manager::isTrack ()
121+ {
122+ if (isTravel && iterationCnt > 1 )
123+ return true ;
124+ return false ;
125+ }
126+
127+ bool Manager::isCalcVelocity ()
122128{
123129 if (isTravel && iterationCnt > 1 )
124130 return true ;
@@ -127,31 +133,36 @@ bool Manager::isTrack(bool isTravel)
127133
128134int Manager::processing (const Mat &newFrame, bool isTravel)
129135{
130- Distance &distance = Distance::getInstance () ;
136+ this -> isTravel = isTravel ;
131137 currentFrame = make_shared<Mat>(newFrame);
132- if (isDetect (isTravel )) {
138+ if (isDetect ()) {
133139 // send the frame to detect
134140 detector.detect (this ->currentFrame , isTravel);
135141 this ->currentOutput = detector.getOutput ();
136142 }
137143
138- if (isResetTracker (isTravel )) {
144+ if (isResetTracker ()) {
139145 // prepare the tracker
140146 dynamicTracker.startTracking (this ->currentFrame , this ->currentOutput );
141147 }
142148
143- if (isTrack (isTravel )) {
149+ if (isTrack ()) {
144150 // send the frame to track
145151 dynamicTracker.tracking (this ->currentFrame , this ->currentOutput );
146152 }
147153
148154 // add distance to detection objects
149155 distance.findDistance (this ->currentOutput );
150- velocity.returnVelocities (this ->currentOutput );
156+ if (isCalcVelocity ()) {
157+ velocity.returnVelocities (this ->currentOutput );
158+ }
151159
152160 // send allerts to main control
153- vector<vector<uint8_t >> alerts = alerter.sendAlerts (this ->currentOutput );
154- sendAlerts (alerts);
161+ if (isCalcVelocity ()) {
162+ vector<vector<uint8_t >> alerts =
163+ alerter.sendAlerts (this ->currentOutput );
164+ sendAlerts (alerts);
165+ }
155166
156167 // update of the iterationCnt
157168 if (isTravel) {
@@ -166,10 +177,10 @@ int Manager::processing(const Mat &newFrame, bool isTravel)
166177
167178int Manager::drawOutput ()
168179{
169- Distance &distance = Distance::getInstance ();
170180 dynamicTracker.drawTracking (currentFrame, currentOutput);
171181 distance.drawDistance (currentFrame, currentOutput);
172- velocity.drawVelocity (currentFrame, currentOutput);
182+ if (isCalcVelocity ())
183+ velocity.drawVelocity (currentFrame, currentOutput);
173184
174185 // Legend
175186 int legendX = 10 , legendY = 10 ;
0 commit comments