tracking: slightly rewrite main loop in TLD

pull/1333/head
Vladislav Sovrasov 8 years ago
parent a0896c7bd1
commit 62939e2937
  1. 50
      modules/tracking/src/tldTracker.cpp

@ -140,37 +140,35 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
std::vector<Rect2d> candidates; std::vector<Rect2d> candidates;
std::vector<double> candidatesRes; std::vector<double> candidatesRes;
bool trackerNeedsReInit = false; bool trackerNeedsReInit = false;
bool DETECT_FLG = false; bool DETECT_FLG = false;
for( int i = 0; i < 2; i++ )
//run tracker
Rect2d tmpCandid = boundingBox;
if(!data->failedLastTime && trackerProxy->update(image, tmpCandid))
{ {
Rect2d tmpCandid = boundingBox; candidates.push_back(tmpCandid);
resample(image_gray, tmpCandid, standardPatch);
candidatesRes.push_back(tldModel->detector->Sc(standardPatch));
}
else
trackerNeedsReInit = true;
if (i == 1) //run detector
{ tmpCandid = boundingBox;
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
if (false)//ocl::useOpenCL()) if (false)//ocl::useOpenCL())
{ DETECT_FLG = tldModel->detector->ocl_detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize());
DETECT_FLG = tldModel->detector->ocl_detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize()); else
}
else
#endif #endif
DETECT_FLG = tldModel->detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize()); DETECT_FLG = tldModel->detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize());
}
if( ( (i == 0) && !data->failedLastTime && trackerProxy->update(image, tmpCandid) ) || ( DETECT_FLG)) if(DETECT_FLG)
{ {
candidates.push_back(tmpCandid); candidates.push_back(tmpCandid);
if( i == 0 ) resample(imageForDetector, tmpCandid, standardPatch);
resample(image_gray, tmpCandid, standardPatch); candidatesRes.push_back(tldModel->detector->Sc(standardPatch));
else
resample(imageForDetector, tmpCandid, standardPatch);
candidatesRes.push_back(tldModel->detector->Sc(standardPatch));
}
else
{
if( i == 0 )
trackerNeedsReInit = true;
}
} }
std::vector<double>::iterator it = std::max_element(candidatesRes.begin(), candidatesRes.end()); std::vector<double>::iterator it = std::max_element(candidatesRes.begin(), candidatesRes.end());
if( it == candidatesRes.end() ) //candidates are empty if( it == candidatesRes.end() ) //candidates are empty

Loading…
Cancel
Save