|
|
|
@ -41,7 +41,6 @@ |
|
|
|
|
|
|
|
|
|
#include "tldTracker.hpp" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
@ -156,7 +155,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) |
|
|
|
|
else |
|
|
|
|
#endif |
|
|
|
|
DETECT_FLG = tldModel->detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if( ( (i == 0) && !data->failedLastTime && trackerProxy->update(image, tmpCandid) ) || ( DETECT_FLG)) |
|
|
|
|
{ |
|
|
|
|
candidates.push_back(tmpCandid); |
|
|
|
@ -174,7 +173,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) |
|
|
|
|
} |
|
|
|
|
std::vector<double>::iterator it = std::max_element(candidatesRes.begin(), candidatesRes.end()); |
|
|
|
|
|
|
|
|
|
if( it == candidatesRes.end() ) |
|
|
|
|
if( it == candidatesRes.end() ) //candidates are empty
|
|
|
|
|
{ |
|
|
|
|
data->confident = false; |
|
|
|
|
data->failedLastTime = true; |
|
|
|
@ -259,6 +258,7 @@ int TrackerTLDImpl::Pexpert::additionalExamples(std::vector<Mat_<uchar> >& examp |
|
|
|
|
|
|
|
|
|
double scale = scaleAndBlur(img_, cvRound(log(1.0 * resultBox_.width / (initSize_.width)) / log(SCALE_STEP)), |
|
|
|
|
scaledImg, blurredImg, GaussBlurKernelSize, SCALE_STEP); |
|
|
|
|
|
|
|
|
|
TLDDetector::generateScanGrid(img_.rows, img_.cols, initSize_, scanGrid); |
|
|
|
|
getClosestN(scanGrid, Rect2d(resultBox_.x / scale, resultBox_.y / scale, resultBox_.width / scale, resultBox_.height / scale), 10, closest); |
|
|
|
|
|
|
|
|
@ -275,21 +275,24 @@ int TrackerTLDImpl::Pexpert::additionalExamples(std::vector<Mat_<uchar> >& examp |
|
|
|
|
size.height = (float)(closest[i].height * rng.uniform((double)0.99, (double)1.01)); |
|
|
|
|
float angle = (float)rng.uniform(-5.0, 5.0); |
|
|
|
|
|
|
|
|
|
resample(scaledImg, RotatedRect(center, size, angle), standardPatch); |
|
|
|
|
for( int y = 0; y < standardPatch.rows; y++ ) |
|
|
|
|
{ |
|
|
|
|
uchar* patchRow = standardPatch.ptr(y); |
|
|
|
|
for( int x = 0; x < standardPatch.cols; x++ ) |
|
|
|
|
{ |
|
|
|
|
standardPatch(x, y) += (uchar)rng.gaussian(5.0); |
|
|
|
|
int newValue = patchRow[x] + cvRound(rng.gaussian(5.0)); |
|
|
|
|
patchRow[x] = saturate_cast<uchar>(newValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#ifdef BLUR_AS_VADIM |
|
|
|
|
examplesForModel.push_back(standardPatch); |
|
|
|
|
|
|
|
|
|
#if defined BLUR_AS_VADIM |
|
|
|
|
GaussianBlur(standardPatch, blurredPatch, GaussBlurKernelSize, 0.0); |
|
|
|
|
resize(blurredPatch, blurredPatch, initSize_); |
|
|
|
|
#else |
|
|
|
|
resample(blurredImg, RotatedRect(center, size, angle), blurredPatch); |
|
|
|
|
#endif |
|
|
|
|
resample(scaledImg, RotatedRect(center, size, angle), standardPatch); |
|
|
|
|
examplesForModel.push_back(standardPatch); |
|
|
|
|
examplesForEnsemble.push_back(blurredPatch); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|