@@ -209,8 +209,8 @@ class PlanarTracker::PlanarTrackerImpl
209209 // std::cout << "New marker detected" << std::endl;
210210 _trackables[bestMatchIndex]._isDetected = true ;
211211 // Since we've just detected the marker, make sure next invocation of
212- // SelectTrackablePoints () for this marker resets the selection.
213- _trackables[bestMatchIndex]._resetTracks = true ;
212+ // GetInitialFeatures () for this marker makes a new selection.
213+ _trackables[bestMatchIndex]._trackSelection . ResetSelection () ;
214214 _trackables[bestMatchIndex]._trackSelection .SetHomography (homoInfo.homography );
215215
216216 // Use the homography to form the initial estimate of the bounding box.
@@ -227,17 +227,6 @@ class PlanarTracker::PlanarTrackerImpl
227227 }
228228 }
229229
230- std::vector<cv::Point2f> SelectTrackablePoints (int trackableIndex)
231- {
232- if (_trackables[trackableIndex]._resetTracks ) {
233- _trackables[trackableIndex]._trackSelection .SelectPoints ();
234- _trackables[trackableIndex]._resetTracks = false ;
235- return _trackables[trackableIndex]._trackSelection .GetSelectedFeatures ();
236- } else {
237- return _trackables[trackableIndex]._trackSelection .GetTrackedFeatures ();
238- }
239- }
240-
241230 bool RunOpticalFlow (int trackableId, const std::vector<cv::Point2f>& trackablePoints, const std::vector<cv::Point2f>& trackablePointsWarped)
242231 {
243232 std::vector<cv::Point2f> flowResultPoints, trackablePointsWarpedResult;
@@ -292,7 +281,7 @@ class PlanarTracker::PlanarTrackerImpl
292281 }
293282 }
294283 if (_frameCount > 1 ) {
295- _trackables[trackableId]._resetTracks = true ;
284+ _trackables[trackableId]._trackSelection . ResetSelection () ;
296285 }
297286 return true ;
298287 }
@@ -537,7 +526,7 @@ class PlanarTracker::PlanarTrackerImpl
537526 // float templateScaleFactor = (float)(1 << templatePyrLevel);
538527 // std::cout << "templatePyrLevel=" << templatePyrLevel << ", templateScaleFactor=" << templateScaleFactor << "." << std::endl;
539528
540- std::vector<cv::Point2f> trackablePoints = SelectTrackablePoints (i );
529+ std::vector<cv::Point2f> trackablePoints = _trackables[i]. _trackSelection . GetInitialFeatures ( );
541530 std::vector<cv::Point2f> trackablePointsWarped = _trackables[i]._trackSelection .GetTrackedFeaturesWarped ();
542531
543532 if (_frameCount > 0 && _prevPyramid.size () > 0 ) {
@@ -648,7 +637,6 @@ class PlanarTracker::PlanarTrackerImpl
648637 newTrackable._bBox .push_back (cv::Point2f (0 , newTrackable._height ));
649638 newTrackable._isTracking = false ;
650639 newTrackable._isDetected = false ;
651- newTrackable._resetTracks = false ;
652640 newTrackable._trackSelection = TrackingPointSelector (newTrackable._cornerPoints , newTrackable._width , newTrackable._height , markerTemplateWidth);
653641 _trackables.push_back (newTrackable);
654642 }
@@ -686,7 +674,6 @@ class PlanarTracker::PlanarTrackerImpl
686674 newTrackable._bBox .push_back (cv::Point2f (0 , newTrackable._height ));
687675 newTrackable._isTracking = false ;
688676 newTrackable._isDetected = false ;
689- newTrackable._resetTracks = false ;
690677 newTrackable._trackSelection = TrackingPointSelector (newTrackable._cornerPoints , newTrackable._width , newTrackable._height , markerTemplateWidth);
691678
692679 _trackables.push_back (newTrackable);
0 commit comments