Commit 016b4c82 authored by Vladimir's avatar Vladimir

Debug through candidates display

parent fdc87172
...@@ -491,6 +491,10 @@ namespace cv ...@@ -491,6 +491,10 @@ namespace cv
continue; continue;
varBuffer.push_back(Point(dx * i, dy * j)); varBuffer.push_back(Point(dx * i, dy * j));
varScaleIDs.push_back(scaleID); varScaleIDs.push_back(scaleID);
//Debug display candidates after Variance Filter
double curScale = pow(tld::SCALE_STEP, scaleID);
debugStack[0].push_back(Rect2d(dx * i* curScale, dy * j*curScale, initSize.width*curScale, initSize.height*curScale));
} }
} }
scaleID++; scaleID++;
...@@ -520,6 +524,9 @@ namespace cv ...@@ -520,6 +524,9 @@ namespace cv
//t = (e2 - e1) / getTickFrequency()*1000.0; //t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Ensemble: %d\t%f\n", ensBuffer.size(), t); //printf("Ensemble: %d\t%f\n", ensBuffer.size(), t);
//printf("varBuffer: %d\n", varBuffer.size());
//printf("ensBuffer: %d\n", ensBuffer.size());
//NN classification //NN classification
//e1 = getTickCount(); //e1 = getTickCount();
for (int i = 0; i < (int)ensBuffer.size(); i++) for (int i = 0; i < (int)ensBuffer.size(); i++)
...@@ -561,8 +568,11 @@ namespace cv ...@@ -561,8 +568,11 @@ namespace cv
if (maxSc < 0) if (maxSc < 0)
return false; return false;
res = maxScRect; else
return true; {
res = maxScRect;
return true;
}
} }
bool TLDDetector::ocl_detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize) bool TLDDetector::ocl_detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize)
......
...@@ -66,6 +66,8 @@ namespace cv ...@@ -66,6 +66,8 @@ namespace cv
static const cv::Size GaussBlurKernelSize(3, 3); static const cv::Size GaussBlurKernelSize(3, 3);
class TLDDetector class TLDDetector
{ {
public: public:
...@@ -79,6 +81,7 @@ namespace cv ...@@ -79,6 +81,7 @@ namespace cv
double ocl_Sc(const Mat_<uchar>& patch); double ocl_Sc(const Mat_<uchar>& patch);
void ocl_batchSrSc(const Mat_<uchar>& patches, double *resultSr, double *resultSc, int numOfPatches); void ocl_batchSrSc(const Mat_<uchar>& patches, double *resultSr, double *resultSc, int numOfPatches);
std::vector <Rect2d> debugStack[10];
std::vector<TLDEnsembleClassifier> classifiers; std::vector<TLDEnsembleClassifier> classifiers;
Mat *posExp, *negExp; Mat *posExp, *negExp;
int *posNum, *negNum; int *posNum, *negNum;
...@@ -93,15 +96,14 @@ namespace cv ...@@ -93,15 +96,14 @@ namespace cv
bool isObject, shouldBeIntegrated; bool isObject, shouldBeIntegrated;
}; };
bool detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize); bool detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize);
bool ocl_detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize); bool ocl_detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize);
protected:
friend class MyMouseCallbackDEBUG; friend class MyMouseCallbackDEBUG;
void computeIntegralImages(const Mat& img, Mat_<double>& intImgP, Mat_<double>& intImgP2){ integral(img, intImgP, intImgP2, CV_64F); } static void computeIntegralImages(const Mat& img, Mat_<double>& intImgP, Mat_<double>& intImgP2){ integral(img, intImgP, intImgP2, CV_64F); }
inline bool patchVariance(Mat_<double>& intImgP, Mat_<double>& intImgP2, double *originalVariance, Point pt, Size size); static inline bool patchVariance(Mat_<double>& intImgP, Mat_<double>& intImgP2, double *originalVariance, Point pt, Size size);
}; };
} }
} }
......
...@@ -45,6 +45,13 @@ ...@@ -45,6 +45,13 @@
namespace cv namespace cv
{ {
TrackerTLD::Params::Params(){}
void TrackerTLD::Params::read(const cv::FileNode& /*fn*/){}
void TrackerTLD::Params::write(cv::FileStorage& /*fs*/) const {}
Ptr<TrackerTLD> TrackerTLD::createTracker(const TrackerTLD::Params &parameters) Ptr<TrackerTLD> TrackerTLD::createTracker(const TrackerTLD::Params &parameters)
{ {
return Ptr<tld::TrackerTLDImpl>(new tld::TrackerTLDImpl(parameters)); return Ptr<tld::TrackerTLDImpl>(new tld::TrackerTLDImpl(parameters));
...@@ -112,7 +119,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -112,7 +119,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
Mat_<uchar> standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); Mat_<uchar> standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
std::vector<TLDDetector::LabeledPatch> detectorResults; std::vector<TLDDetector::LabeledPatch> detectorResults;
//best overlap around 92% //best overlap around 92%
std::vector<Rect2d> candidates; std::vector<Rect2d> candidates;
std::vector<double> candidatesRes; std::vector<double> candidatesRes;
bool trackerNeedsReInit = false; bool trackerNeedsReInit = false;
...@@ -123,12 +129,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -123,12 +129,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
if (i == 1) if (i == 1)
{ {
if (ocl::haveOpenCL()) if (!ocl::haveOpenCL())
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
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( ( (i == 0) && !data->failedLastTime && trackerProxy->update(image, tmpCandid) ) || ( DETECT_FLG))
{ {
candidates.push_back(tmpCandid); candidates.push_back(tmpCandid);
...@@ -144,7 +149,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -144,7 +149,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
trackerNeedsReInit = true; 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());
//dfprintf((stdout, "scale = %f\n", log(1.0 * boundingBox.width / (data->getMinSize()).width) / log(SCALE_STEP))); //dfprintf((stdout, "scale = %f\n", log(1.0 * boundingBox.width / (data->getMinSize()).width) / log(SCALE_STEP)));
...@@ -230,6 +234,16 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -230,6 +234,16 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
#endif #endif
} }
//Debug display candidates after Variance Filter
////////////////////////////////////////////////
Mat tmpImg = image;
for (int i = 0; i < tldModel->detector->debugStack[0].size(); i++)
//rectangle(tmpImg, tldModel->detector->debugStack[0][i], Scalar(255, 255, 255), 1, 1, 0);
tldModel->detector->debugStack[0].clear();
tmpImg.copyTo(image);
////////////////////////////////////////////////
return true; return true;
} }
......
...@@ -52,12 +52,6 @@ ...@@ -52,12 +52,6 @@
namespace cv namespace cv
{ {
TrackerTLD::Params::Params(){}
void TrackerTLD::Params::read(const cv::FileNode& /*fn*/){}
void TrackerTLD::Params::write(cv::FileStorage& /*fs*/) const {}
namespace tld namespace tld
{ {
class TrackerProxy class TrackerProxy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment