Commit 470a8221 authored by Alex Leontiev's avatar Alex Leontiev

Vadim

parent ff73c6f4
...@@ -86,15 +86,15 @@ void myassert(const Mat& img){ ...@@ -86,15 +86,15 @@ void myassert(const Mat& img){
} }
} }
} }
printf("black: %d out of %d (%f)\n",count,img.rows*img.cols,1.0*count/img.rows/img.cols); dprintf(("black: %d out of %d (%f)\n",count,img.rows*img.cols,1.0*count/img.rows/img.cols));
} }
void printPatch(const Mat_<uchar>& standardPatch){ void printPatch(const Mat_<uchar>& standardPatch){
for(int i=0;i<standardPatch.rows;i++){ for(int i=0;i<standardPatch.rows;i++){
for(int j=0;j<standardPatch.cols;j++){ for(int j=0;j<standardPatch.cols;j++){
printf("%5.2f, ",(double)standardPatch(i,j)); dprintf(("%5.2f, ",(double)standardPatch(i,j)));
} }
printf("\n"); dprintf(("\n"));
} }
} }
...@@ -180,6 +180,8 @@ double variance(const Mat& img){ ...@@ -180,6 +180,8 @@ double variance(const Mat& img){
} }
double variance(Mat_<unsigned int>& intImgP,Mat_<unsigned int>& intImgP2,Rect box){ double variance(Mat_<unsigned int>& intImgP,Mat_<unsigned int>& intImgP2,Rect box){
int x=(box.x),y=(box.y),width=(box.width),height=(box.height); int x=(box.x),y=(box.y),width=(box.width),height=(box.height);
CV_Assert(0<=x && (x+width)<=intImgP.cols && (x+width)<=intImgP2.cols);
CV_Assert(0<=y && (y+height)<=intImgP.rows && (y+height)<=intImgP2.rows);
double p=0,p2=0; double p=0,p2=0;
unsigned int A,B,C,D; unsigned int A,B,C,D;
...@@ -206,17 +208,17 @@ double NCC(Mat_<uchar> patch1,Mat_<uchar> patch2){ ...@@ -206,17 +208,17 @@ double NCC(Mat_<uchar> patch1,Mat_<uchar> patch2){
double s1=sum(patch1)(0),s2=sum(patch2)(0); double s1=sum(patch1)(0),s2=sum(patch2)(0);
double n1=norm(patch1),n2=norm(patch2); double n1=norm(patch1),n2=norm(patch2);
double prod=patch1.dot(patch2); double prod=patch1.dot(patch2);
double sq1=sqrt(n1*n1-s1*s1/N),sq2=sqrt(n2*n2-s2*s2/N); double sq1=sqrt(MAX(0.0,n1*n1-s1*s1/N)),sq2=sqrt(MAX(0.0,n2*n2-s2*s2/N));
double ares=(sq2==0)?sq1/abs(sq1):(prod-s1*s2/N)/sq1/sq2; double ares=(sq2==0)?sq1/abs(sq1):(prod-s1*s2/N)/sq1/sq2;
return ares; return ares;
/*Mat_<uchar> p1(80,80),p2(80,80); /*Mat_<uchar> p1(80,80),p2(80,80);
printf("NCC\n"); dprintf(("NCC\n"));
resample(patch1,Rect2d(Point2d(0,0),patch1.size()),p1); resample(patch1,Rect2d(Point2d(0,0),patch1.size()),p1);
resample(patch2,Rect2d(Point2d(0,0),patch2.size()),p2); resample(patch2,Rect2d(Point2d(0,0),patch2.size()),p2);
imshow("patch1",p1); imshow("patch1",p1);
imshow("patch2",p2); imshow("patch2",p2);
printf("NCC=%f\n",ncc); dprintf(("NCC=%f\n",ncc));
waitKey();*/ waitKey();*/
} }
unsigned int getMedian(const std::vector<unsigned int>& values, int size){ unsigned int getMedian(const std::vector<unsigned int>& values, int size){
...@@ -359,7 +361,7 @@ unsigned short int TLDEnsembleClassifier::code(const uchar* data,int rowstep)con ...@@ -359,7 +361,7 @@ unsigned short int TLDEnsembleClassifier::code(const uchar* data,int rowstep)con
position=position<<1; position=position<<1;
} }
//codeS[13]='\0'; //codeS[13]='\0';
//printf("integrate with code %s\n",codeS); //dprintf(("integrate with code %s\n",codeS));
return position; return position;
} }
......
...@@ -49,14 +49,22 @@ namespace cv {namespace tld ...@@ -49,14 +49,22 @@ namespace cv {namespace tld
{ {
//debug functions and variables //debug functions and variables
#define ALEX_DEBUG
#ifdef ALEX_DEBUG
#define dfprintf(x) fprintf x
#define dprintf(x) printf x
#else
#define dfprintf(x)
#define dprintf(x)
#endif
#define MEASURE_TIME(a) {\ #define MEASURE_TIME(a) {\
clock_t start;float milisec=0.0;\ clock_t start;float milisec=0.0;\
start=clock();{a} milisec=1000.0*(clock()-start)/CLOCKS_PER_SEC;\ start=clock();{a} milisec=1000.0*(clock()-start)/CLOCKS_PER_SEC;\
printf("%-90s took %f milis\n",#a,milisec); } dprintf(("%-90s took %f milis\n",#a,milisec)); }
#define HERE fprintf(stderr,"%d\n",__LINE__);fflush(stderr); #define HERE dprintf(("%d\n",__LINE__));fflush(stderr);
#define START_TICK(name) { clock_t start;double milisec=0.0; start=clock(); #define START_TICK(name) { clock_t start;double milisec=0.0; start=clock();
#define END_TICK(name) milisec=1000.0*(clock()-start)/CLOCKS_PER_SEC;\ #define END_TICK(name) milisec=1000.0*(clock()-start)/CLOCKS_PER_SEC;\
printf("%s took %f milis\n",name,milisec); } dprintf(("%s took %f milis\n",name,milisec)); }
extern Rect2d etalon; extern Rect2d etalon;
void myassert(const Mat& img); void myassert(const Mat& img);
void printPatch(const Mat_<uchar>& standardPatch); void printPatch(const Mat_<uchar>& standardPatch);
......
...@@ -48,6 +48,15 @@ ...@@ -48,6 +48,15 @@
namespace cv namespace cv
{ {
#undef ALEX_DEBUG
#ifdef ALEX_DEBUG
#define dfprintf(x) fprintf x
#define dprintf(x) printf x
#else
#define dfprintf(x)
#define dprintf(x)
#endif
/* /*
* TrackerMedianFlow * TrackerMedianFlow
*/ */
...@@ -200,7 +209,7 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){ ...@@ -200,7 +209,7 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){
std::vector<uchar> status(pointsToTrackOld.size()); std::vector<uchar> status(pointsToTrackOld.size());
std::vector<float> errors(pointsToTrackOld.size()); std::vector<float> errors(pointsToTrackOld.size());
calcOpticalFlowPyrLK(oldImage_gray, newImage_gray,pointsToTrackOld,pointsToTrackNew,status,errors,Size(3,3),5,termcrit,0); calcOpticalFlowPyrLK(oldImage_gray, newImage_gray,pointsToTrackOld,pointsToTrackNew,status,errors,Size(3,3),5,termcrit,0);
printf("\t%d after LK forward\n",(int)pointsToTrackOld.size()); dprintf(("\t%d after LK forward\n",(int)pointsToTrackOld.size()));
std::vector<Point2f> di; std::vector<Point2f> di;
for(int i=0;i<(int)pointsToTrackOld.size();i++){ for(int i=0;i<(int)pointsToTrackOld.size();i++){
...@@ -222,7 +231,7 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){ ...@@ -222,7 +231,7 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){
i--; i--;
} }
} }
printf("\t%d after LK backward\n",(int)pointsToTrackOld.size()); dprintf(("\t%d after LK backward\n",(int)pointsToTrackOld.size()));
if(pointsToTrackOld.size()==0 || di.size()==0){ if(pointsToTrackOld.size()==0 || di.size()==0){
return false; return false;
...@@ -239,7 +248,6 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){ ...@@ -239,7 +248,6 @@ bool MedianFlowCore::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){
return false; return false;
} }
//return newBddBox;
return true; return true;
} }
...@@ -286,7 +294,7 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec ...@@ -286,7 +294,7 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec
} }
double scale=getMedian(buf,n*(n-1)/2); double scale=getMedian(buf,n*(n-1)/2);
printf("iter %d %f %f %f\n",iteration,xshift,yshift,scale); dprintf(("iter %d %f %f %f\n",iteration,xshift,yshift,scale));
newRect.x=newCenter.x-scale*oldRect.width/2.0; newRect.x=newCenter.x-scale*oldRect.width/2.0;
newRect.y=newCenter.y-scale*oldRect.height/2.0; newRect.y=newCenter.y-scale*oldRect.height/2.0;
newRect.width=scale*oldRect.width; newRect.width=scale*oldRect.width;
...@@ -294,8 +302,8 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec ...@@ -294,8 +302,8 @@ Rect2d MedianFlowCore::vote(const std::vector<Point2f>& oldPoints,const std::vec
/*if(newRect.x<=0){ /*if(newRect.x<=0){
exit(0); exit(0);
}*/ }*/
printf("rect old [%f %f %f %f]\n",oldRect.x,oldRect.y,oldRect.width,oldRect.height); dprintf(("rect old [%f %f %f %f]\n",oldRect.x,oldRect.y,oldRect.width,oldRect.height));
printf("rect [%f %f %f %f]\n",newRect.x,newRect.y,newRect.width,newRect.height); dprintf(("rect [%f %f %f %f]\n",newRect.x,newRect.y,newRect.width,newRect.height));
iteration++; iteration++;
return newRect; return newRect;
...@@ -326,7 +334,7 @@ void MedianFlowCore::computeStatistics(std::vector<float>& data,int size){ ...@@ -326,7 +334,7 @@ void MedianFlowCore::computeStatistics(std::vector<float>& data,int size){
bins[std::min((int)(binnum*(data[i]-mini)/(maxi-mini)),binnum-1)]++; bins[std::min((int)(binnum*(data[i]-mini)/(maxi-mini)),binnum-1)]++;
} }
for(int i=0;i<binnum;i++){ for(int i=0;i<binnum;i++){
printf("[%4f,%4f] -- %4d\n",mini+(maxi-mini)/binnum*i,mini+(maxi-mini)/binnum*(i+1),bins[i]); dprintf(("[%4f,%4f] -- %4d\n",mini+(maxi-mini)/binnum*i,mini+(maxi-mini)/binnum*(i+1),bins[i]));
} }
} }
double MedianFlowCore::l2distance(Point2f p1,Point2f p2){ double MedianFlowCore::l2distance(Point2f p1,Point2f p2){
...@@ -350,8 +358,8 @@ void MedianFlowCore::check_FB(const Mat& oldImage,const Mat& newImage, ...@@ -350,8 +358,8 @@ void MedianFlowCore::check_FB(const Mat& oldImage,const Mat& newImage,
FBerror[i]=l2distance(oldPoints[i],pointsToTrackReprojection[i]); FBerror[i]=l2distance(oldPoints[i],pointsToTrackReprojection[i]);
} }
double FBerrorMedian=getMedian(FBerror); double FBerrorMedian=getMedian(FBerror);
printf("point median=%f\n",FBerrorMedian); dprintf(("point median=%f\n",FBerrorMedian));
printf("FBerrorMedian=%f\n",FBerrorMedian); dprintf(("FBerrorMedian=%f\n",FBerrorMedian));
for(int i=0;i<(int)oldPoints.size();i++){ for(int i=0;i<(int)oldPoints.size();i++){
status[i]=(FBerror[i]<FBerrorMedian); status[i]=(FBerror[i]<FBerrorMedian);
} }
......
...@@ -70,9 +70,7 @@ using namespace tld; ...@@ -70,9 +70,7 @@ using namespace tld;
* *
* vadim: * vadim:
* *
* dprintf
* variance outside * variance outside
* NCC sqrt(-)
* standard patch out (403) * standard patch out (403)
* pos by 2 in code() * pos by 2 in code()
* *
...@@ -268,7 +266,7 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){ ...@@ -268,7 +266,7 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
privateInfo.push_back(Ptr<Data>(data)); privateInfo.push_back(Ptr<Data>(data));
#if !1 #if !1
printf("here I am\n"); dprintf(("here I am\n"));
Mat image_blurred; Mat image_blurred;
GaussianBlur(image_gray,image_blurred,GaussBlurKernelSize,0.0); GaussianBlur(image_gray,image_blurred,GaussBlurKernelSize,0.0);
MyMouseCallbackDEBUG* callback=new MyMouseCallbackDEBUG(image_gray,image_blurred,detector); MyMouseCallbackDEBUG* callback=new MyMouseCallbackDEBUG(image_gray,image_blurred,detector);
...@@ -322,15 +320,15 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){ ...@@ -322,15 +320,15 @@ bool TrackerTLD::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());
fprintf(stdout,"scale=%f\n",log(1.0*boundingBox.width/(data->getMinSize()).width)/log(1.2)); dfprintf((stdout,"scale=%f\n",log(1.0*boundingBox.width/(data->getMinSize()).width)/log(1.2)));
for(int i=0;i<(int)candidatesRes.size();i++){ for(int i=0;i<(int)candidatesRes.size();i++){
printf("\tcandidatesRes[%d]=%f\n",i,candidatesRes[i]); dprintf(("\tcandidatesRes[%d]=%f\n",i,candidatesRes[i]));
} }
data->printme(); data->printme();
tldModel->printme(stdout); tldModel->printme(stdout);
#if !1 #if !1
if(data->frameNum==82){ if(data->frameNum==82){
printf("here I am\n"); dprintf(("here I am\n"));
MyMouseCallbackDEBUG* callback=new MyMouseCallbackDEBUG(imageForDetector,image_blurred,detector); MyMouseCallbackDEBUG* callback=new MyMouseCallbackDEBUG(imageForDetector,image_blurred,detector);
imshow("picker",imageForDetector); imshow("picker",imageForDetector);
setMouseCallback( "picker", MyMouseCallbackDEBUG::onMouse, (void*)callback); setMouseCallback( "picker", MyMouseCallbackDEBUG::onMouse, (void*)callback);
...@@ -352,11 +350,11 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){ ...@@ -352,11 +350,11 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){
if(!false && it!=candidatesRes.end()){ if(!false && it!=candidatesRes.end()){
resample(imageForDetector,candidates[it-candidatesRes.begin()],standardPatch); resample(imageForDetector,candidates[it-candidatesRes.begin()],standardPatch);
fprintf(stderr,"%d %f %f\n",data->frameNum,tldModel->Sc(standardPatch),tldModel->Sr(standardPatch)); dfprintf((stderr,"%d %f %f\n",data->frameNum,tldModel->Sc(standardPatch),tldModel->Sr(standardPatch)));
if(candidatesRes.size()==2 && it==(candidatesRes.begin()+1)) if(candidatesRes.size()==2 && it==(candidatesRes.begin()+1))
fprintf(stderr,"detector WON\n"); dfprintf((stderr,"detector WON\n"));
}else{ }else{
fprintf(stderr,"%d x x\n",data->frameNum); dfprintf((stderr,"%d x x\n",data->frameNum));
} }
if(*it > CORE_THRESHOLD){ if(*it > CORE_THRESHOLD){
...@@ -382,7 +380,7 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){ ...@@ -382,7 +380,7 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){
isObject[i]=expertResult; isObject[i]=expertResult;
} }
tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults,isObject,shouldBeIntegrated); tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults,isObject,shouldBeIntegrated);
printf("%d relabeled by nExpert\n",negRelabeled); dprintf(("%d relabeled by nExpert\n",negRelabeled));
pExpert.additionalExamples(examplesForModel,examplesForEnsemble); pExpert.additionalExamples(examplesForModel,examplesForEnsemble);
tldModel->integrateAdditional(examplesForModel,examplesForEnsemble,true); tldModel->integrateAdditional(examplesForModel,examplesForEnsemble,true);
examplesForModel.clear();examplesForEnsemble.clear(); examplesForModel.clear();examplesForEnsemble.clear();
...@@ -459,7 +457,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ ...@@ -459,7 +457,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){
} }
} }
} }
printf("positive patches: %d\nnegative patches: %d\n",(int)positiveExamples.size(),(int)negativeExamples.size()); dprintf(("positive patches: %d\nnegative patches: %d\n",(int)positiveExamples.size(),(int)negativeExamples.size()));
} }
void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector<Rect2d>& res,bool withScaling){ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector<Rect2d>& res,bool withScaling){
...@@ -485,7 +483,7 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector<Re ...@@ -485,7 +483,7 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector<Re
break; break;
} }
} }
printf("%d rects in res\n",(int)res.size()); dprintf(("%d rects in res\n",(int)res.size()));
} }
bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::vector<Rect2d>& rect,std::vector<bool>& isObject, bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::vector<Rect2d>& rect,std::vector<bool>& isObject,
...@@ -551,7 +549,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v ...@@ -551,7 +549,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v
}while(size.width>=initSize.width && size.height>=initSize.height); }while(size.width>=initSize.width && size.height>=initSize.height);
END_TICK("detector"); END_TICK("detector");
fprintf(stdout,"after NCC: nneg=%d npos=%d\n",nneg,npos); dfprintf((stdout,"after NCC: nneg=%d npos=%d\n",nneg,npos));
#if !0 #if !0
std::vector<Rect2d> poss,negs; std::vector<Rect2d> poss,negs;
for(int i=0;i<(int)rect.size();i++){ for(int i=0;i<(int)rect.size();i++){
...@@ -560,7 +558,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v ...@@ -560,7 +558,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v
else else
negs.push_back(rect[i]); negs.push_back(rect[i]);
} }
fprintf(stdout,"%d pos and %d neg\n",(int)poss.size(),(int)negs.size()); dfprintf((stdout,"%d pos and %d neg\n",(int)poss.size(),(int)negs.size()));
drawWithRects(img,negs,poss); drawWithRects(img,negs,poss);
#endif #endif
#if !1 #if !1
...@@ -590,7 +588,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v ...@@ -590,7 +588,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v
waitKey(); waitKey();
#endif #endif
fprintf(stdout,"%d after ensemble\n",pass); dfprintf((stdout,"%d after ensemble\n",pass));
if(maxSc<0){ if(maxSc<0){
return false; return false;
} }
...@@ -690,14 +688,14 @@ void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vec ...@@ -690,14 +688,14 @@ void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vec
} }
} }
if(negativeIntoModel>0) if(negativeIntoModel>0)
fprintf(stdout,"negativeIntoModel=%d ",negativeIntoModel); dfprintf((stdout,"negativeIntoModel=%d ",negativeIntoModel));
if(positiveIntoModel>0) if(positiveIntoModel>0)
fprintf(stdout,"positiveIntoModel=%d ",positiveIntoModel); dfprintf((stdout,"positiveIntoModel=%d ",positiveIntoModel));
if(negativeIntoEnsemble>0) if(negativeIntoEnsemble>0)
fprintf(stdout,"negativeIntoEnsemble=%d ",negativeIntoEnsemble); dfprintf((stdout,"negativeIntoEnsemble=%d ",negativeIntoEnsemble));
if(positiveIntoEnsemble>0) if(positiveIntoEnsemble>0)
fprintf(stdout,"positiveIntoEnsemble=%d ",positiveIntoEnsemble); dfprintf((stdout,"positiveIntoEnsemble=%d ",positiveIntoEnsemble));
fprintf(stdout,"\n"); dfprintf((stdout,"\n"));
} }
void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForModel,const std::vector<Mat_<uchar> >& eForEnsemble,bool isPositive){ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForModel,const std::vector<Mat_<uchar> >& eForEnsemble,bool isPositive){
...@@ -730,14 +728,14 @@ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForM ...@@ -730,14 +728,14 @@ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForM
} }
} }
if(negativeIntoModel>0) if(negativeIntoModel>0)
fprintf(stdout,"negativeIntoModel=%d ",negativeIntoModel); dfprintf((stdout,"negativeIntoModel=%d ",negativeIntoModel));
if(positiveIntoModel>0) if(positiveIntoModel>0)
fprintf(stdout,"positiveIntoModel=%d ",positiveIntoModel); dfprintf((stdout,"positiveIntoModel=%d ",positiveIntoModel));
if(negativeIntoEnsemble>0) if(negativeIntoEnsemble>0)
fprintf(stdout,"negativeIntoEnsemble=%d ",negativeIntoEnsemble); dfprintf((stdout,"negativeIntoEnsemble=%d ",negativeIntoEnsemble));
if(positiveIntoEnsemble>0) if(positiveIntoEnsemble>0)
fprintf(stdout,"positiveIntoEnsemble=%d ",positiveIntoEnsemble); dfprintf((stdout,"positiveIntoEnsemble=%d ",positiveIntoEnsemble));
fprintf(stdout,"\n"); dfprintf((stdout,"\n"));
} }
int Pexpert::additionalExamples(std::vector<Mat_<uchar> >& examplesForModel,std::vector<Mat_<uchar> >& examplesForEnsemble){ int Pexpert::additionalExamples(std::vector<Mat_<uchar> >& examplesForModel,std::vector<Mat_<uchar> >& examplesForEnsemble){
...@@ -789,20 +787,20 @@ Data::Data(Rect2d initBox){ ...@@ -789,20 +787,20 @@ 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;
printf("minSize= %dx%d\n",minSize.width,minSize.height); dprintf(("minSize= %dx%d\n",minSize.width,minSize.height));
} }
void Data::printme(FILE* port){ void Data::printme(FILE* port){
fprintf(port,"Data:\n"); dfprintf((port,"Data:\n"));
fprintf(port,"\tframeNum=%d\n",frameNum); dfprintf((port,"\tframeNum=%d\n",frameNum));
fprintf(port,"\tconfident=%s\n",confident?"true":"false"); dfprintf((port,"\tconfident=%s\n",confident?"true":"false"));
fprintf(port,"\tfailedLastTime=%s\n",failedLastTime?"true":"false"); dfprintf((port,"\tfailedLastTime=%s\n",failedLastTime?"true":"false"));
fprintf(port,"\tminSize=%dx%d\n",minSize.width,minSize.height); dfprintf((port,"\tminSize=%dx%d\n",minSize.width,minSize.height));
} }
void TrackerTLDModel::printme(FILE* port){ void TrackerTLDModel::printme(FILE* port){
fprintf(port,"TrackerTLDModel:\n"); dfprintf((port,"TrackerTLDModel:\n"));
fprintf(port,"\tpositiveExamples.size()=%d\n",(int)positiveExamples.size()); dfprintf((port,"\tpositiveExamples.size()=%d\n",(int)positiveExamples.size()));
fprintf(port,"\tnegativeExamples.size()=%d\n",(int)negativeExamples.size()); dfprintf((port,"\tnegativeExamples.size()=%d\n",(int)negativeExamples.size()));
} }
void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){
if(event== EVENT_LBUTTONDOWN){ if(event== EVENT_LBUTTONDOWN){
...@@ -827,17 +825,17 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ ...@@ -827,17 +825,17 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){
int dx=initSize.width/10, dy=initSize.height/10, int dx=initSize.width/10, dy=initSize.height/10,
i=(int)(x/scale/dx), j=(int)(y/scale/dy); i=(int)(x/scale/dx), j=(int)(y/scale/dy);
fprintf(stderr,"patchVariance=%s\n",(detector_->patchVariance(intImgP,intImgP2,originalVariance,Point(dx*i,dy*j),initSize))?"true":"false"); dfprintf((stderr,"patchVariance=%s\n",(detector_->patchVariance(intImgP,intImgP2,originalVariance,Point(dx*i,dy*j),initSize))?"true":"false"));
fprintf(stderr,"p=%f\n",(detector_->ensembleClassifierNum(&blurred_img.at<uchar>(dy*j,dx*i),(int)blurred_img.step[0]))); dfprintf((stderr,"p=%f\n",(detector_->ensembleClassifierNum(&blurred_img.at<uchar>(dy*j,dx*i),(int)blurred_img.step[0]))));
fprintf(stderr,"ensembleClassifier=%s\n", fprintf(stderr,"ensembleClassifier=%s\n",
(detector_->ensembleClassifier(&blurred_img.at<uchar>(dy*j,dx*i),(int)blurred_img.step[0]))?"true":"false"); (detector_->ensembleClassifier(&blurred_img.at<uchar>(dy*j,dx*i),(int)blurred_img.step[0]))?"true":"false");
resample(resized_img,Rect2d(Point(dx*i,dy*j),initSize),standardPatch); resample(resized_img,Rect2d(Point(dx*i,dy*j),initSize),standardPatch);
tmp=tldModel->Sr(standardPatch); tmp=tldModel->Sr(standardPatch);
fprintf(stderr,"Sr=%f\n",tmp); dfprintf((stderr,"Sr=%f\n",tmp));
fprintf(stderr,"isObject=%s\n",(tmp>THETA_NN)?"true":"false"); dfprintf((stderr,"isObject=%s\n",(tmp>THETA_NN)?"true":"false"));
fprintf(stderr,"shouldBeIntegrated=%s\n",(abs(tmp-THETA_NN)<0.1)?"true":"false"); dfprintf((stderr,"shouldBeIntegrated=%s\n",(abs(tmp-THETA_NN)<0.1)?"true":"false"));
fprintf(stderr,"Sc=%f\n",tldModel->Sc(standardPatch)); dfprintf((stderr,"Sc=%f\n",tldModel->Sc(standardPatch)));
rectangle(imgCanvas,Rect2d(Point2d(scale*dx*i,scale*dy*j),Size2d(initSize.width*scale,initSize.height*scale)), 0, 2, 1 ); rectangle(imgCanvas,Rect2d(Point2d(scale*dx*i,scale*dy*j),Size2d(initSize.width*scale,initSize.height*scale)), 0, 2, 1 );
imshow("picker",imgCanvas); imshow("picker",imgCanvas);
......
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