Commit f16586f8 authored by Vladimir's avatar Vladimir

Cleaning up debug prints/variables/flags/timers

parent 4537103c
...@@ -75,7 +75,6 @@ namespace cv ...@@ -75,7 +75,6 @@ namespace cv
bool MultiTracker::update(const Mat& image) bool MultiTracker::update(const Mat& image)
{ {
printf("Naive-Loop MO-TLD Update....\n");
for (int i = 0; i < (int)trackers.size(); i++) for (int i = 0; i < (int)trackers.size(); i++)
if (!trackers[i]->update(image, boundingBoxes[i])) if (!trackers[i]->update(image, boundingBoxes[i]))
return false; return false;
...@@ -87,8 +86,6 @@ namespace cv ...@@ -87,8 +86,6 @@ namespace cv
/*Optimized update method for TLD Multitracker */ /*Optimized update method for TLD Multitracker */
bool MultiTrackerTLD::update_opt(const Mat& image) bool MultiTrackerTLD::update_opt(const Mat& image)
{ {
printf("Optimized MO-TLD Update....\n");
//Get parameters from first object //Get parameters from first object
//TLD Tracker data extraction //TLD Tracker data extraction
Tracker* trackerPtr = trackers[0]; Tracker* trackerPtr = trackers[0];
...@@ -186,16 +183,7 @@ namespace cv ...@@ -186,16 +183,7 @@ namespace cv
#if 1 #if 1
if (it != candidatesRes[k].end()) if (it != candidatesRes[k].end())
{
tld::resample(imageForDetector, candidates[k][it - candidatesRes[k].begin()], standardPatch); tld::resample(imageForDetector, candidates[k][it - candidatesRes[k].begin()], standardPatch);
//dfprintf((stderr, "%d %f %f\n", data->frameNum, tldModel->Sc(standardPatch), tldModel->Sr(standardPatch)));
//if( candidatesRes.size() == 2 && it == (candidatesRes.begin() + 1) )
//dfprintf((stderr, "detector WON\n"));
}
else
{
//dfprintf((stderr, "%d x x\n", data->frameNum));
}
#endif #endif
if (*it > tld::CORE_THRESHOLD) if (*it > tld::CORE_THRESHOLD)
...@@ -226,7 +214,6 @@ namespace cv ...@@ -226,7 +214,6 @@ namespace cv
detectorResults[k][i].isObject = expertResult; detectorResults[k][i].isObject = expertResult;
} }
tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults[k]); tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults[k]);
//dprintf(("%d relabeled by nExpert\n", negRelabeled));
pExpert.additionalExamples(examplesForModel, examplesForEnsemble); pExpert.additionalExamples(examplesForModel, examplesForEnsemble);
if (ocl::haveOpenCL()) if (ocl::haveOpenCL())
tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, true); tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, true);
...@@ -249,14 +236,7 @@ namespace cv ...@@ -249,14 +236,7 @@ namespace cv
} }
//Debug display candidates after Variance Filter
////////////////////////////////////////////////
Mat tmpImg = image;
for (int i = 0; i < (int)debugStack[0].size(); i++)
//rectangle(tmpImg, debugStack[0][i], Scalar(255, 255, 255), 1, 1, 0);
debugStack[0].clear();
tmpImg.copyTo(image);
////////////////////////////////////////////////
return true; return true;
} }
...@@ -290,10 +270,6 @@ namespace cv ...@@ -290,10 +270,6 @@ namespace cv
std::vector <Point> tmpP; std::vector <Point> tmpP;
std::vector <int> tmpI; std::vector <int> tmpI;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
//Detection part //Detection part
//Generate windows and filter by variance //Generate windows and filter by variance
scaleID = 0; scaleID = 0;
...@@ -344,10 +320,6 @@ namespace cv ...@@ -344,10 +320,6 @@ namespace cv
continue; continue;
varBuffer[k].push_back(Point(dx * i, dy * j)); varBuffer[k].push_back(Point(dx * i, dy * j));
varScaleIDs[k].push_back(scaleID); varScaleIDs[k].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, tldModel->getMinSize().width*curScale, tldModel->getMinSize().height*curScale));
} }
} }
} }
...@@ -361,16 +333,7 @@ namespace cv ...@@ -361,16 +333,7 @@ namespace cv
blurred_imgs.push_back(tmp); blurred_imgs.push_back(tmp);
} while (size.width >= initSize.width && size.height >= initSize.height); } while (size.width >= initSize.width && size.height >= initSize.height);
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Variance: %d\t%f\n", varBuffer.size(), t);
//printf("OrigVar 1: %f\n", *tldModel->detector->originalVariancePtr);
//Encsemble classification //Encsemble classification
//e1 = getTickCount();
for (int k = 0; k < (int)trackers.size(); k++) for (int k = 0; k < (int)trackers.size(); k++)
{ {
//TLD Tracker data extraction //TLD Tracker data extraction
...@@ -410,29 +373,9 @@ namespace cv ...@@ -410,29 +373,9 @@ namespace cv
ensBuffer[k].push_back(varBuffer[k][i]); ensBuffer[k].push_back(varBuffer[k][i]);
ensScaleIDs[k].push_back(varScaleIDs[k][i]); ensScaleIDs[k].push_back(varScaleIDs[k][i]);
} }
/*
for (int i = 0; i < (int)varBuffer[k].size(); i++)
{
tldModel->detector->prepareClassifiers(static_cast<int> (blurred_imgs[varScaleIDs[k][i]].step[0]));
if (tldModel->detector->ensembleClassifierNum(&blurred_imgs[varScaleIDs[k][i]].at<uchar>(varBuffer[k][i].y, varBuffer[k][i].x)) <= tld::ENSEMBLE_THRESHOLD)
continue;
ensBuffer[k].push_back(varBuffer[k][i]);
ensScaleIDs[k].push_back(varScaleIDs[k][i]);
} }
*/
}
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Ensemble: %d\t%f\n", ensBuffer.size(), t);
//printf("varBuffer 1: %d\n", varBuffer[0].size());
//printf("ensBuffer 1: %d\n", ensBuffer[0].size());
//printf("varBuffer 2: %d\n", varBuffer[1].size());
//printf("ensBuffer 2: %d\n", ensBuffer[1].size());
//NN classification //NN classification
//e1 = getTickCount();
for (int k = 0; k < (int)trackers.size(); k++) for (int k = 0; k < (int)trackers.size(); k++)
{ {
//TLD Tracker data extraction //TLD Tracker data extraction
...@@ -477,7 +420,6 @@ namespace cv ...@@ -477,7 +420,6 @@ namespace cv
maxSc = scValue; maxSc = scValue;
maxScRect = labPatch.rect; maxScRect = labPatch.rect;
} }
//printf("%d %f %f\n", k, srValue, scValue);
} }
...@@ -487,13 +429,9 @@ namespace cv ...@@ -487,13 +429,9 @@ namespace cv
else else
{ {
res[k] = maxScRect; res[k] = maxScRect;
//printf("%f %f %f %f\n", maxScRect.x, maxScRect.y, maxScRect.width, maxScRect.height);
detect_flgs[k] = true; detect_flgs[k] = true;
} }
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("NN: %d\t%f\n", patches.size(), t);
} }
void ocl_detect_all(const Mat& img, const Mat& imgBlurred, std::vector<Rect2d>& res, std::vector < std::vector < tld::TLDDetector::LabeledPatch > > &patches, std::vector<bool> &detect_flgs, void ocl_detect_all(const Mat& img, const Mat& imgBlurred, std::vector<Rect2d>& res, std::vector < std::vector < tld::TLDDetector::LabeledPatch > > &patches, std::vector<bool> &detect_flgs,
...@@ -526,10 +464,6 @@ namespace cv ...@@ -526,10 +464,6 @@ namespace cv
std::vector <Point> tmpP; std::vector <Point> tmpP;
std::vector <int> tmpI; std::vector <int> tmpI;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
//Detection part //Detection part
//Generate windows and filter by variance //Generate windows and filter by variance
scaleID = 0; scaleID = 0;
...@@ -580,10 +514,6 @@ namespace cv ...@@ -580,10 +514,6 @@ namespace cv
continue; continue;
varBuffer[k].push_back(Point(dx * i, dy * j)); varBuffer[k].push_back(Point(dx * i, dy * j));
varScaleIDs[k].push_back(scaleID); varScaleIDs[k].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, tldModel->getMinSize().width*curScale, tldModel->getMinSize().height*curScale));
} }
} }
} }
...@@ -597,16 +527,7 @@ namespace cv ...@@ -597,16 +527,7 @@ namespace cv
blurred_imgs.push_back(tmp); blurred_imgs.push_back(tmp);
} while (size.width >= initSize.width && size.height >= initSize.height); } while (size.width >= initSize.width && size.height >= initSize.height);
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Variance: %d\t%f\n", varBuffer.size(), t);
//printf("OrigVar 1: %f\n", *tldModel->detector->originalVariancePtr);
//Encsemble classification //Encsemble classification
//e1 = getTickCount();
for (int k = 0; k < (int)trackers.size(); k++) for (int k = 0; k < (int)trackers.size(); k++)
{ {
//TLD Tracker data extraction //TLD Tracker data extraction
...@@ -646,28 +567,9 @@ namespace cv ...@@ -646,28 +567,9 @@ namespace cv
ensBuffer[k].push_back(varBuffer[k][i]); ensBuffer[k].push_back(varBuffer[k][i]);
ensScaleIDs[k].push_back(varScaleIDs[k][i]); ensScaleIDs[k].push_back(varScaleIDs[k][i]);
} }
/*
for (int i = 0; i < (int)varBuffer[k].size(); i++)
{
tldModel->detector->prepareClassifiers(static_cast<int> (blurred_imgs[varScaleIDs[k][i]].step[0]));
if (tldModel->detector->ensembleClassifierNum(&blurred_imgs[varScaleIDs[k][i]].at<uchar>(varBuffer[k][i].y, varBuffer[k][i].x)) <= tld::ENSEMBLE_THRESHOLD)
continue;
ensBuffer[k].push_back(varBuffer[k][i]);
ensScaleIDs[k].push_back(varScaleIDs[k][i]);
}
*/
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("varBuffer 1: %d\n", varBuffer[0].size());
//printf("ensBuffer 1: %d\n", ensBuffer[0].size());
//printf("varBuffer 2: %d\n", varBuffer[1].size());
//printf("ensBuffer 2: %d\n", ensBuffer[1].size());
//NN classification //NN classification
//e1 = getTickCount();
for (int k = 0; k < (int)trackers.size(); k++) for (int k = 0; k < (int)trackers.size(); k++)
{ {
//TLD Tracker data extraction //TLD Tracker data extraction
...@@ -675,7 +577,6 @@ namespace cv ...@@ -675,7 +577,6 @@ namespace cv
tracker = static_cast<tld::TrackerTLDImpl*>(trackerPtr); tracker = static_cast<tld::TrackerTLDImpl*>(trackerPtr);
//TLD Model Extraction //TLD Model Extraction
tldModel = ((tld::TrackerTLDModel*)static_cast<TrackerModel*>(tracker->model)); tldModel = ((tld::TrackerTLDModel*)static_cast<TrackerModel*>(tracker->model));
//Size InitSize = tldModel->getMinSize();
npos = 0; npos = 0;
nneg = 0; nneg = 0;
maxSc = -5.0; maxSc = -5.0;
...@@ -730,7 +631,6 @@ namespace cv ...@@ -730,7 +631,6 @@ namespace cv
maxSc = scValue; maxSc = scValue;
maxScRect = labPatch.rect; maxScRect = labPatch.rect;
} }
//printf("%d %f %f\n", k, srValue, scValue);
} }
...@@ -740,13 +640,9 @@ namespace cv ...@@ -740,13 +640,9 @@ namespace cv
else else
{ {
res[k] = maxScRect; res[k] = maxScRect;
//printf("%f %f %f %f\n", maxScRect.x, maxScRect.y, maxScRect.width, maxScRect.height);
detect_flgs[k] = true; detect_flgs[k] = true;
} }
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("NN: %d\t%f\n", patches.size(), t);
} }
} }
\ No newline at end of file
...@@ -53,6 +53,5 @@ namespace cv ...@@ -53,6 +53,5 @@ namespace cv
std::vector<bool>& detect_flgs, std::vector<Ptr<Tracker> >& trackers); std::vector<bool>& detect_flgs, std::vector<Ptr<Tracker> >& trackers);
void ocl_detect_all(const Mat& img, const Mat& imgBlurred, std::vector<Rect2d>& res, std::vector < std::vector < tld::TLDDetector::LabeledPatch > > &patches, void ocl_detect_all(const Mat& img, const Mat& imgBlurred, std::vector<Rect2d>& res, std::vector < std::vector < tld::TLDDetector::LabeledPatch > > &patches,
std::vector<bool>& detect_flgs, std::vector<Ptr<Tracker> >& trackers); std::vector<bool>& detect_flgs, std::vector<Ptr<Tracker> >& trackers);
std::vector <Rect2d> debugStack[10];
} }
#endif #endif
\ No newline at end of file
...@@ -65,25 +65,6 @@ namespace cv ...@@ -65,25 +65,6 @@ namespace cv
// Calculate Relative similarity of the patch (NN-Model) // Calculate Relative similarity of the patch (NN-Model)
double TLDDetector::Sr(const Mat_<uchar>& patch) double TLDDetector::Sr(const Mat_<uchar>& patch)
{ {
/*
int64 e1, e2;
float t;
e1 = getTickCount();
double splus = 0.0, sminus = 0.0;
for (int i = 0; i < (int)(*positiveExamples).size(); i++)
splus = std::max(splus, 0.5 * (NCC((*positiveExamples)[i], patch) + 1.0));
for (int i = 0; i < (int)(*negativeExamples).size(); i++)
sminus = std::max(sminus, 0.5 * (NCC((*negativeExamples)[i], patch) + 1.0));
e2 = getTickCount();
t = (e2 - e1) / getTickFrequency()*1000.0;
printf("Sr: %f\n", t);
if (splus + sminus == 0.0)
return 0.0;
return splus / (sminus + splus);
*/
//int64 e1, e2;
//float t;
//e1 = getTickCount();
double splus = 0.0, sminus = 0.0; double splus = 0.0, sminus = 0.0;
Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
for (int i = 0; i < *posNum; i++) for (int i = 0; i < *posNum; i++)
...@@ -96,9 +77,7 @@ namespace cv ...@@ -96,9 +77,7 @@ namespace cv
modelSample.data = &(negExp->data[i * 225]); modelSample.data = &(negExp->data[i * 225]);
sminus = std::max(sminus, 0.5 * (NCC(modelSample, patch) + 1.0)); sminus = std::max(sminus, 0.5 * (NCC(modelSample, patch) + 1.0));
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Sr CPU: %f\n", t);
if (splus + sminus == 0.0) if (splus + sminus == 0.0)
return 0.0; return 0.0;
return splus / (sminus + splus); return splus / (sminus + splus);
...@@ -106,10 +85,6 @@ namespace cv ...@@ -106,10 +85,6 @@ namespace cv
double TLDDetector::ocl_Sr(const Mat_<uchar>& patch) double TLDDetector::ocl_Sr(const Mat_<uchar>& patch)
{ {
//int64 e1, e2, e3, e4;
//double t;
//e1 = getTickCount();
//e3 = getTickCount();
double splus = 0.0, sminus = 0.0; double splus = 0.0, sminus = 0.0;
...@@ -134,38 +109,12 @@ namespace cv ...@@ -134,38 +109,12 @@ namespace cv
*posNum, *posNum,
*negNum); *negNum);
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Mem Cpy GPU: %f\n", t);
size_t globSize = 1000; size_t globSize = 1000;
//e3 = getTickCount();
if (!k.run(1, &globSize, NULL, false)) if (!k.run(1, &globSize, NULL, false))
printf("Kernel Run Error!!!"); printf("Kernel Run Error!!!");
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Kernel Run GPU: %f\n", t);
//e3 = getTickCount();
Mat resNCC = devNCC.getMat(ACCESS_READ); Mat resNCC = devNCC.getMat(ACCESS_READ);
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Read Mem GPU: %f\n", t);
////Compare
//Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
//for (int i = 0; i < 200; i+=17)
//{
// modelSample.data = &(posExp->data[i * 225]);
// printf("%f\t%f\n\n", resNCC.at<float>(i), NCC(modelSample, patch));
//}
//for (int i = 0; i < 200; i+=23)
//{
// modelSample.data = &(negExp->data[i * 225]);
// printf("%f\t%f\n", resNCC.at<float>(500+i), NCC(modelSample, patch));
//}
for (int i = 0; i < *posNum; i++) for (int i = 0; i < *posNum; i++)
splus = std::max(splus, 0.5 * (resNCC.at<float>(i) + 1.0)); splus = std::max(splus, 0.5 * (resNCC.at<float>(i) + 1.0));
...@@ -173,10 +122,6 @@ namespace cv ...@@ -173,10 +122,6 @@ namespace cv
for (int i = 0; i < *negNum; i++) for (int i = 0; i < *negNum; i++)
sminus = std::max(sminus, 0.5 * (resNCC.at<float>(i+500) +1.0)); sminus = std::max(sminus, 0.5 * (resNCC.at<float>(i+500) +1.0));
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Sr GPU: %f\n\n", t);
if (splus + sminus == 0.0) if (splus + sminus == 0.0)
return 0.0; return 0.0;
return splus / (sminus + splus); return splus / (sminus + splus);
...@@ -184,11 +129,6 @@ namespace cv ...@@ -184,11 +129,6 @@ namespace cv
void TLDDetector::ocl_batchSrSc(const Mat_<uchar>& patches, double *resultSr, double *resultSc, int numOfPatches) void TLDDetector::ocl_batchSrSc(const Mat_<uchar>& patches, double *resultSr, double *resultSc, int numOfPatches)
{ {
//int64 e1, e2, e3, e4;
//double t;
//e1 = getTickCount();
//e3 = getTickCount();
UMat devPatches = patches.getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY); UMat devPatches = patches.getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devPositiveSamples = posExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY); UMat devPositiveSamples = posExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devNegativeSamples = negExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY); UMat devNegativeSamples = negExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
...@@ -212,25 +152,13 @@ namespace cv ...@@ -212,25 +152,13 @@ namespace cv
*negNum, *negNum,
numOfPatches); numOfPatches);
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Mem Cpy GPU: %f\n", t);
// 2 -> Pos&Neg
size_t globSize = 2 * numOfPatches*MAX_EXAMPLES_IN_MODEL; size_t globSize = 2 * numOfPatches*MAX_EXAMPLES_IN_MODEL;
//e3 = getTickCount();
if (!k.run(1, &globSize, NULL, true)) if (!k.run(1, &globSize, NULL, true))
printf("Kernel Run Error!!!"); printf("Kernel Run Error!!!");
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Kernel Run GPU: %f\n", t);
//e3 = getTickCount();
Mat posNCC = devPosNCC.getMat(ACCESS_READ); Mat posNCC = devPosNCC.getMat(ACCESS_READ);
Mat negNCC = devNegNCC.getMat(ACCESS_READ); Mat negNCC = devNegNCC.getMat(ACCESS_READ);
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Read Mem GPU: %f\n", t);
//Calculate Srs //Calculate Srs
for (int id = 0; id < numOfPatches; id++) for (int id = 0; id < numOfPatches; id++)
...@@ -256,62 +184,11 @@ namespace cv ...@@ -256,62 +184,11 @@ namespace cv
else else
resultSc[id] = spc / (smc + spc); resultSc[id] = spc / (smc + spc);
} }
////Compare positive NCCs
/*Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
Mat_<uchar> patch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
for (int j = 0; j < numOfPatches; j++)
{
for (int i = 0; i < 1; i++)
{
modelSample.data = &(posExp->data[i * 225]);
patch.data = &(patches.data[j * 225]);
printf("%f\t%f\n", resultSr[j], Sr(patch));
printf("%f\t%f\n", resultSc[j], Sc(patch));
}
}*/
//for (int i = 0; i < 200; i+=23)
//{
// modelSample.data = &(negExp->data[i * 225]);
// printf("%f\t%f\n", resNCC.at<float>(500+i), NCC(modelSample, patch));
//}
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Sr GPU: %f\n\n", t);
} }
// Calculate Conservative similarity of the patch (NN-Model) // Calculate Conservative similarity of the patch (NN-Model)
double TLDDetector::Sc(const Mat_<uchar>& patch) double TLDDetector::Sc(const Mat_<uchar>& patch)
{ {
/*
int64 e1, e2;
float t;
e1 = getTickCount();
double splus = 0.0, sminus = 0.0;
int med = getMedian((*timeStampsPositive));
for (int i = 0; i < (int)(*positiveExamples).size(); i++)
{
if ((int)(*timeStampsPositive)[i] <= med)
splus = std::max(splus, 0.5 * (NCC((*positiveExamples)[i], patch) + 1.0));
}
for (int i = 0; i < (int)(*negativeExamples).size(); i++)
sminus = std::max(sminus, 0.5 * (NCC((*negativeExamples)[i], patch) + 1.0));
e2 = getTickCount();
t = (e2 - e1) / getTickFrequency()*1000.0;
printf("Sc: %f\n", t);
if (splus + sminus == 0.0)
return 0.0;
return splus / (sminus + splus);
*/
//int64 e1, e2;
//double t;
//e1 = getTickCount();
double splus = 0.0, sminus = 0.0; double splus = 0.0, sminus = 0.0;
Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
int med = getMedian((*timeStampsPositive)); int med = getMedian((*timeStampsPositive));
...@@ -328,9 +205,7 @@ namespace cv ...@@ -328,9 +205,7 @@ namespace cv
modelSample.data = &(negExp->data[i * 225]); modelSample.data = &(negExp->data[i * 225]);
sminus = std::max(sminus, 0.5 * (NCC(modelSample, patch) + 1.0)); sminus = std::max(sminus, 0.5 * (NCC(modelSample, patch) + 1.0));
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Sc: %f\n", t);
if (splus + sminus == 0.0) if (splus + sminus == 0.0)
return 0.0; return 0.0;
...@@ -339,13 +214,8 @@ namespace cv ...@@ -339,13 +214,8 @@ namespace cv
double TLDDetector::ocl_Sc(const Mat_<uchar>& patch) double TLDDetector::ocl_Sc(const Mat_<uchar>& patch)
{ {
//int64 e1, e2, e3, e4;
//float t;
//e1 = getTickCount();
double splus = 0.0, sminus = 0.0; double splus = 0.0, sminus = 0.0;
//e3 = getTickCount();
UMat devPatch = patch.getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY); UMat devPatch = patch.getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devPositiveSamples = posExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY); UMat devPositiveSamples = posExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devNegativeSamples = negExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY); UMat devNegativeSamples = negExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
...@@ -367,37 +237,12 @@ namespace cv ...@@ -367,37 +237,12 @@ namespace cv
*posNum, *posNum,
*negNum); *negNum);
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Mem Cpy GPU: %f\n", t);
size_t globSize = 1000; size_t globSize = 1000;
//e3 = getTickCount();
if (!k.run(1, &globSize, NULL, false)) if (!k.run(1, &globSize, NULL, false))
printf("Kernel Run Error!!!"); printf("Kernel Run Error!!!");
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Kernel Run GPU: %f\n", t);
//e3 = getTickCount();
Mat resNCC = devNCC.getMat(ACCESS_READ); Mat resNCC = devNCC.getMat(ACCESS_READ);
//e4 = getTickCount();
//t = (e4 - e3) / getTickFrequency()*1000.0;
//printf("Read Mem GPU: %f\n", t);
////Compare
//Mat_<uchar> modelSample(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE);
//for (int i = 0; i < 200; i+=17)
//{
// modelSample.data = &(posExp->data[i * 225]);
// printf("%f\t%f\n\n", resNCC.at<float>(i), NCC(modelSample, patch));
//}
//for (int i = 0; i < 200; i+=23)
//{
// modelSample.data = &(negExp->data[i * 225]);
// printf("%f\t%f\n", resNCC.at<float>(500+i), NCC(modelSample, patch));
//}
int med = getMedian((*timeStampsPositive)); int med = getMedian((*timeStampsPositive));
for (int i = 0; i < *posNum; i++) for (int i = 0; i < *posNum; i++)
...@@ -407,10 +252,6 @@ namespace cv ...@@ -407,10 +252,6 @@ namespace cv
for (int i = 0; i < *negNum; i++) for (int i = 0; i < *negNum; i++)
sminus = std::max(sminus, 0.5 * (resNCC.at<float>(i + 500) + 1.0)); sminus = std::max(sminus, 0.5 * (resNCC.at<float>(i + 500) + 1.0));
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Sc GPU: %f\n\n", t);
if (splus + sminus == 0.0) if (splus + sminus == 0.0)
return 0.0; return 0.0;
return splus / (sminus + splus); return splus / (sminus + splus);
...@@ -449,7 +290,6 @@ namespace cv ...@@ -449,7 +290,6 @@ namespace cv
break; break;
} }
} }
//dprintf(("%d rects in res\n", (int)res.size()));
} }
//Detection - returns most probable new target location (Max Sc) //Detection - returns most probable new target location (Max Sc)
...@@ -469,10 +309,6 @@ namespace cv ...@@ -469,10 +309,6 @@ namespace cv
std::vector <Mat> resized_imgs, blurred_imgs; std::vector <Mat> resized_imgs, blurred_imgs;
std::vector <Point> varBuffer, ensBuffer; std::vector <Point> varBuffer, ensBuffer;
std::vector <int> varScaleIDs, ensScaleIDs; std::vector <int> varScaleIDs, ensScaleIDs;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
//Detection part //Detection part
//Generate windows and filter by variance //Generate windows and filter by variance
...@@ -491,10 +327,6 @@ namespace cv ...@@ -491,10 +327,6 @@ 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++;
...@@ -506,12 +338,8 @@ namespace cv ...@@ -506,12 +338,8 @@ namespace cv
GaussianBlur(resized_imgs[scaleID], tmp, GaussBlurKernelSize, 0.0f); GaussianBlur(resized_imgs[scaleID], tmp, GaussBlurKernelSize, 0.0f);
blurred_imgs.push_back(tmp); blurred_imgs.push_back(tmp);
} while (size.width >= initSize.width && size.height >= initSize.height); } while (size.width >= initSize.width && size.height >= initSize.height);
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Variance: %d\t%f\n", varBuffer.size(), t);
//Encsemble classification //Encsemble classification
//e1 = getTickCount();
for (int i = 0; i < (int)varBuffer.size(); i++) for (int i = 0; i < (int)varBuffer.size(); i++)
{ {
prepareClassifiers(static_cast<int> (blurred_imgs[varScaleIDs[i]].step[0])); prepareClassifiers(static_cast<int> (blurred_imgs[varScaleIDs[i]].step[0]));
...@@ -520,15 +348,8 @@ namespace cv ...@@ -520,15 +348,8 @@ namespace cv
ensBuffer.push_back(varBuffer[i]); ensBuffer.push_back(varBuffer[i]);
ensScaleIDs.push_back(varScaleIDs[i]); ensScaleIDs.push_back(varScaleIDs[i]);
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//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();
for (int i = 0; i < (int)ensBuffer.size(); i++) for (int i = 0; i < (int)ensBuffer.size(); i++)
{ {
LabeledPatch labPatch; LabeledPatch labPatch;
...@@ -562,9 +383,6 @@ namespace cv ...@@ -562,9 +383,6 @@ namespace cv
maxScRect = labPatch.rect; maxScRect = labPatch.rect;
} }
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("NN: %d\t%f\n", patches.size(), t);
if (maxSc < 0) if (maxSc < 0)
return false; return false;
...@@ -590,10 +408,7 @@ namespace cv ...@@ -590,10 +408,7 @@ namespace cv
std::vector <Mat> resized_imgs, blurred_imgs; std::vector <Mat> resized_imgs, blurred_imgs;
std::vector <Point> varBuffer, ensBuffer; std::vector <Point> varBuffer, ensBuffer;
std::vector <int> varScaleIDs, ensScaleIDs; std::vector <int> varScaleIDs, ensScaleIDs;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
//Detection part //Detection part
//Generate windows and filter by variance //Generate windows and filter by variance
scaleID = 0; scaleID = 0;
...@@ -622,12 +437,8 @@ namespace cv ...@@ -622,12 +437,8 @@ namespace cv
GaussianBlur(resized_imgs[scaleID], tmp, GaussBlurKernelSize, 0.0f); GaussianBlur(resized_imgs[scaleID], tmp, GaussBlurKernelSize, 0.0f);
blurred_imgs.push_back(tmp); blurred_imgs.push_back(tmp);
} while (size.width >= initSize.width && size.height >= initSize.height); } while (size.width >= initSize.width && size.height >= initSize.height);
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Variance: %d\t%f\n", varBuffer.size(), t);
//Encsemble classification //Encsemble classification
//e1 = getTickCount();
for (int i = 0; i < (int)varBuffer.size(); i++) for (int i = 0; i < (int)varBuffer.size(); i++)
{ {
prepareClassifiers((int)blurred_imgs[varScaleIDs[i]].step[0]); prepareClassifiers((int)blurred_imgs[varScaleIDs[i]].step[0]);
...@@ -636,12 +447,8 @@ namespace cv ...@@ -636,12 +447,8 @@ namespace cv
ensBuffer.push_back(varBuffer[i]); ensBuffer.push_back(varBuffer[i]);
ensScaleIDs.push_back(varScaleIDs[i]); ensScaleIDs.push_back(varScaleIDs[i]);
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Ensemble: %d\t%f\n", ensBuffer.size(), t);
//NN classification //NN classification
//e1 = getTickCount();
//Prepare batch of patches //Prepare batch of patches
int numOfPatches = (int)ensBuffer.size(); int numOfPatches = (int)ensBuffer.size();
Mat_<uchar> stdPatches(numOfPatches, 225); Mat_<uchar> stdPatches(numOfPatches, 225);
...@@ -671,9 +478,6 @@ namespace cv ...@@ -671,9 +478,6 @@ namespace cv
srValue = resultSr[i]; srValue = resultSr[i];
//srValue = Sr(standardPatch);
//printf("%f\t%f\t\n", srValue, resultSr[i]);
////To fix: Check the paper, probably this cause wrong learning ////To fix: Check the paper, probably this cause wrong learning
// //
labPatch.isObject = srValue > THETA_NN; labPatch.isObject = srValue > THETA_NN;
...@@ -697,9 +501,6 @@ namespace cv ...@@ -697,9 +501,6 @@ namespace cv
maxScRect = labPatch.rect; maxScRect = labPatch.rect;
} }
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("NN: %d\t%f\n", patches.size(), t);
if (maxSc < 0) if (maxSc < 0)
return false; return false;
......
...@@ -81,7 +81,6 @@ namespace cv ...@@ -81,7 +81,6 @@ 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;
......
...@@ -140,7 +140,6 @@ namespace cv ...@@ -140,7 +140,6 @@ namespace cv
detector->classifiers[k].integrate(blurredPatch, false); detector->classifiers[k].integrate(blurredPatch, false);
} }
} }
//dprintf(("positive patches: %d\nnegative patches: %d\n", (int)positiveExamples.size(), (int)negativeExamples.size()));
} }
...@@ -180,16 +179,6 @@ namespace cv ...@@ -180,16 +179,6 @@ namespace cv
detector->classifiers[i].integrate(blurredPatch, patches[k].isObject); detector->classifiers[i].integrate(blurredPatch, patches[k].isObject);
} }
} }
/*
if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0)
dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel));
if( negativeIntoEnsemble > 0 )
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
} }
...@@ -198,9 +187,6 @@ namespace cv ...@@ -198,9 +187,6 @@ namespace cv
int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0; int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0;
if ((int)eForModel.size() == 0) return; if ((int)eForModel.size() == 0) return;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
for (int k = 0; k < (int)eForModel.size(); k++) for (int k = 0; k < (int)eForModel.size(); k++)
{ {
double sr = detector->Sr(eForModel[k]); double sr = detector->Sr(eForModel[k]);
...@@ -231,19 +217,6 @@ namespace cv ...@@ -231,19 +217,6 @@ namespace cv
detector->classifiers[i].integrate(eForEnsemble[k], isPositive); detector->classifiers[i].integrate(eForEnsemble[k], isPositive);
} }
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency() * 1000;
//printf("Integrate Additional: %fms\n", t);
/*
if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0 )
dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel));
if( negativeIntoEnsemble > 0 )
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
} }
void TrackerTLDModel::ocl_integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive) void TrackerTLDModel::ocl_integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive)
...@@ -251,10 +224,6 @@ namespace cv ...@@ -251,10 +224,6 @@ namespace cv
int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0; int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0;
if ((int)eForModel.size() == 0) return; if ((int)eForModel.size() == 0) return;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
//Prepare batch of patches //Prepare batch of patches
int numOfPatches = (int)eForModel.size(); int numOfPatches = (int)eForModel.size();
Mat_<uchar> stdPatches(numOfPatches, 225); Mat_<uchar> stdPatches(numOfPatches, 225);
...@@ -301,19 +270,6 @@ namespace cv ...@@ -301,19 +270,6 @@ namespace cv
detector->classifiers[i].integrate(eForEnsemble[k], isPositive); detector->classifiers[i].integrate(eForEnsemble[k], isPositive);
} }
} }
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency() * 1000;
//printf("Integrate Additional OCL: %fms\n", t);
/*
if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0 )
dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel));
if( negativeIntoEnsemble > 0 )
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
} }
//Push the patch to the model //Push the patch to the model
......
...@@ -151,12 +151,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -151,12 +151,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
} }
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)));
//for( int i = 0; i < (int)candidatesRes.size(); i++ )
//dprintf(("\tcandidatesRes[%d] = %f\n", i, candidatesRes[i]));
//data->printme();
//tldModel->printme(stdout);
if( it == candidatesRes.end() ) if( it == candidatesRes.end() )
{ {
data->confident = false; data->confident = false;
...@@ -173,16 +167,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -173,16 +167,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
#if 1 #if 1
if( it != candidatesRes.end() ) if( it != candidatesRes.end() )
{
resample(imageForDetector, candidates[it - candidatesRes.begin()], standardPatch); resample(imageForDetector, candidates[it - candidatesRes.begin()], standardPatch);
//dfprintf((stderr, "%d %f %f\n", data->frameNum, tldModel->Sc(standardPatch), tldModel->Sr(standardPatch)));
//if( candidatesRes.size() == 2 && it == (candidatesRes.begin() + 1) )
//dfprintf((stderr, "detector WON\n"));
}
else
{
//dfprintf((stderr, "%d x x\n", data->frameNum));
}
#endif #endif
if( *it > CORE_THRESHOLD ) if( *it > CORE_THRESHOLD )
...@@ -213,7 +198,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -213,7 +198,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
detectorResults[i].isObject = expertResult; detectorResults[i].isObject = expertResult;
} }
tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults); tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults);
//dprintf(("%d relabeled by nExpert\n", negRelabeled));
pExpert.additionalExamples(examplesForModel, examplesForEnsemble); pExpert.additionalExamples(examplesForModel, examplesForEnsemble);
if (ocl::haveOpenCL()) if (ocl::haveOpenCL())
tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, true); tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, true);
...@@ -234,16 +218,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -234,16 +218,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
#endif #endif
} }
//Debug display candidates after Variance Filter
////////////////////////////////////////////////
Mat tmpImg = image;
for (int i = 0; i < (int)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;
} }
...@@ -310,7 +284,6 @@ Data::Data(Rect2d initBox) ...@@ -310,7 +284,6 @@ Data::Data(Rect2d initBox)
minSize.width = (int)(initBox.width * 20.0 / minDim); minSize.width = (int)(initBox.width * 20.0 / minDim);
minSize.height = (int)(initBox.height * 20.0 / minDim); minSize.height = (int)(initBox.height * 20.0 / minDim);
frameNum = 0; frameNum = 0;
//dprintf(("minSize = %dx%d\n", minSize.width, minSize.height));
} }
void Data::printme(FILE* port) void Data::printme(FILE* port)
......
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