From 97d2aa9ff034ef169ed5b19a397680f708a66611 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Wed, 16 Jul 2014 09:26:00 +0900 Subject: [PATCH 01/26] blur bug --- modules/tracking/samples/benchmark.cpp | 33 +++++++++++-------- .../tracking/src/TLDEnsembleClassifier.cpp | 2 +- modules/tracking/src/trackerTLD.cpp | 28 +++++++++------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/modules/tracking/samples/benchmark.cpp b/modules/tracking/samples/benchmark.cpp index 7d2324d34..bf67afcbb 100644 --- a/modules/tracking/samples/benchmark.cpp +++ b/modules/tracking/samples/benchmark.cpp @@ -7,7 +7,7 @@ #include #include -#define CMDLINEMAX 10 +#define CMDLINEMAX 30 #define ASSESS_TILL 100 #define LINEMAX 40 @@ -20,7 +20,8 @@ using namespace cv; static Mat image; static bool paused; -vector palette; +static bool saveImageKey; +static vector palette; void print_table(char* videos[],int videoNum,char* algorithms[],int algNum,const vector >& results,char* tableName); @@ -67,20 +68,15 @@ static void help(){ exit(EXIT_SUCCESS); } static void parseCommandLineArgs(int argc, char** argv,char* videos[],char* gts[], - int* vc,char* algorithms[],char* initBoxes[][CMDLINEMAX],int* ac){ + int* vc,char* algorithms[],char* initBoxes[][CMDLINEMAX],int* ac,char keys[CMDLINEMAX][LINEMAX]){ *ac=*vc=0; for(int i=1;i averageMillisPerFrame(algnum,0.0); + static int videoNum=0; + videoNum++; FILE* gt=fopen(gt_str,"r"); if(gt==NULL){ @@ -312,6 +310,11 @@ static AssessmentRes assessment(char* video,char* gt_str, char* algorithms[],cha res.results[i][j]->assess(boundingBox,initBoxes[i]); } imshow( "Tracking API", image ); + if(saveImageKey){ + char inbuf[LINEMAX]; + sprintf(inbuf,"image%d_%d.jpg",videoNum,frameCounter); + imwrite(inbuf,image); + } if((frameCounter+1)>=ASSESS_TILL){ break; @@ -342,7 +345,11 @@ int main( int argc, char** argv ){ palette.push_back(Scalar(0,255,255)); int vcount=0,acount=0; char* videos[CMDLINEMAX],*gts[CMDLINEMAX],*algorithms[CMDLINEMAX],*initBoxes[CMDLINEMAX][CMDLINEMAX]; - parseCommandLineArgs(argc,argv,videos,gts,&vcount,algorithms,initBoxes,&acount); + char keys[CMDLINEMAX][LINEMAX]; + strcpy(keys[0],"-s"); + parseCommandLineArgs(argc,argv,videos,gts,&vcount,algorithms,initBoxes,&acount,keys); + saveImageKey=(keys[0][0]=='\0'); + CV_Assert(acount0.6 dramatic change vs video 6 !! - * FIXME(features) - * benchmark: save photos --> two streams of photos --> better video + * TODO(features) + * benchmark: two streams of photos --> better video + * (try inter_area for resize) * TODO: - * schoolPC: codec, libopencv-dev * fix pushbot ->pick commits -> compare_branches->all in 1->resubmit - * ||video(0.5<->0.6) --> debug if box size is less than 20 --> (remove ensemble self-loop) --> (try inter_area for resize) + * ||video(0.5<->0.6) --> debug if box size is less than 20 * perfect PN * * vadim: @@ -446,7 +446,9 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ } #ifdef BLUR_AS_VADIM - GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); + resize(standardPatch,blurredPatch,minSize); + GaussianBlur(blurredPatch,blurredPatch,GaussBlurKernelSize,0.0); + CV_Assert(blurredPatch.cols==minSize.width && blurredPatch.rows==minSize.height); #else resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); #endif @@ -767,17 +769,19 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: size.height=(float)(closest[i].height*rng.uniform((double)0.99,(double)1.01)); float angle=(float)rng.uniform(-5.0,5.0); -#ifdef BLUR_AS_VADIM - GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); -#else - resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); -#endif - resample(scaledImg,RotatedRect(center,size,angle),standardPatch); for(int y=0;y Date: Thu, 17 Jul 2014 22:08:19 +0900 Subject: [PATCH 02/26] blur as vadim debug --- modules/tracking/src/trackerTLD.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/tracking/src/trackerTLD.cpp b/modules/tracking/src/trackerTLD.cpp index a666c2584..c5cf30efb 100644 --- a/modules/tracking/src/trackerTLD.cpp +++ b/modules/tracking/src/trackerTLD.cpp @@ -48,11 +48,12 @@ #include "TLD.hpp" #include "opencv2/highgui.hpp" -#define THETA_NN 0.5 +#define THETA_NN 0.50 #define CORE_THRESHOLD 0.5 #define NEG_EXAMPLES_IN_INIT_MODEL 300 #define MAX_EXAMPLES_IN_MODEL 500 #define MEASURES_PER_CLASSIFIER 13 +#define DOWNSCALE_MODE INTER_LINEAR #define BLUR_AS_VADIM #undef CLOSED_LOOP static const cv::Size GaussBlurKernelSize(3,3); @@ -269,7 +270,7 @@ bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox ){ Rect2d myBoundingBox=boundingBox; if(scale>1.0){ Mat image_proxy; - resize(image_gray,image_proxy,Size(cvRound(image.cols*scale),cvRound(image.rows*scale))); + resize(image_gray,image_proxy,Size(cvRound(image.cols*scale),cvRound(image.rows*scale)),0,0,DOWNSCALE_MODE); image_proxy.copyTo(image_gray); myBoundingBox.x*=scale; myBoundingBox.y*=scale; @@ -298,7 +299,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ cvtColor( image, image_gray, COLOR_BGR2GRAY ); double scale=data->getScale(); if(scale>1.0){ - resize(image_gray,imageForDetector,Size(cvRound(image.cols*scale),cvRound(image.rows*scale))); + resize(image_gray,imageForDetector,Size(cvRound(image.cols*scale),cvRound(image.rows*scale)),0,0,DOWNSCALE_MODE); }else{ imageForDetector=image_gray; } @@ -446,8 +447,8 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ } #ifdef BLUR_AS_VADIM - resize(standardPatch,blurredPatch,minSize); - GaussianBlur(blurredPatch,blurredPatch,GaussBlurKernelSize,0.0); + GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); + resize(blurredPatch,blurredPatch,minSize); CV_Assert(blurredPatch.cols==minSize.width && blurredPatch.rows==minSize.height); #else resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); @@ -564,7 +565,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v size.width/=1.2; size.height/=1.2; scale*=1.2; - resize(img,resized_img,size); + resize(img,resized_img,size,0,0,DOWNSCALE_MODE); GaussianBlur(resized_img,blurred_img,GaussBlurKernelSize,0.0f); }while(size.width>=initSize.width && size.height>=initSize.height); END_TICK("detector"); @@ -775,8 +776,8 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: } } #ifdef BLUR_AS_VADIM - resize(standardPatch,blurredPatch,initSize_); - GaussianBlur(blurredPatch,blurredPatch,GaussBlurKernelSize,0.0); + GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); + resize(blurredPatch,blurredPatch,initSize_); CV_Assert(blurredPatch.cols==initSize_.width && blurredPatch.rows==initSize_.height); #else resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); From f1d4a1e163031a0bdb2e586734017e3d901a3c8d Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Sat, 19 Jul 2014 22:51:01 +0900 Subject: [PATCH 03/26] commit --- modules/tracking/src/trackerTLD.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/tracking/src/trackerTLD.cpp b/modules/tracking/src/trackerTLD.cpp index c5cf30efb..4e44a77ab 100644 --- a/modules/tracking/src/trackerTLD.cpp +++ b/modules/tracking/src/trackerTLD.cpp @@ -449,7 +449,6 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ #ifdef BLUR_AS_VADIM GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); resize(blurredPatch,blurredPatch,minSize); - CV_Assert(blurredPatch.cols==minSize.width && blurredPatch.rows==minSize.height); #else resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); #endif @@ -778,7 +777,6 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: #ifdef BLUR_AS_VADIM GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); resize(blurredPatch,blurredPatch,initSize_); - CV_Assert(blurredPatch.cols==initSize_.width && blurredPatch.rows==initSize_.height); #else resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); #endif From 99ce8defc1fdfa6ca350c78b32b11612a354de09 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Sun, 20 Jul 2014 19:57:25 +0900 Subject: [PATCH 04/26] commit --- .../src/{TLDEnsembleClassifier.cpp => tld_classifier.cpp} | 2 +- modules/tracking/src/{trackerTLD.cpp => tld_tracker.cpp} | 2 +- modules/tracking/src/{TLD.hpp => tld_tracker.hpp} | 0 modules/tracking/src/{TLD.cpp => tld_utils.cpp} | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename modules/tracking/src/{TLDEnsembleClassifier.cpp => tld_classifier.cpp} (99%) rename modules/tracking/src/{trackerTLD.cpp => tld_tracker.cpp} (99%) rename modules/tracking/src/{TLD.hpp => tld_tracker.hpp} (100%) rename modules/tracking/src/{TLD.cpp => tld_utils.cpp} (99%) diff --git a/modules/tracking/src/TLDEnsembleClassifier.cpp b/modules/tracking/src/tld_classifier.cpp similarity index 99% rename from modules/tracking/src/TLDEnsembleClassifier.cpp rename to modules/tracking/src/tld_classifier.cpp index 44c7ad788..70c9bfd5a 100644 --- a/modules/tracking/src/TLDEnsembleClassifier.cpp +++ b/modules/tracking/src/tld_classifier.cpp @@ -44,7 +44,7 @@ #include "opencv2/imgproc.hpp" #include #include -#include "TLD.hpp" +#include "tld_utils.hpp" using namespace cv; diff --git a/modules/tracking/src/trackerTLD.cpp b/modules/tracking/src/tld_tracker.cpp similarity index 99% rename from modules/tracking/src/trackerTLD.cpp rename to modules/tracking/src/tld_tracker.cpp index 4e44a77ab..7e11176d4 100644 --- a/modules/tracking/src/trackerTLD.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -45,7 +45,7 @@ #include "time.h" #include #include -#include "TLD.hpp" +#include "tld_utils.hpp" #include "opencv2/highgui.hpp" #define THETA_NN 0.50 diff --git a/modules/tracking/src/TLD.hpp b/modules/tracking/src/tld_tracker.hpp similarity index 100% rename from modules/tracking/src/TLD.hpp rename to modules/tracking/src/tld_tracker.hpp diff --git a/modules/tracking/src/TLD.cpp b/modules/tracking/src/tld_utils.cpp similarity index 99% rename from modules/tracking/src/TLD.cpp rename to modules/tracking/src/tld_utils.cpp index 09cdfcf7c..d50fde8f9 100644 --- a/modules/tracking/src/TLD.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -47,7 +47,7 @@ #include #include #include -#include "TLD.hpp" +#include "tld_utils.hpp" namespace cv {namespace tld { From 19b2d7449090ef6bdfa198a15e975dbd200700f8 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Tue, 22 Jul 2014 22:23:06 +0900 Subject: [PATCH 05/26] commit --- modules/tracking/src/tld_tracker.cpp | 59 ++++------------------------ 1 file changed, 8 insertions(+), 51 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 7e11176d4..74a096693 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -49,6 +49,7 @@ #include "opencv2/highgui.hpp" #define THETA_NN 0.50 +#define STANDARD_PATCH_SIZE 15 #define CORE_THRESHOLD 0.5 #define NEG_EXAMPLES_IN_INIT_MODEL 300 #define MAX_EXAMPLES_IN_MODEL 500 @@ -282,15 +283,6 @@ bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox ){ data->confident=false; data->failedLastTime=false; -#if !1 - dprintf(("here I am\n")); - Mat image_blurred; - GaussianBlur(image_gray,image_blurred,GaussBlurKernelSize,0.0); - MyMouseCallbackDEBUG* callback=new MyMouseCallbackDEBUG(image_gray,image_blurred,detector); - imshow("picker",image_gray); - setMouseCallback( "picker", MyMouseCallbackDEBUG::onMouse, (void*)callback); - waitKey(); -#endif return true; } @@ -306,7 +298,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ GaussianBlur(imageForDetector,image_blurred,GaussBlurKernelSize,0.0); TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(model)); data->frameNum++; - Mat_ standardPatch(15,15); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); std::vector detectorResults; std::vector isObject,shouldBeIntegrated; //best overlap around 92% @@ -340,15 +332,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ } data->printme(); tldModel->printme(stdout); -#if !1 - if(data->frameNum==82){ - dprintf(("here I am\n")); - MyMouseCallbackDEBUG* callback=new MyMouseCallbackDEBUG(imageForDetector,image_blurred,detector); - imshow("picker",imageForDetector); - setMouseCallback( "picker", MyMouseCallbackDEBUG::onMouse, (void*)callback); - waitKey(); - } -#endif if(it==candidatesRes.end()){ data->confident=false; @@ -431,7 +414,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ Size2f size; for(int i=0;i<(int)closest.size();i++){ for(int j=0;j<20;j++){ - Mat_ standardPatch(15,15); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); center.x=(float)(closest[i].x+closest[i].width*(0.5+rng.uniform(-0.01,0.01))); center.y=(float)(closest[i].y+closest[i].height*(0.5+rng.uniform(-0.01,0.01))); size.width=(float)(closest[i].width*rng.uniform((double)0.99,(double)1.01)); @@ -467,7 +450,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ while(negativeExamples.size() standardPatch(15,15); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); resample(image,scanGrid[i],standardPatch); pushIntoModel(standardPatch,false); @@ -515,7 +498,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v shouldBeIntegrated.clear(); Mat resized_img,blurred_img; - Mat_ standardPatch(15,15); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); img.copyTo(resized_img); imgBlurred.copyTo(blurred_img); double originalVariance=tldModel->getOriginalVariance();; @@ -581,32 +564,6 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v dfprintf((stdout,"%d pos and %d neg\n",(int)poss.size(),(int)negs.size())); drawWithRects(img,negs,poss); #endif -#if !1 - std::vector scanGrid; - generateScanGrid(img.rows,img.cols,initSize,scanGrid); - std::vector results; - Mat_ standardPatch_inner(15,15); - for(int i=0;i<(int)scanGrid.size();i++){ - resample(img,scanGrid[i],standardPatch_inner); - results.push_back(tldModel->Sr(standardPatch_inner)); - } - std::vector::iterator it=std::max_element(results.begin(),results.end()); - Mat image; - img.copyTo(image); - rectangle( image,scanGrid[it-results.begin()], 255, 1, 1 ); - imshow("img",image); - waitKey(); -#endif -#if !1 - Mat image; - img.copyTo(image); - rectangle( image,res, 255, 1, 1 ); - for(int i=0;i<(int)rect.size();i++){ - rectangle( image,rect[i], 0, 1, 1 ); - } - imshow("img",image); - waitKey(); -#endif dfprintf((stdout,"%d after ensemble\n",pass)); if(maxSc<0){ @@ -666,7 +623,7 @@ double TrackerTLDModel::Sc(const Mat_ patch){ void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& box,const std::vector& isPositive, const std::vector& alsoIntoModel){ - Mat_ standardPatch(15,15),blurredPatch(minSize_); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(minSize_); int positiveIntoModel=0,negativeIntoModel=0,positiveIntoEnsemble=0,negativeIntoEnsemble=0; for(int k=0;k<(int)box.size();k++){ if(alsoIntoModel[k]){ @@ -762,7 +719,7 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: Size2f size; for(int i=0;i<(int)closest.size();i++){ for(int j=0;j<10;j++){ - Mat_ standardPatch(15,15),blurredPatch(initSize_); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(initSize_); center.x=(float)(closest[i].x+closest[i].width*(0.5+rng.uniform(-0.01,0.01))); center.y=(float)(closest[i].y+closest[i].height*(0.5+rng.uniform(-0.01,0.01))); size.width=(float)(closest[i].width*rng.uniform((double)0.99,(double)1.01)); @@ -822,7 +779,7 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ img_.copyTo(imgCanvas); TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(detector_->model)); Size initSize=tldModel->getMinSize(); - Mat_ standardPatch(15,15); + Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); double originalVariance=tldModel->getOriginalVariance();; double tmp; From 4b5c8412c1c82880d182f5a7f6ec95bbf39d26d8 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Thu, 24 Jul 2014 00:48:10 +0900 Subject: [PATCH 06/26] vadim 2 --- modules/tracking/src/tld_classifier.cpp | 2 +- modules/tracking/src/tld_tracker.cpp | 2 +- modules/tracking/src/tld_utils.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/tracking/src/tld_classifier.cpp b/modules/tracking/src/tld_classifier.cpp index 70c9bfd5a..0386e954b 100644 --- a/modules/tracking/src/tld_classifier.cpp +++ b/modules/tracking/src/tld_classifier.cpp @@ -44,7 +44,7 @@ #include "opencv2/imgproc.hpp" #include #include -#include "tld_utils.hpp" +#include "tld_tracker.hpp" using namespace cv; diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 74a096693..cb0bd7282 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -45,7 +45,7 @@ #include "time.h" #include #include -#include "tld_utils.hpp" +#include "tld_tracker.hpp" #include "opencv2/highgui.hpp" #define THETA_NN 0.50 diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index d50fde8f9..d52eb76b0 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -47,7 +47,7 @@ #include #include #include -#include "tld_utils.hpp" +#include "tld_tracker.hpp" namespace cv {namespace tld { From b76a7a3d443c12e24c1f7985e54d353cccd911c4 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Thu, 24 Jul 2014 04:36:13 +0900 Subject: [PATCH 07/26] vadim 7, 8 --- modules/tracking/src/tld_tracker.cpp | 18 +++++++++--------- modules/tracking/src/tld_tracker.hpp | 17 +++++++++++++---- modules/tracking/src/tld_utils.cpp | 6 +++--- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index cb0bd7282..dbf5023a7 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -191,8 +191,8 @@ class TrackerTLDModel : public TrackerModel{ void setBoudingBox(Rect2d boundingBox){boundingBox_=boundingBox;} double getOriginalVariance(){return originalVariance_;} std::vector* getClassifiers(){return &classifiers;} - double Sr(const Mat_ patch); - double Sc(const Mat_ patch); + double Sr(const Mat_& patch); + double Sc(const Mat_& patch); void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& box,const std::vector& isPositive, const std::vector& alsoIntoModel); void integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive); @@ -588,14 +588,14 @@ double TLDDetector::ensembleClassifierNum(const uchar* data,int rowstep){ return p; } -double TrackerTLDModel::Sr(const Mat_ patch){ +double TrackerTLDModel::Sr(const Mat_& patch){ double splus=0.0; for(int i=0;i<(int)positiveExamples.size();i++){ - splus=MAX(splus,0.5*(NCC(positiveExamples[i],patch)+1.0)); + splus=std::max(splus,0.5*(NCC(positiveExamples[i],patch)+1.0)); } double sminus=0.0; for(int i=0;i<(int)negativeExamples.size();i++){ - sminus=MAX(sminus,0.5*(NCC(negativeExamples[i],patch)+1.0)); + sminus=std::max(sminus,0.5*(NCC(negativeExamples[i],patch)+1.0)); } if(splus+sminus==0.0){ return 0.0; @@ -603,17 +603,17 @@ double TrackerTLDModel::Sr(const Mat_ patch){ return splus/(sminus+splus); } -double TrackerTLDModel::Sc(const Mat_ patch){ +double TrackerTLDModel::Sc(const Mat_& patch){ double splus=0.0; int med=getMedian(timeStampsPositive); for(int i=0;i<(int)positiveExamples.size();i++){ if((int)timeStampsPositive[i]<=med){ - splus=MAX(splus,0.5*(NCC(positiveExamples[i],patch)+1.0)); + splus=std::max(splus,0.5*(NCC(positiveExamples[i],patch)+1.0)); } } double sminus=0.0; for(int i=0;i<(int)negativeExamples.size();i++){ - sminus=MAX(sminus,0.5*(NCC(negativeExamples[i],patch)+1.0)); + sminus=std::max(sminus,0.5*(NCC(negativeExamples[i],patch)+1.0)); } if(splus+sminus==0.0){ return 0.0; @@ -753,7 +753,7 @@ bool Nexpert::operator()(Rect2d box){ } Data::Data(Rect2d initBox){ - double minDim=MIN(initBox.width,initBox.height); + double minDim=std::min(initBox.width,initBox.height); scale = 20.0/minDim; minSize.width=(int)(initBox.width*20.0/minDim); minSize.height=(int)(initBox.height*20.0/minDim); diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index c2c96272a..c575105ef 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -73,14 +73,23 @@ void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes); //aux functions and variables -//#define CLIP(x,a,b) MIN(MAX((x),(a)),(b)) -template inline T CLIP(T x,T a,T b){return MIN(MAX(x,a),b);} +//#define CLIP(x,a,b) std::min(std::max((x),(a)),(b)) +template inline T CLIP(T x,T a,T b){return std::min(std::max(x,a),b);} +/** Computes overlap between the two given rectangles. Overlap is computed as ratio of rectangles' intersection to that + * of their union.*/ double overlap(const Rect2d& r1,const Rect2d& r2); +/** Resamples the area surrounded by r2 in img so it matches the size of samples, where it is written.*/ void resample(const Mat& img,const RotatedRect& r2,Mat_& samples); +/** Specialization of resample() for rectangles without retation for better performance and simplicity.*/ void resample(const Mat& img,const Rect2d& r2,Mat_& samples); +/** Computes the variance of single given image.*/ double variance(const Mat& img); +/** Computes the variance of subimage given by box, with the help of two integral + * images intImgP and intImgP2 (sum of squares), which should be also provided.*/ double variance(Mat_& intImgP,Mat_& intImgP2,Rect box); -double NCC(Mat_ patch1,Mat_ patch2); +/** Computes normalized corellation coefficient between the two patches (they should be + * of the same size).*/ +double NCC(const Mat_& patch1,const Mat_& patch2); void getClosestN(std::vector& scanGrid,Rect2d bBox,int n,std::vector& res); double scaleAndBlur(const Mat& originalImg,int scale,Mat& scaledImg,Mat& blurredImg,Size GaussBlurKernelSize); unsigned int getMedian(const std::vector& values, int size=-1); @@ -88,7 +97,7 @@ unsigned int getMedian(const std::vector& values, int size=-1); class TLDEnsembleClassifier{ public: TLDEnsembleClassifier(int ordinal,Size size,int measurePerClassifier); - void integrate(Mat_ patch,bool isPositive); + void integrate(const Mat_& patch,bool isPositive); double posteriorProbability(const uchar* data,int rowstep)const; static int getMaxOrdinal(); private: diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index d52eb76b0..d7948ab07 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -199,7 +199,7 @@ double variance(Mat_& intImgP,Mat_& intImgP2,Rect box){ return p2-p*p; } -double NCC(Mat_ patch1,Mat_ patch2){ +double NCC(const Mat_& patch1,const Mat_& patch2){ CV_Assert(patch1.rows==patch2.rows); CV_Assert(patch1.cols==patch2.cols); @@ -207,7 +207,7 @@ double NCC(Mat_ patch1,Mat_ patch2){ double s1=sum(patch1)(0),s2=sum(patch2)(0); double n1=norm(patch1),n2=norm(patch2); double prod=patch1.dot(patch2); - double sq1=sqrt(MAX(0.0,n1*n1-s1*s1/N)),sq2=sqrt(MAX(0.0,n2*n2-s2*s2/N)); + double sq1=sqrt(std::max(0.0,n1*n1-s1*s1/N)),sq2=sqrt(std::max(0.0,n2*n2-s2*s2/N)); double ares=(sq2==0)?sq1/abs(sq1):(prod-s1*s2/N)/sq1/sq2; return ares; } @@ -300,7 +300,7 @@ TLDEnsembleClassifier::TLDEnsembleClassifier(int ordinal,Size size,int measurePe pos=std::vector(posSize,0); neg=std::vector(posSize,0); } -void TLDEnsembleClassifier::integrate(Mat_ patch,bool isPositive){ +void TLDEnsembleClassifier::integrate(const Mat_& patch,bool isPositive){ unsigned short int position=code(patch.data,(int)patch.step[0]); if(isPositive){ pos[position]++; From ee76722c7754270c0d92b91f0307dc1ab640bdea Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Thu, 24 Jul 2014 05:18:38 +0900 Subject: [PATCH 08/26] vadim --- modules/tracking/src/tld_tracker.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index dbf5023a7..8af13091b 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -54,6 +54,7 @@ #define NEG_EXAMPLES_IN_INIT_MODEL 300 #define MAX_EXAMPLES_IN_MODEL 500 #define MEASURES_PER_CLASSIFIER 13 +#define SCALE_STEP 1.2 #define DOWNSCALE_MODE INTER_LINEAR #define BLUR_AS_VADIM #undef CLOSED_LOOP @@ -326,7 +327,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ std::vector::iterator it=std::max_element(candidatesRes.begin(),candidatesRes.end()); - dfprintf((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(SCALE_STEP))); for(int i=0;i<(int)candidatesRes.size();i++){ dprintf(("\tcandidatesRes[%d]=%f\n",i,candidatesRes[i])); } @@ -399,7 +400,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ std::vector closest(10),scanGrid; Mat scaledImg,blurredImg,image_blurred; - double scale=scaleAndBlur(image,cvRound(log(1.0*boundingBox.width/(minSize.width))/log(1.2)),scaledImg,blurredImg,GaussBlurKernelSize); + double scale=scaleAndBlur(image,cvRound(log(1.0*boundingBox.width/(minSize.width))/log(SCALE_STEP)),scaledImg,blurredImg,GaussBlurKernelSize); GaussianBlur(image,image_blurred,GaussBlurKernelSize,0.0); TLDDetector::generateScanGrid(image.rows,image.cols,minSize,scanGrid); getClosestN(scanGrid,Rect2d(boundingBox.x/scale,boundingBox.y/scale,boundingBox.width/scale,boundingBox.height/scale),10,closest); @@ -465,7 +466,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector& res,bool withScaling){ res.clear(); - //scales step: 1.2; hor step: 10% of width; verstep: 10% of height; minsize: 20pix + //scales step: SCALE_STEP; hor step: 10% of width; verstep: 10% of height; minsize: 20pix for(double h=initBox.height, w=initBox.width;hinitBox.height || w>initBox.width); } }else{ - h*=1.2; w*=1.2; + h*=SCALE_STEP; w*=SCALE_STEP; } }else{ break; @@ -544,9 +545,9 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v } } - size.width/=1.2; - size.height/=1.2; - scale*=1.2; + size.width/=SCALE_STEP; + size.height/=SCALE_STEP; + scale*=SCALE_STEP; resize(img,resized_img,size,0,0,DOWNSCALE_MODE); GaussianBlur(resized_img,blurred_img,GaussBlurKernelSize,0.0f); }while(size.width>=initSize.width && size.height>=initSize.height); @@ -711,7 +712,7 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: std::vector closest(10),scanGrid; Mat scaledImg,blurredImg; - double scale=scaleAndBlur(img_,cvRound(log(1.0*resultBox_.width/(initSize_.width))/log(1.2)),scaledImg,blurredImg,GaussBlurKernelSize); + double scale=scaleAndBlur(img_,cvRound(log(1.0*resultBox_.width/(initSize_.width))/log(SCALE_STEP)),scaledImg,blurredImg,GaussBlurKernelSize); 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); @@ -784,8 +785,8 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ double tmp; Mat resized_img,blurred_img; - double scale=1.2; - //double scale=1.2*1.2*1.2*1.2; + double scale=SCALE_STEP; + //double scale=SCALE_STEP*SCALE_STEP*SCALE_STEP*SCALE_STEP; Size2d size(img_.cols/scale,img_.rows/scale); resize(img_,resized_img,size); resize(imgBlurred_,blurred_img,size); From 8c38fa7658c4557ef917283bb72f3cb72612de6c Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 28 Jul 2014 12:56:39 +0300 Subject: [PATCH 09/26] vadim --- modules/tracking/src/tld_tracker.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 8af13091b..03483a2a8 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -78,10 +78,21 @@ using namespace tld; * perfect PN * * vadim: + * ?3. comment each function/method + * 5. empty lines to separate logical... + * 6. comment logical sections + * ?10. all in one class + * 11. group decls logically, order of statements + * 12. not v=vector(n), but assign(n,0) + * -->14. TLDEnsembleClassifier + * 16. loops limits + * 17. inner scope loops + * 18. classify in TLDEnsembleClassifier + * 19. var checker + * 20. NCC using plain loops + * 21. precompute offset + * 22. vec of structs (detect and beyond) * - * blurred in TrackerTLDModel() - * - * warpAffine -- ? */ /* design decisions: From b564f1b698c76fe4f91ac0cbf07e4c09b11f57c3 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Thu, 31 Jul 2014 15:39:24 +0300 Subject: [PATCH 10/26] vadim 14 --- modules/tracking/src/tld_classifier.cpp | 3693 ----------------------- modules/tracking/src/tld_tracker.cpp | 15 +- modules/tracking/src/tld_tracker.hpp | 12 +- modules/tracking/src/tld_utils.cpp | 71 +- 4 files changed, 57 insertions(+), 3734 deletions(-) delete mode 100644 modules/tracking/src/tld_classifier.cpp diff --git a/modules/tracking/src/tld_classifier.cpp b/modules/tracking/src/tld_classifier.cpp deleted file mode 100644 index 0386e954b..000000000 --- a/modules/tracking/src/tld_classifier.cpp +++ /dev/null @@ -1,3693 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// - // - // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. - // - // By downloading, copying, installing or using the software you agree to this license. - // If you do not agree to this license, do not download, install, - // copy or use the software. - // - // - // License Agreement - // For Open Source Computer Vision Library - // - // Copyright (C) 2013, OpenCV Foundation, all rights reserved. - // Third party copyrights are property of their respective owners. - // - // Redistribution and use in source and binary forms, with or without modification, - // are permitted provided that the following conditions are met: - // - // * Redistribution's of source code must retain the above copyright notice, - // this list of conditions and the following disclaimer. - // - // * Redistribution's in binary form must reproduce the above copyright notice, - // this list of conditions and the following disclaimer in the documentation - // and/or other materials provided with the distribution. - // - // * The name of the copyright holders may not be used to endorse or promote products - // derived from this software without specific prior written permission. - // - // This software is provided by the copyright holders and contributors "as is" and - // any express or implied warranties, including, but not limited to, the implied - // warranties of merchantability and fitness for a particular purpose are disclaimed. - // In no event shall the Intel Corporation or contributors be liable for any direct, - // indirect, incidental, special, exemplary, or consequential damages - // (including, but not limited to, procurement of substitute goods or services; - // loss of use, data, or profits; or business interruption) however caused - // and on any theory of liability, whether in contract, strict liability, - // or tort (including negligence or otherwise) arising in any way out of - // the use of this software, even if advised of the possibility of such damage. - // - //M*/ - -#include "precomp.hpp" -#include "opencv2/video/tracking.hpp" -#include "opencv2/imgproc.hpp" -#include -#include -#include "tld_tracker.hpp" - -using namespace cv; - -namespace cv{namespace tld -{ -int TLDEnsembleClassifier::getGridSize(){ - return 15; -} -int TLDEnsembleClassifier::getMaxOrdinal(){ - return 242; -} -void TLDEnsembleClassifier::preinit(int ordinal){ - CV_Assert(ordinal>0 && ordinal<=getMaxOrdinal()); - switch(ordinal){ - case 1: - x1[0]=5; x2[0]=5; y1[0]=12; y2[0]=11; - x1[1]=5; x2[1]=5; y1[1]=12; y2[1]=4; - x1[2]=8; x2[2]=7; y1[2]=3; y2[2]=3; - x1[3]=14; x2[3]=14; y1[3]=13; y2[3]=1; - x1[4]=11; x2[4]=11; y1[4]=10; y2[4]=0; - x1[5]=2; x2[5]=2; y1[5]=7; y2[5]=3; - x1[6]=3; x2[6]=3; y1[6]=9; y2[6]=2; - x1[7]=9; x2[7]=7; y1[7]=13; y2[7]=13; - x1[8]=0; x2[8]=0; y1[8]=13; y2[8]=4; - x1[9]=9; x2[9]=3; y1[9]=11; y2[9]=11; - x1[10]=13; x2[10]=3; y1[10]=5; y2[10]=5; - x1[11]=14; x2[11]=3; y1[11]=4; y2[11]=4; - x1[12]=12; x2[12]=9; y1[12]=1; y2[12]=1; - break; - case 2: - x1[0]=13; x2[0]=11; y1[0]=7; y2[0]=7; - x1[1]=7; x2[1]=6; y1[1]=8; y2[1]=8; - x1[2]=9; x2[2]=8; y1[2]=9; y2[2]=9; - x1[3]=6; x2[3]=6; y1[3]=13; y2[3]=0; - x1[4]=5; x2[4]=5; y1[4]=12; y2[4]=6; - x1[5]=4; x2[5]=0; y1[5]=3; y2[5]=3; - x1[6]=6; x2[6]=1; y1[6]=14; y2[6]=14; - x1[7]=10; x2[7]=7; y1[7]=7; y2[7]=7; - x1[8]=5; x2[8]=2; y1[8]=13; y2[8]=13; - x1[9]=2; x2[9]=2; y1[9]=1; y2[9]=0; - x1[10]=11; x2[10]=11; y1[10]=3; y2[10]=1; - x1[11]=12; x2[11]=1; y1[11]=5; y2[11]=5; - x1[12]=9; x2[12]=9; y1[12]=10; y2[12]=1; - break; - case 3: - x1[0]=14; x2[0]=14; y1[0]=14; y2[0]=9; - x1[1]=3; x2[1]=0; y1[1]=8; y2[1]=8; - x1[2]=11; x2[2]=10; y1[2]=4; y2[2]=4; - x1[3]=14; x2[3]=14; y1[3]=9; y2[3]=3; - x1[4]=13; x2[4]=8; y1[4]=12; y2[4]=12; - x1[5]=4; x2[5]=4; y1[5]=9; y2[5]=0; - x1[6]=11; x2[6]=6; y1[6]=2; y2[6]=2; - x1[7]=12; x2[7]=11; y1[7]=10; y2[7]=10; - x1[8]=14; x2[8]=14; y1[8]=14; y2[8]=0; - x1[9]=0; x2[9]=0; y1[9]=11; y2[9]=2; - x1[10]=3; x2[10]=1; y1[10]=3; y2[10]=3; - x1[11]=3; x2[11]=1; y1[11]=6; y2[11]=6; - x1[12]=11; x2[12]=1; y1[12]=14; y2[12]=14; - break; - case 4: - x1[0]=1; x2[0]=1; y1[0]=8; y2[0]=7; - x1[1]=0; x2[1]=0; y1[1]=8; y2[1]=5; - x1[2]=3; x2[2]=3; y1[2]=7; y2[2]=0; - x1[3]=14; x2[3]=9; y1[3]=14; y2[3]=14; - x1[4]=7; x2[4]=7; y1[4]=12; y2[4]=11; - x1[5]=14; x2[5]=10; y1[5]=8; y2[5]=8; - x1[6]=14; x2[6]=14; y1[6]=14; y2[6]=7; - x1[7]=0; x2[7]=0; y1[7]=10; y2[7]=8; - x1[8]=3; x2[8]=3; y1[8]=13; y2[8]=6; - x1[9]=12; x2[9]=11; y1[9]=7; y2[9]=7; - x1[10]=1; x2[10]=1; y1[10]=8; y2[10]=2; - x1[11]=6; x2[11]=6; y1[11]=3; y2[11]=1; - x1[12]=7; x2[12]=4; y1[12]=6; y2[12]=6; - break; - case 5: - x1[0]=10; x2[0]=10; y1[0]=14; y2[0]=2; - x1[1]=7; x2[1]=7; y1[1]=12; y2[1]=5; - x1[2]=13; x2[2]=12; y1[2]=1; y2[2]=1; - x1[3]=0; x2[3]=0; y1[3]=14; y2[3]=10; - x1[4]=6; x2[4]=6; y1[4]=11; y2[4]=8; - x1[5]=13; x2[5]=12; y1[5]=6; y2[5]=6; - x1[6]=13; x2[6]=2; y1[6]=11; y2[6]=11; - x1[7]=10; x2[7]=2; y1[7]=14; y2[7]=14; - x1[8]=13; x2[8]=10; y1[8]=1; y2[8]=1; - x1[9]=13; x2[9]=11; y1[9]=1; y2[9]=1; - x1[10]=12; x2[10]=4; y1[10]=0; y2[10]=0; - x1[11]=1; x2[11]=1; y1[11]=14; y2[11]=8; - x1[12]=9; x2[12]=9; y1[12]=12; y2[12]=9; - break; - case 6: - x1[0]=3; x2[0]=3; y1[0]=11; y2[0]=0; - x1[1]=9; x2[1]=7; y1[1]=3; y2[1]=3; - x1[2]=6; x2[2]=1; y1[2]=0; y2[2]=0; - x1[3]=7; x2[3]=7; y1[3]=9; y2[3]=2; - x1[4]=8; x2[4]=8; y1[4]=10; y2[4]=2; - x1[5]=5; x2[5]=2; y1[5]=0; y2[5]=0; - x1[6]=12; x2[6]=9; y1[6]=3; y2[6]=3; - x1[7]=3; x2[7]=3; y1[7]=9; y2[7]=4; - x1[8]=13; x2[8]=5; y1[8]=7; y2[8]=7; - x1[9]=12; x2[9]=12; y1[9]=14; y2[9]=3; - x1[10]=2; x2[10]=2; y1[10]=4; y2[10]=1; - x1[11]=2; x2[11]=2; y1[11]=11; y2[11]=6; - x1[12]=2; x2[12]=1; y1[12]=9; y2[12]=9; - break; - case 7: - x1[0]=7; x2[0]=1; y1[0]=1; y2[0]=1; - x1[1]=6; x2[1]=6; y1[1]=7; y2[1]=6; - x1[2]=12; x2[2]=5; y1[2]=5; y2[2]=5; - x1[3]=6; x2[3]=6; y1[3]=4; y2[3]=0; - x1[4]=5; x2[4]=5; y1[4]=13; y2[4]=8; - x1[5]=14; x2[5]=13; y1[5]=12; y2[5]=12; - x1[6]=12; x2[6]=10; y1[6]=13; y2[6]=13; - x1[7]=0; x2[7]=0; y1[7]=7; y2[7]=1; - x1[8]=14; x2[8]=14; y1[8]=11; y2[8]=4; - x1[9]=14; x2[9]=14; y1[9]=6; y2[9]=4; - x1[10]=13; x2[10]=4; y1[10]=10; y2[10]=10; - x1[11]=13; x2[11]=13; y1[11]=5; y2[11]=4; - x1[12]=10; x2[12]=7; y1[12]=10; y2[12]=10; - break; - case 8: - x1[0]=14; x2[0]=7; y1[0]=7; y2[0]=7; - x1[1]=12; x2[1]=12; y1[1]=12; y2[1]=4; - x1[2]=6; x2[2]=1; y1[2]=7; y2[2]=7; - x1[3]=12; x2[3]=11; y1[3]=8; y2[3]=8; - x1[4]=12; x2[4]=1; y1[4]=2; y2[4]=2; - x1[5]=14; x2[5]=11; y1[5]=9; y2[5]=9; - x1[6]=13; x2[6]=11; y1[6]=10; y2[6]=10; - x1[7]=12; x2[7]=12; y1[7]=11; y2[7]=0; - x1[8]=4; x2[8]=4; y1[8]=8; y2[8]=6; - x1[9]=2; x2[9]=2; y1[9]=11; y2[9]=3; - x1[10]=7; x2[10]=4; y1[10]=10; y2[10]=10; - x1[11]=12; x2[11]=2; y1[11]=14; y2[11]=14; - x1[12]=14; x2[12]=0; y1[12]=4; y2[12]=4; - break; - case 9: - x1[0]=9; x2[0]=9; y1[0]=12; y2[0]=11; - x1[1]=14; x2[1]=7; y1[1]=14; y2[1]=14; - x1[2]=9; x2[2]=1; y1[2]=9; y2[2]=9; - x1[3]=8; x2[3]=1; y1[3]=8; y2[3]=8; - x1[4]=3; x2[4]=3; y1[4]=3; y2[4]=1; - x1[5]=5; x2[5]=4; y1[5]=8; y2[5]=8; - x1[6]=9; x2[6]=9; y1[6]=9; y2[6]=8; - x1[7]=0; x2[7]=0; y1[7]=7; y2[7]=3; - x1[8]=8; x2[8]=2; y1[8]=0; y2[8]=0; - x1[9]=2; x2[9]=2; y1[9]=9; y2[9]=7; - x1[10]=0; x2[10]=0; y1[10]=14; y2[10]=4; - x1[11]=8; x2[11]=5; y1[11]=0; y2[11]=0; - x1[12]=5; x2[12]=5; y1[12]=12; y2[12]=9; - break; - case 10: - x1[0]=8; x2[0]=0; y1[0]=3; y2[0]=3; - x1[1]=7; x2[1]=4; y1[1]=11; y2[1]=11; - x1[2]=5; x2[2]=5; y1[2]=7; y2[2]=2; - x1[3]=3; x2[3]=3; y1[3]=8; y2[3]=5; - x1[4]=6; x2[4]=6; y1[4]=9; y2[4]=8; - x1[5]=4; x2[5]=2; y1[5]=7; y2[5]=7; - x1[6]=13; x2[6]=6; y1[6]=3; y2[6]=3; - x1[7]=12; x2[7]=12; y1[7]=11; y2[7]=3; - x1[8]=7; x2[8]=7; y1[8]=12; y2[8]=1; - x1[9]=6; x2[9]=6; y1[9]=14; y2[9]=3; - x1[10]=2; x2[10]=2; y1[10]=14; y2[10]=5; - x1[11]=14; x2[11]=14; y1[11]=7; y2[11]=4; - x1[12]=5; x2[12]=1; y1[12]=12; y2[12]=12; - break; - case 11: - x1[0]=10; x2[0]=10; y1[0]=4; y2[0]=0; - x1[1]=3; x2[1]=3; y1[1]=12; y2[1]=10; - x1[2]=13; x2[2]=8; y1[2]=9; y2[2]=9; - x1[3]=12; x2[3]=12; y1[3]=9; y2[3]=5; - x1[4]=14; x2[4]=14; y1[4]=7; y2[4]=0; - x1[5]=5; x2[5]=5; y1[5]=14; y2[5]=4; - x1[6]=4; x2[6]=4; y1[6]=13; y2[6]=3; - x1[7]=6; x2[7]=6; y1[7]=12; y2[7]=1; - x1[8]=10; x2[8]=10; y1[8]=5; y2[8]=1; - x1[9]=9; x2[9]=9; y1[9]=3; y2[9]=1; - x1[10]=9; x2[10]=4; y1[10]=14; y2[10]=14; - x1[11]=12; x2[11]=3; y1[11]=14; y2[11]=14; - x1[12]=6; x2[12]=2; y1[12]=13; y2[12]=13; - break; - case 12: - x1[0]=12; x2[0]=3; y1[0]=3; y2[0]=3; - x1[1]=12; x2[1]=9; y1[1]=8; y2[1]=8; - x1[2]=2; x2[2]=2; y1[2]=9; y2[2]=1; - x1[3]=4; x2[3]=4; y1[3]=10; y2[3]=9; - x1[4]=12; x2[4]=9; y1[4]=5; y2[4]=5; - x1[5]=14; x2[5]=8; y1[5]=12; y2[5]=12; - x1[6]=9; x2[6]=9; y1[6]=12; y2[6]=7; - x1[7]=11; x2[7]=3; y1[7]=6; y2[7]=6; - x1[8]=8; x2[8]=2; y1[8]=12; y2[8]=12; - x1[9]=10; x2[9]=1; y1[9]=12; y2[9]=12; - x1[10]=2; x2[10]=2; y1[10]=11; y2[10]=1; - x1[11]=11; x2[11]=4; y1[11]=13; y2[11]=13; - x1[12]=13; x2[12]=2; y1[12]=0; y2[12]=0; - break; - case 13: - x1[0]=4; x2[0]=4; y1[0]=14; y2[0]=8; - x1[1]=10; x2[1]=10; y1[1]=11; y2[1]=5; - x1[2]=7; x2[2]=7; y1[2]=8; y2[2]=3; - x1[3]=0; x2[3]=0; y1[3]=9; y2[3]=3; - x1[4]=8; x2[4]=8; y1[4]=9; y2[4]=7; - x1[5]=12; x2[5]=1; y1[5]=0; y2[5]=0; - x1[6]=14; x2[6]=5; y1[6]=8; y2[6]=8; - x1[7]=12; x2[7]=12; y1[7]=13; y2[7]=2; - x1[8]=9; x2[8]=6; y1[8]=6; y2[8]=6; - x1[9]=11; x2[9]=2; y1[9]=3; y2[9]=3; - x1[10]=1; x2[10]=1; y1[10]=8; y2[10]=5; - x1[11]=3; x2[11]=3; y1[11]=12; y2[11]=4; - x1[12]=1; x2[12]=1; y1[12]=14; y2[12]=11; - break; - case 14: - x1[0]=12; x2[0]=7; y1[0]=13; y2[0]=13; - x1[1]=10; x2[1]=10; y1[1]=7; y2[1]=5; - x1[2]=11; x2[2]=2; y1[2]=10; y2[2]=10; - x1[3]=11; x2[3]=11; y1[3]=2; y2[3]=0; - x1[4]=9; x2[4]=9; y1[4]=8; y2[4]=7; - x1[5]=8; x2[5]=8; y1[5]=14; y2[5]=5; - x1[6]=13; x2[6]=13; y1[6]=7; y2[6]=6; - x1[7]=11; x2[7]=11; y1[7]=14; y2[7]=11; - x1[8]=8; x2[8]=8; y1[8]=13; y2[8]=11; - x1[9]=10; x2[9]=10; y1[9]=12; y2[9]=5; - x1[10]=1; x2[10]=1; y1[10]=13; y2[10]=8; - x1[11]=13; x2[11]=13; y1[11]=14; y2[11]=13; - x1[12]=7; x2[12]=6; y1[12]=14; y2[12]=14; - break; - case 15: - x1[0]=1; x2[0]=1; y1[0]=12; y2[0]=2; - x1[1]=12; x2[1]=12; y1[1]=3; y2[1]=1; - x1[2]=10; x2[2]=5; y1[2]=8; y2[2]=8; - x1[3]=9; x2[3]=2; y1[3]=6; y2[3]=6; - x1[4]=11; x2[4]=5; y1[4]=0; y2[4]=0; - x1[5]=10; x2[5]=7; y1[5]=4; y2[5]=4; - x1[6]=4; x2[6]=3; y1[6]=14; y2[6]=14; - x1[7]=1; x2[7]=1; y1[7]=8; y2[7]=3; - x1[8]=8; x2[8]=8; y1[8]=12; y2[8]=2; - x1[9]=7; x2[9]=0; y1[9]=2; y2[9]=2; - x1[10]=1; x2[10]=0; y1[10]=14; y2[10]=14; - x1[11]=11; x2[11]=11; y1[11]=12; y2[11]=6; - x1[12]=9; x2[12]=5; y1[12]=7; y2[12]=7; - break; - case 16: - x1[0]=8; x2[0]=4; y1[0]=10; y2[0]=10; - x1[1]=0; x2[1]=0; y1[1]=8; y2[1]=7; - x1[2]=3; x2[2]=3; y1[2]=9; y2[2]=1; - x1[3]=6; x2[3]=2; y1[3]=3; y2[3]=3; - x1[4]=10; x2[4]=10; y1[4]=8; y2[4]=5; - x1[5]=8; x2[5]=2; y1[5]=4; y2[5]=4; - x1[6]=9; x2[6]=9; y1[6]=14; y2[6]=11; - x1[7]=0; x2[7]=0; y1[7]=8; y2[7]=2; - x1[8]=11; x2[8]=3; y1[8]=13; y2[8]=13; - x1[9]=7; x2[9]=4; y1[9]=13; y2[9]=13; - x1[10]=14; x2[10]=2; y1[10]=3; y2[10]=3; - x1[11]=8; x2[11]=8; y1[11]=13; y2[11]=4; - x1[12]=7; x2[12]=7; y1[12]=7; y2[12]=0; - break; - case 17: - x1[0]=14; x2[0]=8; y1[0]=3; y2[0]=3; - x1[1]=9; x2[1]=9; y1[1]=1; y2[1]=0; - x1[2]=14; x2[2]=14; y1[2]=3; y2[2]=2; - x1[3]=5; x2[3]=5; y1[3]=12; y2[3]=10; - x1[4]=8; x2[4]=8; y1[4]=12; y2[4]=4; - x1[5]=8; x2[5]=6; y1[5]=1; y2[5]=1; - x1[6]=5; x2[6]=5; y1[6]=6; y2[6]=4; - x1[7]=2; x2[7]=2; y1[7]=8; y2[7]=1; - x1[8]=14; x2[8]=5; y1[8]=1; y2[8]=1; - x1[9]=7; x2[9]=1; y1[9]=0; y2[9]=0; - x1[10]=5; x2[10]=5; y1[10]=7; y2[10]=1; - x1[11]=9; x2[11]=9; y1[11]=6; y2[11]=3; - x1[12]=13; x2[12]=0; y1[12]=11; y2[12]=11; - break; - case 18: - x1[0]=12; x2[0]=1; y1[0]=6; y2[0]=6; - x1[1]=4; x2[1]=4; y1[1]=12; y2[1]=8; - x1[2]=9; x2[2]=5; y1[2]=0; y2[2]=0; - x1[3]=8; x2[3]=4; y1[3]=11; y2[3]=11; - x1[4]=13; x2[4]=3; y1[4]=7; y2[4]=7; - x1[5]=10; x2[5]=10; y1[5]=12; y2[5]=4; - x1[6]=13; x2[6]=13; y1[6]=14; y2[6]=6; - x1[7]=0; x2[7]=0; y1[7]=9; y2[7]=2; - x1[8]=2; x2[8]=2; y1[8]=14; y2[8]=2; - x1[9]=7; x2[9]=3; y1[9]=10; y2[9]=10; - x1[10]=9; x2[10]=4; y1[10]=1; y2[10]=1; - x1[11]=10; x2[11]=10; y1[11]=10; y2[11]=2; - x1[12]=4; x2[12]=4; y1[12]=11; y2[12]=3; - break; - case 19: - x1[0]=4; x2[0]=4; y1[0]=5; y2[0]=1; - x1[1]=9; x2[1]=9; y1[1]=13; y2[1]=1; - x1[2]=5; x2[2]=0; y1[2]=3; y2[2]=3; - x1[3]=8; x2[3]=0; y1[3]=2; y2[3]=2; - x1[4]=9; x2[4]=9; y1[4]=8; y2[4]=0; - x1[5]=3; x2[5]=3; y1[5]=12; y2[5]=1; - x1[6]=6; x2[6]=0; y1[6]=2; y2[6]=2; - x1[7]=8; x2[7]=7; y1[7]=14; y2[7]=14; - x1[8]=10; x2[8]=1; y1[8]=14; y2[8]=14; - x1[9]=2; x2[9]=2; y1[9]=7; y2[9]=1; - x1[10]=10; x2[10]=0; y1[10]=2; y2[10]=2; - x1[11]=8; x2[11]=8; y1[11]=6; y2[11]=5; - x1[12]=13; x2[12]=13; y1[12]=11; y2[12]=9; - break; - case 20: - x1[0]=9; x2[0]=0; y1[0]=5; y2[0]=5; - x1[1]=13; x2[1]=12; y1[1]=14; y2[1]=14; - x1[2]=9; x2[2]=9; y1[2]=13; y2[2]=2; - x1[3]=12; x2[3]=8; y1[3]=9; y2[3]=9; - x1[4]=7; x2[4]=6; y1[4]=4; y2[4]=4; - x1[5]=11; x2[5]=9; y1[5]=3; y2[5]=3; - x1[6]=4; x2[6]=2; y1[6]=4; y2[6]=4; - x1[7]=13; x2[7]=7; y1[7]=13; y2[7]=13; - x1[8]=12; x2[8]=11; y1[8]=5; y2[8]=5; - x1[9]=4; x2[9]=1; y1[9]=7; y2[9]=7; - x1[10]=9; x2[10]=7; y1[10]=2; y2[10]=2; - x1[11]=11; x2[11]=11; y1[11]=13; y2[11]=6; - x1[12]=6; x2[12]=6; y1[12]=5; y2[12]=3; - break; - case 21: - x1[0]=14; x2[0]=9; y1[0]=10; y2[0]=10; - x1[1]=8; x2[1]=2; y1[1]=14; y2[1]=14; - x1[2]=14; x2[2]=14; y1[2]=9; y2[2]=1; - x1[3]=8; x2[3]=8; y1[3]=2; y2[3]=0; - x1[4]=10; x2[4]=1; y1[4]=6; y2[4]=6; - x1[5]=7; x2[5]=2; y1[5]=3; y2[5]=3; - x1[6]=12; x2[6]=12; y1[6]=7; y2[6]=4; - x1[7]=12; x2[7]=6; y1[7]=7; y2[7]=7; - x1[8]=8; x2[8]=8; y1[8]=4; y2[8]=0; - x1[9]=9; x2[9]=9; y1[9]=10; y2[9]=6; - x1[10]=6; x2[10]=6; y1[10]=9; y2[10]=1; - x1[11]=10; x2[11]=2; y1[11]=0; y2[11]=0; - x1[12]=1; x2[12]=1; y1[12]=13; y2[12]=2; - break; - case 22: - x1[0]=14; x2[0]=12; y1[0]=4; y2[0]=4; - x1[1]=13; x2[1]=1; y1[1]=14; y2[1]=14; - x1[2]=7; x2[2]=7; y1[2]=10; y2[2]=9; - x1[3]=6; x2[3]=1; y1[3]=12; y2[3]=12; - x1[4]=11; x2[4]=11; y1[4]=13; y2[4]=9; - x1[5]=5; x2[5]=4; y1[5]=1; y2[5]=1; - x1[6]=11; x2[6]=11; y1[6]=11; y2[6]=2; - x1[7]=3; x2[7]=0; y1[7]=5; y2[7]=5; - x1[8]=13; x2[8]=13; y1[8]=13; y2[8]=10; - x1[9]=12; x2[9]=12; y1[9]=14; y2[9]=0; - x1[10]=10; x2[10]=3; y1[10]=4; y2[10]=4; - x1[11]=10; x2[11]=8; y1[11]=1; y2[11]=1; - x1[12]=5; x2[12]=5; y1[12]=11; y2[12]=5; - break; - case 23: - x1[0]=8; x2[0]=8; y1[0]=11; y2[0]=4; - x1[1]=14; x2[1]=14; y1[1]=13; y2[1]=8; - x1[2]=13; x2[2]=13; y1[2]=13; y2[2]=8; - x1[3]=10; x2[3]=8; y1[3]=5; y2[3]=5; - x1[4]=14; x2[4]=14; y1[4]=12; y2[4]=7; - x1[5]=10; x2[5]=8; y1[5]=0; y2[5]=0; - x1[6]=9; x2[6]=2; y1[6]=4; y2[6]=4; - x1[7]=14; x2[7]=14; y1[7]=6; y2[7]=3; - x1[8]=5; x2[8]=5; y1[8]=9; y2[8]=1; - x1[9]=10; x2[9]=4; y1[9]=8; y2[9]=8; - x1[10]=5; x2[10]=5; y1[10]=4; y2[10]=2; - x1[11]=8; x2[11]=2; y1[11]=10; y2[11]=10; - x1[12]=4; x2[12]=4; y1[12]=12; y2[12]=6; - break; - case 24: - x1[0]=14; x2[0]=3; y1[0]=0; y2[0]=0; - x1[1]=6; x2[1]=4; y1[1]=13; y2[1]=13; - x1[2]=11; x2[2]=6; y1[2]=10; y2[2]=10; - x1[3]=2; x2[3]=2; y1[3]=13; y2[3]=10; - x1[4]=9; x2[4]=9; y1[4]=10; y2[4]=4; - x1[5]=6; x2[5]=6; y1[5]=14; y2[5]=6; - x1[6]=13; x2[6]=8; y1[6]=5; y2[6]=5; - x1[7]=0; x2[7]=0; y1[7]=12; y2[7]=10; - x1[8]=13; x2[8]=8; y1[8]=0; y2[8]=0; - x1[9]=9; x2[9]=9; y1[9]=13; y2[9]=7; - x1[10]=14; x2[10]=3; y1[10]=9; y2[10]=9; - x1[11]=6; x2[11]=6; y1[11]=6; y2[11]=5; - x1[12]=10; x2[12]=1; y1[12]=2; y2[12]=2; - break; - case 25: - x1[0]=13; x2[0]=10; y1[0]=14; y2[0]=14; - x1[1]=7; x2[1]=7; y1[1]=13; y2[1]=9; - x1[2]=12; x2[2]=10; y1[2]=10; y2[2]=10; - x1[3]=7; x2[3]=7; y1[3]=8; y2[3]=2; - x1[4]=12; x2[4]=1; y1[4]=7; y2[4]=7; - x1[5]=14; x2[5]=5; y1[5]=12; y2[5]=12; - x1[6]=8; x2[6]=8; y1[6]=9; y2[6]=3; - x1[7]=2; x2[7]=1; y1[7]=11; y2[7]=11; - x1[8]=12; x2[8]=2; y1[8]=9; y2[8]=9; - x1[9]=12; x2[9]=3; y1[9]=0; y2[9]=0; - x1[10]=6; x2[10]=1; y1[10]=2; y2[10]=2; - x1[11]=6; x2[11]=6; y1[11]=8; y2[11]=3; - x1[12]=7; x2[12]=7; y1[12]=8; y2[12]=6; - break; - case 26: - x1[0]=13; x2[0]=13; y1[0]=5; y2[0]=0; - x1[1]=13; x2[1]=10; y1[1]=7; y2[1]=7; - x1[2]=14; x2[2]=14; y1[2]=7; y2[2]=5; - x1[3]=9; x2[3]=9; y1[3]=13; y2[3]=5; - x1[4]=13; x2[4]=7; y1[4]=1; y2[4]=1; - x1[5]=10; x2[5]=8; y1[5]=3; y2[5]=3; - x1[6]=1; x2[6]=1; y1[6]=6; y2[6]=4; - x1[7]=6; x2[7]=6; y1[7]=6; y2[7]=1; - x1[8]=14; x2[8]=14; y1[8]=7; y2[8]=3; - x1[9]=14; x2[9]=10; y1[9]=0; y2[9]=0; - x1[10]=14; x2[10]=9; y1[10]=1; y2[10]=1; - x1[11]=3; x2[11]=3; y1[11]=13; y2[11]=1; - x1[12]=12; x2[12]=5; y1[12]=8; y2[12]=8; - break; - case 27: - x1[0]=10; x2[0]=3; y1[0]=6; y2[0]=6; - x1[1]=10; x2[1]=4; y1[1]=12; y2[1]=12; - x1[2]=13; x2[2]=13; y1[2]=8; y2[2]=6; - x1[3]=14; x2[3]=14; y1[3]=14; y2[3]=13; - x1[4]=13; x2[4]=1; y1[4]=1; y2[4]=1; - x1[5]=10; x2[5]=10; y1[5]=13; y2[5]=4; - x1[6]=13; x2[6]=8; y1[6]=13; y2[6]=13; - x1[7]=5; x2[7]=5; y1[7]=11; y2[7]=0; - x1[8]=14; x2[8]=14; y1[8]=10; y2[8]=8; - x1[9]=9; x2[9]=4; y1[9]=10; y2[9]=10; - x1[10]=13; x2[10]=10; y1[10]=6; y2[10]=6; - x1[11]=9; x2[11]=9; y1[11]=8; y2[11]=4; - x1[12]=5; x2[12]=1; y1[12]=11; y2[12]=11; - break; - case 28: - x1[0]=12; x2[0]=12; y1[0]=12; y2[0]=9; - x1[1]=6; x2[1]=2; y1[1]=11; y2[1]=11; - x1[2]=12; x2[2]=12; y1[2]=6; y2[2]=1; - x1[3]=9; x2[3]=7; y1[3]=14; y2[3]=14; - x1[4]=14; x2[4]=14; y1[4]=11; y2[4]=0; - x1[5]=5; x2[5]=3; y1[5]=13; y2[5]=13; - x1[6]=0; x2[6]=0; y1[6]=6; y2[6]=5; - x1[7]=11; x2[7]=9; y1[7]=14; y2[7]=14; - x1[8]=12; x2[8]=5; y1[8]=14; y2[8]=14; - x1[9]=0; x2[9]=0; y1[9]=4; y2[9]=3; - x1[10]=12; x2[10]=3; y1[10]=13; y2[10]=13; - x1[11]=5; x2[11]=4; y1[11]=6; y2[11]=6; - x1[12]=6; x2[12]=3; y1[12]=8; y2[12]=8; - break; - case 29: - x1[0]=8; x2[0]=7; y1[0]=9; y2[0]=9; - x1[1]=8; x2[1]=8; y1[1]=14; y2[1]=2; - x1[2]=11; x2[2]=11; y1[2]=12; y2[2]=1; - x1[3]=13; x2[3]=5; y1[3]=13; y2[3]=13; - x1[4]=1; x2[4]=1; y1[4]=10; y2[4]=0; - x1[5]=13; x2[5]=12; y1[5]=3; y2[5]=3; - x1[6]=7; x2[6]=7; y1[6]=13; y2[6]=1; - x1[7]=3; x2[7]=3; y1[7]=7; y2[7]=4; - x1[8]=11; x2[8]=3; y1[8]=11; y2[8]=11; - x1[9]=9; x2[9]=8; y1[9]=13; y2[9]=13; - x1[10]=7; x2[10]=7; y1[10]=12; y2[10]=8; - x1[11]=8; x2[11]=8; y1[11]=14; y2[11]=8; - x1[12]=3; x2[12]=1; y1[12]=4; y2[12]=4; - break; - case 30: - x1[0]=2; x2[0]=2; y1[0]=10; y2[0]=4; - x1[1]=11; x2[1]=6; y1[1]=13; y2[1]=13; - x1[2]=12; x2[2]=8; y1[2]=11; y2[2]=11; - x1[3]=14; x2[3]=14; y1[3]=13; y2[3]=11; - x1[4]=6; x2[4]=6; y1[4]=7; y2[4]=4; - x1[5]=7; x2[5]=4; y1[5]=14; y2[5]=14; - x1[6]=9; x2[6]=5; y1[6]=9; y2[6]=9; - x1[7]=6; x2[7]=0; y1[7]=4; y2[7]=4; - x1[8]=1; x2[8]=1; y1[8]=10; y2[8]=5; - x1[9]=9; x2[9]=1; y1[9]=2; y2[9]=2; - x1[10]=13; x2[10]=7; y1[10]=0; y2[10]=0; - x1[11]=8; x2[11]=8; y1[11]=12; y2[11]=10; - x1[12]=8; x2[12]=3; y1[12]=12; y2[12]=12; - break; - case 31: - x1[0]=2; x2[0]=2; y1[0]=13; y2[0]=2; - x1[1]=0; x2[1]=0; y1[1]=4; y2[1]=2; - x1[2]=9; x2[2]=9; y1[2]=6; y2[2]=5; - x1[3]=1; x2[3]=0; y1[3]=11; y2[3]=11; - x1[4]=4; x2[4]=4; y1[4]=7; y2[4]=3; - x1[5]=4; x2[5]=4; y1[5]=7; y2[5]=4; - x1[6]=1; x2[6]=1; y1[6]=7; y2[6]=0; - x1[7]=8; x2[7]=4; y1[7]=4; y2[7]=4; - x1[8]=12; x2[8]=12; y1[8]=10; y2[8]=5; - x1[9]=4; x2[9]=2; y1[9]=12; y2[9]=12; - x1[10]=12; x2[10]=3; y1[10]=8; y2[10]=8; - x1[11]=4; x2[11]=4; y1[11]=14; y2[11]=0; - x1[12]=7; x2[12]=6; y1[12]=0; y2[12]=0; - break; - case 32: - x1[0]=7; x2[0]=7; y1[0]=10; y2[0]=1; - x1[1]=11; x2[1]=5; y1[1]=10; y2[1]=10; - x1[2]=14; x2[2]=7; y1[2]=4; y2[2]=4; - x1[3]=8; x2[3]=8; y1[3]=10; y2[3]=6; - x1[4]=4; x2[4]=4; y1[4]=6; y2[4]=5; - x1[5]=10; x2[5]=10; y1[5]=1; y2[5]=0; - x1[6]=11; x2[6]=2; y1[6]=9; y2[6]=9; - x1[7]=12; x2[7]=12; y1[7]=4; y2[7]=3; - x1[8]=3; x2[8]=2; y1[8]=13; y2[8]=13; - x1[9]=11; x2[9]=11; y1[9]=14; y2[9]=8; - x1[10]=5; x2[10]=1; y1[10]=5; y2[10]=5; - x1[11]=10; x2[11]=10; y1[11]=14; y2[11]=7; - x1[12]=1; x2[12]=1; y1[12]=11; y2[12]=8; - break; - case 33: - x1[0]=11; x2[0]=11; y1[0]=12; y2[0]=5; - x1[1]=6; x2[1]=2; y1[1]=14; y2[1]=14; - x1[2]=9; x2[2]=9; y1[2]=7; y2[2]=2; - x1[3]=2; x2[3]=2; y1[3]=12; y2[3]=1; - x1[4]=11; x2[4]=11; y1[4]=13; y2[4]=5; - x1[5]=11; x2[5]=2; y1[5]=11; y2[5]=11; - x1[6]=3; x2[6]=0; y1[6]=11; y2[6]=11; - x1[7]=7; x2[7]=6; y1[7]=10; y2[7]=10; - x1[8]=5; x2[8]=0; y1[8]=11; y2[8]=11; - x1[9]=5; x2[9]=5; y1[9]=8; y2[9]=5; - x1[10]=13; x2[10]=11; y1[10]=13; y2[10]=13; - x1[11]=0; x2[11]=0; y1[11]=10; y2[11]=3; - x1[12]=5; x2[12]=5; y1[12]=11; y2[12]=10; - break; - case 34: - x1[0]=7; x2[0]=6; y1[0]=6; y2[0]=6; - x1[1]=6; x2[1]=6; y1[1]=13; y2[1]=12; - x1[2]=11; x2[2]=2; y1[2]=2; y2[2]=2; - x1[3]=1; x2[3]=1; y1[3]=9; y2[3]=6; - x1[4]=7; x2[4]=7; y1[4]=11; y2[4]=3; - x1[5]=2; x2[5]=2; y1[5]=12; y2[5]=0; - x1[6]=6; x2[6]=6; y1[6]=7; y2[6]=5; - x1[7]=11; x2[7]=9; y1[7]=6; y2[7]=6; - x1[8]=14; x2[8]=5; y1[8]=10; y2[8]=10; - x1[9]=8; x2[9]=3; y1[9]=2; y2[9]=2; - x1[10]=14; x2[10]=9; y1[10]=6; y2[10]=6; - x1[11]=13; x2[11]=8; y1[11]=6; y2[11]=6; - x1[12]=13; x2[12]=13; y1[12]=1; y2[12]=0; - break; - case 35: - x1[0]=2; x2[0]=2; y1[0]=8; y2[0]=7; - x1[1]=8; x2[1]=8; y1[1]=6; y2[1]=2; - x1[2]=2; x2[2]=2; y1[2]=2; y2[2]=0; - x1[3]=8; x2[3]=0; y1[3]=14; y2[3]=14; - x1[4]=14; x2[4]=14; y1[4]=4; y2[4]=3; - x1[5]=11; x2[5]=2; y1[5]=1; y2[5]=1; - x1[6]=14; x2[6]=9; y1[6]=2; y2[6]=2; - x1[7]=13; x2[7]=13; y1[7]=9; y2[7]=2; - x1[8]=9; x2[8]=8; y1[8]=2; y2[8]=2; - x1[9]=7; x2[9]=3; y1[9]=14; y2[9]=14; - x1[10]=13; x2[10]=13; y1[10]=8; y2[10]=7; - x1[11]=11; x2[11]=11; y1[11]=10; y2[11]=4; - x1[12]=13; x2[12]=12; y1[12]=7; y2[12]=7; - break; - case 36: - x1[0]=8; x2[0]=6; y1[0]=4; y2[0]=4; - x1[1]=12; x2[1]=3; y1[1]=4; y2[1]=4; - x1[2]=5; x2[2]=5; y1[2]=9; y2[2]=8; - x1[3]=3; x2[3]=3; y1[3]=10; y2[3]=2; - x1[4]=11; x2[4]=11; y1[4]=9; y2[4]=5; - x1[5]=9; x2[5]=9; y1[5]=13; y2[5]=0; - x1[6]=4; x2[6]=0; y1[6]=11; y2[6]=11; - x1[7]=9; x2[7]=0; y1[7]=9; y2[7]=9; - x1[8]=7; x2[8]=7; y1[8]=4; y2[8]=3; - x1[9]=7; x2[9]=4; y1[9]=5; y2[9]=5; - x1[10]=12; x2[10]=12; y1[10]=11; y2[10]=8; - x1[11]=9; x2[11]=1; y1[11]=11; y2[11]=11; - x1[12]=8; x2[12]=1; y1[12]=11; y2[12]=11; - break; - case 37: - x1[0]=5; x2[0]=5; y1[0]=9; y2[0]=3; - x1[1]=5; x2[1]=5; y1[1]=8; y2[1]=1; - x1[2]=3; x2[2]=3; y1[2]=13; y2[2]=12; - x1[3]=2; x2[3]=2; y1[3]=7; y2[3]=5; - x1[4]=10; x2[4]=2; y1[4]=1; y2[4]=1; - x1[5]=8; x2[5]=2; y1[5]=1; y2[5]=1; - x1[6]=2; x2[6]=0; y1[6]=11; y2[6]=11; - x1[7]=9; x2[7]=1; y1[7]=7; y2[7]=7; - x1[8]=1; x2[8]=1; y1[8]=6; y2[8]=1; - x1[9]=12; x2[9]=12; y1[9]=2; y2[9]=1; - x1[10]=4; x2[10]=4; y1[10]=2; y2[10]=1; - x1[11]=13; x2[11]=4; y1[11]=4; y2[11]=4; - x1[12]=12; x2[12]=12; y1[12]=12; y2[12]=5; - break; - case 38: - x1[0]=10; x2[0]=3; y1[0]=10; y2[0]=10; - x1[1]=10; x2[1]=3; y1[1]=8; y2[1]=8; - x1[2]=1; x2[2]=1; y1[2]=8; y2[2]=4; - x1[3]=10; x2[3]=10; y1[3]=11; y2[3]=1; - x1[4]=6; x2[4]=6; y1[4]=13; y2[4]=4; - x1[5]=10; x2[5]=10; y1[5]=5; y2[5]=2; - x1[6]=11; x2[6]=5; y1[6]=1; y2[6]=1; - x1[7]=14; x2[7]=13; y1[7]=6; y2[7]=6; - x1[8]=14; x2[8]=14; y1[8]=9; y2[8]=4; - x1[9]=14; x2[9]=1; y1[9]=0; y2[9]=0; - x1[10]=7; x2[10]=7; y1[10]=14; y2[10]=11; - x1[11]=5; x2[11]=3; y1[11]=11; y2[11]=11; - x1[12]=5; x2[12]=5; y1[12]=10; y2[12]=8; - break; - case 39: - x1[0]=8; x2[0]=8; y1[0]=13; y2[0]=1; - x1[1]=14; x2[1]=12; y1[1]=6; y2[1]=6; - x1[2]=0; x2[2]=0; y1[2]=14; y2[2]=11; - x1[3]=6; x2[3]=6; y1[3]=10; y2[3]=3; - x1[4]=14; x2[4]=1; y1[4]=7; y2[4]=7; - x1[5]=6; x2[5]=6; y1[5]=14; y2[5]=1; - x1[6]=10; x2[6]=10; y1[6]=12; y2[6]=3; - x1[7]=14; x2[7]=1; y1[7]=10; y2[7]=10; - x1[8]=10; x2[8]=10; y1[8]=13; y2[8]=10; - x1[9]=6; x2[9]=6; y1[9]=9; y2[9]=4; - x1[10]=14; x2[10]=0; y1[10]=10; y2[10]=10; - x1[11]=14; x2[11]=11; y1[11]=4; y2[11]=4; - x1[12]=11; x2[12]=11; y1[12]=11; y2[12]=8; - break; - case 40: - x1[0]=1; x2[0]=1; y1[0]=10; y2[0]=3; - x1[1]=11; x2[1]=11; y1[1]=10; y2[1]=1; - x1[2]=12; x2[2]=12; y1[2]=8; y2[2]=4; - x1[3]=1; x2[3]=1; y1[3]=10; y2[3]=8; - x1[4]=1; x2[4]=1; y1[4]=7; y2[4]=5; - x1[5]=5; x2[5]=5; y1[5]=5; y2[5]=3; - x1[6]=1; x2[6]=1; y1[6]=13; y2[6]=12; - x1[7]=3; x2[7]=3; y1[7]=5; y2[7]=0; - x1[8]=7; x2[8]=4; y1[8]=7; y2[8]=7; - x1[9]=10; x2[9]=2; y1[9]=5; y2[9]=5; - x1[10]=7; x2[10]=3; y1[10]=4; y2[10]=4; - x1[11]=1; x2[11]=1; y1[11]=4; y2[11]=2; - x1[12]=5; x2[12]=5; y1[12]=1; y2[12]=0; - break; - case 41: - x1[0]=8; x2[0]=7; y1[0]=7; y2[0]=7; - x1[1]=2; x2[1]=0; y1[1]=4; y2[1]=4; - x1[2]=11; x2[2]=4; y1[2]=0; y2[2]=0; - x1[3]=7; x2[3]=2; y1[3]=12; y2[3]=12; - x1[4]=10; x2[4]=10; y1[4]=4; y2[4]=1; - x1[5]=11; x2[5]=8; y1[5]=10; y2[5]=10; - x1[6]=9; x2[6]=9; y1[6]=10; y2[6]=5; - x1[7]=1; x2[7]=1; y1[7]=14; y2[7]=12; - x1[8]=7; x2[8]=3; y1[8]=2; y2[8]=2; - x1[9]=14; x2[9]=14; y1[9]=12; y2[9]=6; - x1[10]=7; x2[10]=7; y1[10]=13; y2[10]=7; - x1[11]=2; x2[11]=0; y1[11]=13; y2[11]=13; - x1[12]=14; x2[12]=6; y1[12]=3; y2[12]=3; - break; - case 42: - x1[0]=5; x2[0]=3; y1[0]=5; y2[0]=5; - x1[1]=5; x2[1]=1; y1[1]=4; y2[1]=4; - x1[2]=4; x2[2]=4; y1[2]=12; y2[2]=1; - x1[3]=13; x2[3]=13; y1[3]=12; y2[3]=0; - x1[4]=9; x2[4]=3; y1[4]=3; y2[4]=3; - x1[5]=10; x2[5]=9; y1[5]=8; y2[5]=8; - x1[6]=10; x2[6]=4; y1[6]=11; y2[6]=11; - x1[7]=7; x2[7]=1; y1[7]=10; y2[7]=10; - x1[8]=9; x2[8]=4; y1[8]=0; y2[8]=0; - x1[9]=7; x2[9]=0; y1[9]=10; y2[9]=10; - x1[10]=5; x2[10]=5; y1[10]=8; y2[10]=3; - x1[11]=6; x2[11]=3; y1[11]=9; y2[11]=9; - x1[12]=8; x2[12]=8; y1[12]=7; y2[12]=1; - break; - case 43: - x1[0]=0; x2[0]=0; y1[0]=13; y2[0]=1; - x1[1]=7; x2[1]=0; y1[1]=1; y2[1]=1; - x1[2]=6; x2[2]=6; y1[2]=9; y2[2]=3; - x1[3]=14; x2[3]=7; y1[3]=12; y2[3]=12; - x1[4]=4; x2[4]=4; y1[4]=13; y2[4]=8; - x1[5]=11; x2[5]=2; y1[5]=5; y2[5]=5; - x1[6]=9; x2[6]=6; y1[6]=7; y2[6]=7; - x1[7]=4; x2[7]=4; y1[7]=14; y2[7]=10; - x1[8]=2; x2[8]=2; y1[8]=6; y2[8]=5; - x1[9]=2; x2[9]=2; y1[9]=4; y2[9]=2; - x1[10]=11; x2[10]=5; y1[10]=7; y2[10]=7; - x1[11]=13; x2[11]=11; y1[11]=11; y2[11]=11; - x1[12]=13; x2[12]=3; y1[12]=13; y2[12]=13; - break; - case 44: - x1[0]=10; x2[0]=0; y1[0]=6; y2[0]=6; - x1[1]=9; x2[1]=5; y1[1]=11; y2[1]=11; - x1[2]=7; x2[2]=0; y1[2]=4; y2[2]=4; - x1[3]=13; x2[3]=0; y1[3]=1; y2[3]=1; - x1[4]=13; x2[4]=13; y1[4]=13; y2[4]=4; - x1[5]=12; x2[5]=12; y1[5]=9; y2[5]=8; - x1[6]=14; x2[6]=4; y1[6]=3; y2[6]=3; - x1[7]=0; x2[7]=0; y1[7]=11; y2[7]=10; - x1[8]=13; x2[8]=13; y1[8]=9; y2[8]=4; - x1[9]=1; x2[9]=0; y1[9]=4; y2[9]=4; - x1[10]=6; x2[10]=3; y1[10]=12; y2[10]=12; - x1[11]=2; x2[11]=2; y1[11]=8; y2[11]=6; - x1[12]=14; x2[12]=0; y1[12]=3; y2[12]=3; - break; - case 45: - x1[0]=3; x2[0]=2; y1[0]=9; y2[0]=9; - x1[1]=7; x2[1]=7; y1[1]=14; y2[1]=1; - x1[2]=5; x2[2]=2; y1[2]=14; y2[2]=14; - x1[3]=13; x2[3]=13; y1[3]=10; y2[3]=8; - x1[4]=7; x2[4]=3; y1[4]=6; y2[4]=6; - x1[5]=14; x2[5]=14; y1[5]=5; y2[5]=2; - x1[6]=5; x2[6]=5; y1[6]=14; y2[6]=10; - x1[7]=13; x2[7]=13; y1[7]=12; y2[7]=8; - x1[8]=2; x2[8]=2; y1[8]=14; y2[8]=7; - x1[9]=14; x2[9]=14; y1[9]=13; y2[9]=3; - x1[10]=9; x2[10]=1; y1[10]=0; y2[10]=0; - x1[11]=9; x2[11]=9; y1[11]=14; y2[11]=2; - x1[12]=4; x2[12]=1; y1[12]=8; y2[12]=8; - break; - case 46: - x1[0]=6; x2[0]=6; y1[0]=8; y2[0]=6; - x1[1]=14; x2[1]=10; y1[1]=10; y2[1]=10; - x1[2]=7; x2[2]=3; y1[2]=7; y2[2]=7; - x1[3]=14; x2[3]=14; y1[3]=9; y2[3]=6; - x1[4]=12; x2[4]=5; y1[4]=0; y2[4]=0; - x1[5]=7; x2[5]=6; y1[5]=13; y2[5]=13; - x1[6]=13; x2[6]=13; y1[6]=6; y2[6]=4; - x1[7]=11; x2[7]=11; y1[7]=13; y2[7]=10; - x1[8]=2; x2[8]=2; y1[8]=12; y2[8]=5; - x1[9]=8; x2[9]=1; y1[9]=6; y2[9]=6; - x1[10]=12; x2[10]=6; y1[10]=11; y2[10]=11; - x1[11]=14; x2[11]=14; y1[11]=12; y2[11]=2; - x1[12]=10; x2[12]=1; y1[12]=0; y2[12]=0; - break; - case 47: - x1[0]=12; x2[0]=12; y1[0]=13; y2[0]=6; - x1[1]=1; x2[1]=1; y1[1]=3; y2[1]=1; - x1[2]=6; x2[2]=6; y1[2]=12; y2[2]=3; - x1[3]=10; x2[3]=9; y1[3]=1; y2[3]=1; - x1[4]=12; x2[4]=10; y1[4]=9; y2[4]=9; - x1[5]=14; x2[5]=14; y1[5]=11; y2[5]=8; - x1[6]=9; x2[6]=2; y1[6]=7; y2[6]=7; - x1[7]=12; x2[7]=12; y1[7]=6; y2[7]=3; - x1[8]=7; x2[8]=6; y1[8]=11; y2[8]=11; - x1[9]=8; x2[9]=8; y1[9]=11; y2[9]=5; - x1[10]=2; x2[10]=2; y1[10]=14; y2[10]=1; - x1[11]=3; x2[11]=3; y1[11]=10; y2[11]=4; - x1[12]=7; x2[12]=7; y1[12]=13; y2[12]=10; - break; - case 48: - x1[0]=13; x2[0]=6; y1[0]=14; y2[0]=14; - x1[1]=12; x2[1]=12; y1[1]=7; y2[1]=1; - x1[2]=6; x2[2]=6; y1[2]=10; y2[2]=5; - x1[3]=4; x2[3]=1; y1[3]=10; y2[3]=10; - x1[4]=2; x2[4]=2; y1[4]=6; y2[4]=1; - x1[5]=5; x2[5]=5; y1[5]=9; y2[5]=7; - x1[6]=10; x2[6]=8; y1[6]=8; y2[6]=8; - x1[7]=13; x2[7]=1; y1[7]=12; y2[7]=12; - x1[8]=7; x2[8]=6; y1[8]=2; y2[8]=2; - x1[9]=9; x2[9]=9; y1[9]=13; y2[9]=12; - x1[10]=10; x2[10]=10; y1[10]=10; y2[10]=5; - x1[11]=12; x2[11]=12; y1[11]=8; y2[11]=2; - x1[12]=9; x2[12]=0; y1[12]=14; y2[12]=14; - break; - case 49: - x1[0]=10; x2[0]=10; y1[0]=14; y2[0]=9; - x1[1]=4; x2[1]=4; y1[1]=14; y2[1]=12; - x1[2]=13; x2[2]=7; y1[2]=14; y2[2]=14; - x1[3]=13; x2[3]=5; y1[3]=14; y2[3]=14; - x1[4]=13; x2[4]=13; y1[4]=14; y2[4]=7; - x1[5]=14; x2[5]=7; y1[5]=5; y2[5]=5; - x1[6]=11; x2[6]=9; y1[6]=13; y2[6]=13; - x1[7]=14; x2[7]=10; y1[7]=9; y2[7]=9; - x1[8]=8; x2[8]=6; y1[8]=8; y2[8]=8; - x1[9]=9; x2[9]=9; y1[9]=12; y2[9]=6; - x1[10]=14; x2[10]=14; y1[10]=11; y2[10]=6; - x1[11]=7; x2[11]=0; y1[11]=3; y2[11]=3; - x1[12]=2; x2[12]=2; y1[12]=5; y2[12]=3; - break; - case 50: - x1[0]=0; x2[0]=0; y1[0]=4; y2[0]=1; - x1[1]=11; x2[1]=2; y1[1]=12; y2[1]=12; - x1[2]=13; x2[2]=0; y1[2]=7; y2[2]=7; - x1[3]=3; x2[3]=3; y1[3]=14; y2[3]=0; - x1[4]=9; x2[4]=6; y1[4]=1; y2[4]=1; - x1[5]=14; x2[5]=14; y1[5]=13; y2[5]=2; - x1[6]=13; x2[6]=4; y1[6]=6; y2[6]=6; - x1[7]=13; x2[7]=5; y1[7]=11; y2[7]=11; - x1[8]=14; x2[8]=12; y1[8]=12; y2[8]=12; - x1[9]=12; x2[9]=12; y1[9]=4; y2[9]=0; - x1[10]=13; x2[10]=8; y1[10]=10; y2[10]=10; - x1[11]=14; x2[11]=4; y1[11]=8; y2[11]=8; - x1[12]=5; x2[12]=1; y1[12]=7; y2[12]=7; - break; - case 51: - x1[0]=12; x2[0]=12; y1[0]=13; y2[0]=10; - x1[1]=12; x2[1]=12; y1[1]=11; y2[1]=6; - x1[2]=12; x2[2]=2; y1[2]=7; y2[2]=7; - x1[3]=10; x2[3]=10; y1[3]=10; y2[3]=6; - x1[4]=7; x2[4]=7; y1[4]=13; y2[4]=0; - x1[5]=13; x2[5]=2; y1[5]=6; y2[5]=6; - x1[6]=1; x2[6]=1; y1[6]=12; y2[6]=9; - x1[7]=12; x2[7]=12; y1[7]=5; y2[7]=3; - x1[8]=14; x2[8]=11; y1[8]=2; y2[8]=2; - x1[9]=6; x2[9]=0; y1[9]=0; y2[9]=0; - x1[10]=9; x2[10]=6; y1[10]=12; y2[10]=12; - x1[11]=10; x2[11]=10; y1[11]=14; y2[11]=3; - x1[12]=9; x2[12]=2; y1[12]=11; y2[12]=11; - break; - case 52: - x1[0]=8; x2[0]=8; y1[0]=13; y2[0]=5; - x1[1]=5; x2[1]=0; y1[1]=4; y2[1]=4; - x1[2]=6; x2[2]=6; y1[2]=14; y2[2]=8; - x1[3]=13; x2[3]=13; y1[3]=14; y2[3]=12; - x1[4]=11; x2[4]=11; y1[4]=14; y2[4]=4; - x1[5]=9; x2[5]=7; y1[5]=10; y2[5]=10; - x1[6]=1; x2[6]=0; y1[6]=6; y2[6]=6; - x1[7]=11; x2[7]=8; y1[7]=2; y2[7]=2; - x1[8]=1; x2[8]=0; y1[8]=2; y2[8]=2; - x1[9]=12; x2[9]=12; y1[9]=11; y2[9]=4; - x1[10]=6; x2[10]=0; y1[10]=13; y2[10]=13; - x1[11]=11; x2[11]=11; y1[11]=9; y2[11]=2; - x1[12]=9; x2[12]=9; y1[12]=12; y2[12]=10; - break; - case 53: - x1[0]=8; x2[0]=1; y1[0]=3; y2[0]=3; - x1[1]=5; x2[1]=0; y1[1]=13; y2[1]=13; - x1[2]=8; x2[2]=8; y1[2]=12; y2[2]=3; - x1[3]=11; x2[3]=11; y1[3]=11; y2[3]=9; - x1[4]=14; x2[4]=4; y1[4]=7; y2[4]=7; - x1[5]=12; x2[5]=9; y1[5]=13; y2[5]=13; - x1[6]=13; x2[6]=0; y1[6]=2; y2[6]=2; - x1[7]=13; x2[7]=5; y1[7]=5; y2[7]=5; - x1[8]=6; x2[8]=6; y1[8]=5; y2[8]=2; - x1[9]=3; x2[9]=3; y1[9]=8; y2[9]=1; - x1[10]=12; x2[10]=2; y1[10]=4; y2[10]=4; - x1[11]=14; x2[11]=1; y1[11]=8; y2[11]=8; - x1[12]=6; x2[12]=3; y1[12]=7; y2[12]=7; - break; - case 54: - x1[0]=11; x2[0]=11; y1[0]=6; y2[0]=0; - x1[1]=4; x2[1]=4; y1[1]=9; y2[1]=6; - x1[2]=2; x2[2]=2; y1[2]=10; y2[2]=0; - x1[3]=11; x2[3]=4; y1[3]=1; y2[3]=1; - x1[4]=4; x2[4]=0; y1[4]=13; y2[4]=13; - x1[5]=12; x2[5]=12; y1[5]=4; y2[5]=1; - x1[6]=11; x2[6]=7; y1[6]=2; y2[6]=2; - x1[7]=5; x2[7]=5; y1[7]=12; y2[7]=7; - x1[8]=5; x2[8]=2; y1[8]=1; y2[8]=1; - x1[9]=0; x2[9]=0; y1[9]=11; y2[9]=5; - x1[10]=2; x2[10]=2; y1[10]=11; y2[10]=10; - x1[11]=12; x2[11]=4; y1[11]=5; y2[11]=5; - x1[12]=2; x2[12]=0; y1[12]=12; y2[12]=12; - break; - case 55: - x1[0]=12; x2[0]=4; y1[0]=12; y2[0]=12; - x1[1]=12; x2[1]=11; y1[1]=9; y2[1]=9; - x1[2]=8; x2[2]=3; y1[2]=13; y2[2]=13; - x1[3]=11; x2[3]=0; y1[3]=12; y2[3]=12; - x1[4]=7; x2[4]=2; y1[4]=4; y2[4]=4; - x1[5]=0; x2[5]=0; y1[5]=11; y2[5]=1; - x1[6]=11; x2[6]=11; y1[6]=4; y2[6]=3; - x1[7]=4; x2[7]=3; y1[7]=13; y2[7]=13; - x1[8]=9; x2[8]=9; y1[8]=14; y2[8]=1; - x1[9]=14; x2[9]=11; y1[9]=0; y2[9]=0; - x1[10]=11; x2[10]=11; y1[10]=5; y2[10]=3; - x1[11]=11; x2[11]=11; y1[11]=10; y2[11]=2; - x1[12]=9; x2[12]=0; y1[12]=11; y2[12]=11; - break; - case 56: - x1[0]=4; x2[0]=4; y1[0]=14; y2[0]=13; - x1[1]=9; x2[1]=9; y1[1]=14; y2[1]=12; - x1[2]=0; x2[2]=0; y1[2]=3; y2[2]=1; - x1[3]=8; x2[3]=4; y1[3]=2; y2[3]=2; - x1[4]=4; x2[4]=2; y1[4]=2; y2[4]=2; - x1[5]=13; x2[5]=11; y1[5]=8; y2[5]=8; - x1[6]=9; x2[6]=9; y1[6]=11; y2[6]=9; - x1[7]=2; x2[7]=2; y1[7]=12; y2[7]=9; - x1[8]=13; x2[8]=13; y1[8]=13; y2[8]=7; - x1[9]=6; x2[9]=6; y1[9]=2; y2[9]=1; - x1[10]=9; x2[10]=0; y1[10]=12; y2[10]=12; - x1[11]=5; x2[11]=5; y1[11]=7; y2[11]=3; - x1[12]=6; x2[12]=6; y1[12]=4; y2[12]=1; - break; - case 57: - x1[0]=0; x2[0]=0; y1[0]=8; y2[0]=3; - x1[1]=8; x2[1]=5; y1[1]=1; y2[1]=1; - x1[2]=13; x2[2]=8; y1[2]=11; y2[2]=11; - x1[3]=8; x2[3]=0; y1[3]=5; y2[3]=5; - x1[4]=10; x2[4]=7; y1[4]=13; y2[4]=13; - x1[5]=6; x2[5]=6; y1[5]=10; y2[5]=7; - x1[6]=11; x2[6]=9; y1[6]=8; y2[6]=8; - x1[7]=3; x2[7]=3; y1[7]=14; y2[7]=4; - x1[8]=9; x2[8]=9; y1[8]=9; y2[8]=7; - x1[9]=9; x2[9]=8; y1[9]=14; y2[9]=14; - x1[10]=6; x2[10]=6; y1[10]=14; y2[10]=2; - x1[11]=9; x2[11]=9; y1[11]=9; y2[11]=2; - x1[12]=4; x2[12]=4; y1[12]=9; y2[12]=8; - break; - case 58: - x1[0]=5; x2[0]=2; y1[0]=8; y2[0]=8; - x1[1]=14; x2[1]=14; y1[1]=13; y2[1]=0; - x1[2]=6; x2[2]=4; y1[2]=14; y2[2]=14; - x1[3]=7; x2[3]=5; y1[3]=9; y2[3]=9; - x1[4]=13; x2[4]=9; y1[4]=5; y2[4]=5; - x1[5]=0; x2[5]=0; y1[5]=12; y2[5]=11; - x1[6]=0; x2[6]=0; y1[6]=9; y2[6]=8; - x1[7]=2; x2[7]=2; y1[7]=10; y2[7]=9; - x1[8]=13; x2[8]=4; y1[8]=9; y2[8]=9; - x1[9]=13; x2[9]=3; y1[9]=0; y2[9]=0; - x1[10]=5; x2[10]=5; y1[10]=11; y2[10]=9; - x1[11]=11; x2[11]=2; y1[11]=8; y2[11]=8; - x1[12]=10; x2[12]=10; y1[12]=5; y2[12]=0; - break; - case 59: - x1[0]=5; x2[0]=5; y1[0]=10; y2[0]=5; - x1[1]=1; x2[1]=1; y1[1]=12; y2[1]=10; - x1[2]=12; x2[2]=12; y1[2]=9; y2[2]=1; - x1[3]=14; x2[3]=13; y1[3]=14; y2[3]=14; - x1[4]=0; x2[4]=0; y1[4]=10; y2[4]=4; - x1[5]=10; x2[5]=0; y1[5]=10; y2[5]=10; - x1[6]=13; x2[6]=12; y1[6]=13; y2[6]=13; - x1[7]=14; x2[7]=6; y1[7]=9; y2[7]=9; - x1[8]=0; x2[8]=0; y1[8]=6; y2[8]=3; - x1[9]=10; x2[9]=9; y1[9]=0; y2[9]=0; - x1[10]=0; x2[10]=0; y1[10]=13; y2[10]=9; - x1[11]=2; x2[11]=2; y1[11]=14; y2[11]=6; - x1[12]=9; x2[12]=7; y1[12]=1; y2[12]=1; - break; - case 60: - x1[0]=12; x2[0]=12; y1[0]=10; y2[0]=7; - x1[1]=9; x2[1]=9; y1[1]=6; y2[1]=0; - x1[2]=12; x2[2]=12; y1[2]=14; y2[2]=2; - x1[3]=8; x2[3]=1; y1[3]=14; y2[3]=14; - x1[4]=6; x2[4]=1; y1[4]=1; y2[4]=1; - x1[5]=11; x2[5]=8; y1[5]=14; y2[5]=14; - x1[6]=9; x2[6]=9; y1[6]=5; y2[6]=2; - x1[7]=14; x2[7]=14; y1[7]=9; y2[7]=7; - x1[8]=5; x2[8]=5; y1[8]=7; y2[8]=4; - x1[9]=2; x2[9]=2; y1[9]=3; y2[9]=0; - x1[10]=4; x2[10]=4; y1[10]=7; y2[10]=6; - x1[11]=11; x2[11]=11; y1[11]=12; y2[11]=7; - x1[12]=3; x2[12]=3; y1[12]=7; y2[12]=3; - break; - case 61: - x1[0]=14; x2[0]=14; y1[0]=9; y2[0]=0; - x1[1]=14; x2[1]=7; y1[1]=13; y2[1]=13; - x1[2]=10; x2[2]=10; y1[2]=9; y2[2]=8; - x1[3]=14; x2[3]=14; y1[3]=6; y2[3]=2; - x1[4]=6; x2[4]=6; y1[4]=8; y2[4]=4; - x1[5]=6; x2[5]=6; y1[5]=11; y2[5]=5; - x1[6]=8; x2[6]=8; y1[6]=12; y2[6]=9; - x1[7]=7; x2[7]=0; y1[7]=13; y2[7]=13; - x1[8]=2; x2[8]=2; y1[8]=5; y2[8]=2; - x1[9]=14; x2[9]=7; y1[9]=10; y2[9]=10; - x1[10]=8; x2[10]=8; y1[10]=8; y2[10]=4; - x1[11]=13; x2[11]=7; y1[11]=5; y2[11]=5; - x1[12]=11; x2[12]=10; y1[12]=13; y2[12]=13; - break; - case 62: - x1[0]=5; x2[0]=5; y1[0]=5; y2[0]=4; - x1[1]=11; x2[1]=0; y1[1]=10; y2[1]=10; - x1[2]=10; x2[2]=3; y1[2]=14; y2[2]=14; - x1[3]=11; x2[3]=3; y1[3]=10; y2[3]=10; - x1[4]=2; x2[4]=0; y1[4]=1; y2[4]=1; - x1[5]=6; x2[5]=6; y1[5]=7; y2[5]=2; - x1[6]=11; x2[6]=8; y1[6]=1; y2[6]=1; - x1[7]=10; x2[7]=10; y1[7]=14; y2[7]=12; - x1[8]=5; x2[8]=5; y1[8]=10; y2[8]=9; - x1[9]=6; x2[9]=2; y1[9]=12; y2[9]=12; - x1[10]=10; x2[10]=0; y1[10]=8; y2[10]=8; - x1[11]=5; x2[11]=1; y1[11]=1; y2[11]=1; - x1[12]=11; x2[12]=1; y1[12]=8; y2[12]=8; - break; - case 63: - x1[0]=12; x2[0]=8; y1[0]=13; y2[0]=13; - x1[1]=12; x2[1]=12; y1[1]=9; y2[1]=4; - x1[2]=4; x2[2]=4; y1[2]=12; y2[2]=2; - x1[3]=7; x2[3]=7; y1[3]=11; y2[3]=6; - x1[4]=10; x2[4]=4; y1[4]=10; y2[4]=10; - x1[5]=0; x2[5]=0; y1[5]=12; y2[5]=4; - x1[6]=9; x2[6]=7; y1[6]=9; y2[6]=9; - x1[7]=3; x2[7]=3; y1[7]=10; y2[7]=7; - x1[8]=9; x2[8]=9; y1[8]=4; y2[8]=2; - x1[9]=5; x2[9]=5; y1[9]=3; y2[9]=1; - x1[10]=10; x2[10]=0; y1[10]=9; y2[10]=9; - x1[11]=5; x2[11]=1; y1[11]=6; y2[11]=6; - x1[12]=9; x2[12]=9; y1[12]=4; y2[12]=3; - break; - case 64: - x1[0]=11; x2[0]=6; y1[0]=14; y2[0]=14; - x1[1]=11; x2[1]=10; y1[1]=7; y2[1]=7; - x1[2]=8; x2[2]=3; y1[2]=6; y2[2]=6; - x1[3]=7; x2[3]=7; y1[3]=11; y2[3]=8; - x1[4]=10; x2[4]=6; y1[4]=4; y2[4]=4; - x1[5]=10; x2[5]=6; y1[5]=11; y2[5]=11; - x1[6]=14; x2[6]=14; y1[6]=14; y2[6]=10; - x1[7]=3; x2[7]=3; y1[7]=8; y2[7]=3; - x1[8]=14; x2[8]=14; y1[8]=11; y2[8]=5; - x1[9]=9; x2[9]=9; y1[9]=7; y2[9]=5; - x1[10]=9; x2[10]=5; y1[10]=8; y2[10]=8; - x1[11]=12; x2[11]=6; y1[11]=1; y2[11]=1; - x1[12]=14; x2[12]=11; y1[12]=8; y2[12]=8; - break; - case 65: - x1[0]=11; x2[0]=5; y1[0]=14; y2[0]=14; - x1[1]=8; x2[1]=6; y1[1]=9; y2[1]=9; - x1[2]=1; x2[2]=1; y1[2]=5; y2[2]=0; - x1[3]=11; x2[3]=11; y1[3]=7; y2[3]=6; - x1[4]=13; x2[4]=13; y1[4]=7; y2[4]=2; - x1[5]=4; x2[5]=4; y1[5]=9; y2[5]=4; - x1[6]=8; x2[6]=7; y1[6]=1; y2[6]=1; - x1[7]=13; x2[7]=11; y1[7]=4; y2[7]=4; - x1[8]=3; x2[8]=3; y1[8]=4; y2[8]=3; - x1[9]=13; x2[9]=13; y1[9]=14; y2[9]=3; - x1[10]=6; x2[10]=2; y1[10]=1; y2[10]=1; - x1[11]=10; x2[11]=10; y1[11]=13; y2[11]=0; - x1[12]=4; x2[12]=1; y1[12]=4; y2[12]=4; - break; - case 66: - x1[0]=1; x2[0]=1; y1[0]=9; y2[0]=2; - x1[1]=11; x2[1]=11; y1[1]=9; y2[1]=1; - x1[2]=10; x2[2]=10; y1[2]=8; y2[2]=1; - x1[3]=13; x2[3]=13; y1[3]=10; y2[3]=2; - x1[4]=9; x2[4]=9; y1[4]=13; y2[4]=6; - x1[5]=14; x2[5]=13; y1[5]=8; y2[5]=8; - x1[6]=13; x2[6]=13; y1[6]=4; y2[6]=3; - x1[7]=6; x2[7]=4; y1[7]=7; y2[7]=7; - x1[8]=13; x2[8]=8; y1[8]=1; y2[8]=1; - x1[9]=13; x2[9]=13; y1[9]=6; y2[9]=0; - x1[10]=7; x2[10]=0; y1[10]=11; y2[10]=11; - x1[11]=6; x2[11]=6; y1[11]=6; y2[11]=3; - x1[12]=8; x2[12]=8; y1[12]=7; y2[12]=6; - break; - case 67: - x1[0]=5; x2[0]=5; y1[0]=13; y2[0]=4; - x1[1]=12; x2[1]=1; y1[1]=11; y2[1]=11; - x1[2]=10; x2[2]=5; y1[2]=10; y2[2]=10; - x1[3]=13; x2[3]=3; y1[3]=12; y2[3]=12; - x1[4]=6; x2[4]=6; y1[4]=13; y2[4]=11; - x1[5]=11; x2[5]=7; y1[5]=6; y2[5]=6; - x1[6]=12; x2[6]=12; y1[6]=8; y2[6]=7; - x1[7]=11; x2[7]=11; y1[7]=5; y2[7]=4; - x1[8]=1; x2[8]=1; y1[8]=13; y2[8]=0; - x1[9]=8; x2[9]=8; y1[9]=10; y2[9]=9; - x1[10]=2; x2[10]=2; y1[10]=9; y2[10]=3; - x1[11]=5; x2[11]=1; y1[11]=14; y2[11]=14; - x1[12]=4; x2[12]=2; y1[12]=10; y2[12]=10; - break; - case 68: - x1[0]=8; x2[0]=8; y1[0]=14; y2[0]=1; - x1[1]=8; x2[1]=8; y1[1]=5; y2[1]=1; - x1[2]=1; x2[2]=1; y1[2]=11; y2[2]=6; - x1[3]=4; x2[3]=0; y1[3]=9; y2[3]=9; - x1[4]=10; x2[4]=10; y1[4]=10; y2[4]=3; - x1[5]=13; x2[5]=3; y1[5]=1; y2[5]=1; - x1[6]=13; x2[6]=13; y1[6]=14; y2[6]=10; - x1[7]=13; x2[7]=13; y1[7]=4; y2[7]=1; - x1[8]=7; x2[8]=3; y1[8]=1; y2[8]=1; - x1[9]=6; x2[9]=1; y1[9]=8; y2[9]=8; - x1[10]=0; x2[10]=0; y1[10]=5; y2[10]=4; - x1[11]=1; x2[11]=1; y1[11]=11; y2[11]=4; - x1[12]=12; x2[12]=9; y1[12]=0; y2[12]=0; - break; - case 69: - x1[0]=0; x2[0]=0; y1[0]=14; y2[0]=1; - x1[1]=8; x2[1]=1; y1[1]=2; y2[1]=2; - x1[2]=13; x2[2]=5; y1[2]=9; y2[2]=9; - x1[3]=4; x2[3]=4; y1[3]=14; y2[3]=9; - x1[4]=5; x2[4]=0; y1[4]=0; y2[4]=0; - x1[5]=14; x2[5]=8; y1[5]=1; y2[5]=1; - x1[6]=1; x2[6]=1; y1[6]=13; y2[6]=3; - x1[7]=6; x2[7]=6; y1[7]=4; y2[7]=2; - x1[8]=3; x2[8]=1; y1[8]=2; y2[8]=2; - x1[9]=6; x2[9]=1; y1[9]=3; y2[9]=3; - x1[10]=11; x2[10]=3; y1[10]=5; y2[10]=5; - x1[11]=9; x2[11]=0; y1[11]=8; y2[11]=8; - x1[12]=13; x2[12]=11; y1[12]=6; y2[12]=6; - break; - case 70: - x1[0]=11; x2[0]=0; y1[0]=2; y2[0]=2; - x1[1]=6; x2[1]=6; y1[1]=9; y2[1]=7; - x1[2]=2; x2[2]=2; y1[2]=5; y2[2]=1; - x1[3]=12; x2[3]=12; y1[3]=13; y2[3]=8; - x1[4]=2; x2[4]=2; y1[4]=9; y2[4]=4; - x1[5]=14; x2[5]=9; y1[5]=4; y2[5]=4; - x1[6]=9; x2[6]=9; y1[6]=4; y2[6]=1; - x1[7]=4; x2[7]=3; y1[7]=5; y2[7]=5; - x1[8]=10; x2[8]=5; y1[8]=3; y2[8]=3; - x1[9]=1; x2[9]=1; y1[9]=13; y2[9]=10; - x1[10]=12; x2[10]=3; y1[10]=12; y2[10]=12; - x1[11]=11; x2[11]=1; y1[11]=4; y2[11]=4; - x1[12]=5; x2[12]=3; y1[12]=3; y2[12]=3; - break; - case 71: - x1[0]=12; x2[0]=8; y1[0]=0; y2[0]=0; - x1[1]=10; x2[1]=7; y1[1]=3; y2[1]=3; - x1[2]=3; x2[2]=0; y1[2]=2; y2[2]=2; - x1[3]=12; x2[3]=12; y1[3]=12; y2[3]=10; - x1[4]=11; x2[4]=0; y1[4]=7; y2[4]=7; - x1[5]=12; x2[5]=12; y1[5]=3; y2[5]=0; - x1[6]=13; x2[6]=13; y1[6]=9; y2[6]=5; - x1[7]=10; x2[7]=9; y1[7]=6; y2[7]=6; - x1[8]=4; x2[8]=2; y1[8]=14; y2[8]=14; - x1[9]=11; x2[9]=11; y1[9]=6; y2[9]=4; - x1[10]=7; x2[10]=7; y1[10]=9; y2[10]=3; - x1[11]=7; x2[11]=7; y1[11]=10; y2[11]=8; - x1[12]=13; x2[12]=0; y1[12]=6; y2[12]=6; - break; - case 72: - x1[0]=10; x2[0]=3; y1[0]=5; y2[0]=5; - x1[1]=10; x2[1]=1; y1[1]=8; y2[1]=8; - x1[2]=12; x2[2]=10; y1[2]=7; y2[2]=7; - x1[3]=1; x2[3]=1; y1[3]=12; y2[3]=4; - x1[4]=4; x2[4]=4; y1[4]=9; y2[4]=2; - x1[5]=10; x2[5]=5; y1[5]=14; y2[5]=14; - x1[6]=14; x2[6]=2; y1[6]=13; y2[6]=13; - x1[7]=1; x2[7]=1; y1[7]=11; y2[7]=10; - x1[8]=13; x2[8]=13; y1[8]=9; y2[8]=1; - x1[9]=13; x2[9]=8; y1[9]=3; y2[9]=3; - x1[10]=11; x2[10]=7; y1[10]=9; y2[10]=9; - x1[11]=12; x2[11]=4; y1[11]=3; y2[11]=3; - x1[12]=4; x2[12]=0; y1[12]=2; y2[12]=2; - break; - case 73: - x1[0]=4; x2[0]=0; y1[0]=12; y2[0]=12; - x1[1]=2; x2[1]=1; y1[1]=10; y2[1]=10; - x1[2]=9; x2[2]=8; y1[2]=3; y2[2]=3; - x1[3]=13; x2[3]=13; y1[3]=12; y2[3]=11; - x1[4]=9; x2[4]=5; y1[4]=2; y2[4]=2; - x1[5]=3; x2[5]=3; y1[5]=2; y2[5]=1; - x1[6]=0; x2[6]=0; y1[6]=12; y2[6]=2; - x1[7]=14; x2[7]=5; y1[7]=14; y2[7]=14; - x1[8]=2; x2[8]=2; y1[8]=14; y2[8]=8; - x1[9]=12; x2[9]=12; y1[9]=10; y2[9]=6; - x1[10]=10; x2[10]=10; y1[10]=8; y2[10]=4; - x1[11]=12; x2[11]=12; y1[11]=11; y2[11]=1; - x1[12]=2; x2[12]=2; y1[12]=14; y2[12]=9; - break; - case 74: - x1[0]=9; x2[0]=9; y1[0]=11; y2[0]=2; - x1[1]=8; x2[1]=8; y1[1]=14; y2[1]=13; - x1[2]=7; x2[2]=7; y1[2]=11; y2[2]=10; - x1[3]=9; x2[3]=9; y1[3]=11; y2[3]=7; - x1[4]=14; x2[4]=10; y1[4]=3; y2[4]=3; - x1[5]=9; x2[5]=6; y1[5]=9; y2[5]=9; - x1[6]=10; x2[6]=10; y1[6]=9; y2[6]=4; - x1[7]=3; x2[7]=1; y1[7]=1; y2[7]=1; - x1[8]=13; x2[8]=12; y1[8]=2; y2[8]=2; - x1[9]=8; x2[9]=8; y1[9]=10; y2[9]=3; - x1[10]=9; x2[10]=9; y1[10]=2; y2[10]=0; - x1[11]=8; x2[11]=5; y1[11]=12; y2[11]=12; - x1[12]=11; x2[12]=11; y1[12]=14; y2[12]=0; - break; - case 75: - x1[0]=12; x2[0]=12; y1[0]=11; y2[0]=2; - x1[1]=4; x2[1]=4; y1[1]=8; y2[1]=3; - x1[2]=7; x2[2]=2; y1[2]=14; y2[2]=14; - x1[3]=14; x2[3]=4; y1[3]=4; y2[3]=4; - x1[4]=7; x2[4]=7; y1[4]=5; y2[4]=1; - x1[5]=14; x2[5]=6; y1[5]=10; y2[5]=10; - x1[6]=13; x2[6]=9; y1[6]=0; y2[6]=0; - x1[7]=5; x2[7]=5; y1[7]=11; y2[7]=4; - x1[8]=10; x2[8]=1; y1[8]=10; y2[8]=10; - x1[9]=0; x2[9]=0; y1[9]=10; y2[9]=7; - x1[10]=5; x2[10]=4; y1[10]=7; y2[10]=7; - x1[11]=14; x2[11]=4; y1[11]=14; y2[11]=14; - x1[12]=9; x2[12]=0; y1[12]=2; y2[12]=2; - break; - case 76: - x1[0]=14; x2[0]=4; y1[0]=6; y2[0]=6; - x1[1]=14; x2[1]=3; y1[1]=3; y2[1]=3; - x1[2]=13; x2[2]=7; y1[2]=2; y2[2]=2; - x1[3]=2; x2[3]=0; y1[3]=10; y2[3]=10; - x1[4]=4; x2[4]=4; y1[4]=13; y2[4]=4; - x1[5]=9; x2[5]=3; y1[5]=1; y2[5]=1; - x1[6]=11; x2[6]=11; y1[6]=13; y2[6]=4; - x1[7]=13; x2[7]=13; y1[7]=8; y2[7]=1; - x1[8]=1; x2[8]=0; y1[8]=1; y2[8]=1; - x1[9]=8; x2[9]=3; y1[9]=14; y2[9]=14; - x1[10]=12; x2[10]=12; y1[10]=6; y2[10]=0; - x1[11]=11; x2[11]=11; y1[11]=10; y2[11]=5; - x1[12]=7; x2[12]=6; y1[12]=9; y2[12]=9; - break; - case 77: - x1[0]=3; x2[0]=3; y1[0]=12; y2[0]=6; - x1[1]=0; x2[1]=0; y1[1]=7; y2[1]=6; - x1[2]=3; x2[2]=0; y1[2]=9; y2[2]=9; - x1[3]=14; x2[3]=3; y1[3]=1; y2[3]=1; - x1[4]=9; x2[4]=0; y1[4]=1; y2[4]=1; - x1[5]=1; x2[5]=1; y1[5]=14; y2[5]=6; - x1[6]=13; x2[6]=6; y1[6]=7; y2[6]=7; - x1[7]=12; x2[7]=7; y1[7]=0; y2[7]=0; - x1[8]=14; x2[8]=4; y1[8]=2; y2[8]=2; - x1[9]=3; x2[9]=3; y1[9]=13; y2[9]=7; - x1[10]=7; x2[10]=7; y1[10]=10; y2[10]=6; - x1[11]=4; x2[11]=4; y1[11]=13; y2[11]=2; - x1[12]=13; x2[12]=13; y1[12]=10; y2[12]=1; - break; - case 78: - x1[0]=13; x2[0]=13; y1[0]=13; y2[0]=12; - x1[1]=1; x2[1]=1; y1[1]=13; y2[1]=1; - x1[2]=0; x2[2]=0; y1[2]=5; y2[2]=3; - x1[3]=14; x2[3]=14; y1[3]=13; y2[3]=10; - x1[4]=14; x2[4]=14; y1[4]=10; y2[4]=2; - x1[5]=7; x2[5]=2; y1[5]=1; y2[5]=1; - x1[6]=2; x2[6]=2; y1[6]=13; y2[6]=4; - x1[7]=14; x2[7]=9; y1[7]=11; y2[7]=11; - x1[8]=5; x2[8]=3; y1[8]=4; y2[8]=4; - x1[9]=12; x2[9]=6; y1[9]=9; y2[9]=9; - x1[10]=4; x2[10]=4; y1[10]=10; y2[10]=1; - x1[11]=11; x2[11]=3; y1[11]=4; y2[11]=4; - x1[12]=1; x2[12]=1; y1[12]=8; y2[12]=1; - break; - case 79: - x1[0]=5; x2[0]=5; y1[0]=11; y2[0]=6; - x1[1]=2; x2[1]=2; y1[1]=10; y2[1]=5; - x1[2]=13; x2[2]=0; y1[2]=10; y2[2]=10; - x1[3]=10; x2[3]=8; y1[3]=7; y2[3]=7; - x1[4]=11; x2[4]=11; y1[4]=7; y2[4]=2; - x1[5]=11; x2[5]=1; y1[5]=0; y2[5]=0; - x1[6]=10; x2[6]=5; y1[6]=0; y2[6]=0; - x1[7]=10; x2[7]=10; y1[7]=14; y2[7]=13; - x1[8]=5; x2[8]=5; y1[8]=4; y2[8]=3; - x1[9]=3; x2[9]=3; y1[9]=5; y2[9]=2; - x1[10]=12; x2[10]=8; y1[10]=2; y2[10]=2; - x1[11]=5; x2[11]=5; y1[11]=13; y2[11]=12; - x1[12]=2; x2[12]=2; y1[12]=8; y2[12]=2; - break; - case 80: - x1[0]=12; x2[0]=12; y1[0]=6; y2[0]=4; - x1[1]=7; x2[1]=2; y1[1]=9; y2[1]=9; - x1[2]=7; x2[2]=7; y1[2]=3; y2[2]=2; - x1[3]=7; x2[3]=2; y1[3]=2; y2[3]=2; - x1[4]=10; x2[4]=10; y1[4]=11; y2[4]=9; - x1[5]=4; x2[5]=3; y1[5]=11; y2[5]=11; - x1[6]=1; x2[6]=1; y1[6]=7; y2[6]=4; - x1[7]=4; x2[7]=4; y1[7]=14; y2[7]=3; - x1[8]=9; x2[8]=6; y1[8]=14; y2[8]=14; - x1[9]=9; x2[9]=9; y1[9]=3; y2[9]=0; - x1[10]=14; x2[10]=14; y1[10]=1; y2[10]=0; - x1[11]=11; x2[11]=10; y1[11]=12; y2[11]=12; - x1[12]=13; x2[12]=12; y1[12]=12; y2[12]=12; - break; - case 81: - x1[0]=8; x2[0]=8; y1[0]=8; y2[0]=0; - x1[1]=6; x2[1]=5; y1[1]=9; y2[1]=9; - x1[2]=13; x2[2]=5; y1[2]=12; y2[2]=12; - x1[3]=12; x2[3]=12; y1[3]=10; y2[3]=3; - x1[4]=13; x2[4]=13; y1[4]=13; y2[4]=1; - x1[5]=9; x2[5]=2; y1[5]=0; y2[5]=0; - x1[6]=12; x2[6]=12; y1[6]=14; y2[6]=9; - x1[7]=14; x2[7]=14; y1[7]=8; y2[7]=4; - x1[8]=10; x2[8]=2; y1[8]=7; y2[8]=7; - x1[9]=13; x2[9]=11; y1[9]=3; y2[9]=3; - x1[10]=9; x2[10]=3; y1[10]=12; y2[10]=12; - x1[11]=6; x2[11]=0; y1[11]=6; y2[11]=6; - x1[12]=8; x2[12]=7; y1[12]=12; y2[12]=12; - break; - case 82: - x1[0]=14; x2[0]=14; y1[0]=12; y2[0]=8; - x1[1]=3; x2[1]=2; y1[1]=12; y2[1]=12; - x1[2]=9; x2[2]=7; y1[2]=7; y2[2]=7; - x1[3]=9; x2[3]=2; y1[3]=3; y2[3]=3; - x1[4]=6; x2[4]=6; y1[4]=11; y2[4]=10; - x1[5]=11; x2[5]=11; y1[5]=13; y2[5]=2; - x1[6]=2; x2[6]=2; y1[6]=12; y2[6]=4; - x1[7]=14; x2[7]=0; y1[7]=8; y2[7]=8; - x1[8]=5; x2[8]=5; y1[8]=9; y2[8]=5; - x1[9]=6; x2[9]=5; y1[9]=3; y2[9]=3; - x1[10]=9; x2[10]=9; y1[10]=9; y2[10]=0; - x1[11]=5; x2[11]=1; y1[11]=9; y2[11]=9; - x1[12]=8; x2[12]=8; y1[12]=14; y2[12]=3; - break; - case 83: - x1[0]=10; x2[0]=10; y1[0]=14; y2[0]=6; - x1[1]=10; x2[1]=1; y1[1]=3; y2[1]=3; - x1[2]=10; x2[2]=10; y1[2]=13; y2[2]=2; - x1[3]=13; x2[3]=1; y1[3]=10; y2[3]=10; - x1[4]=1; x2[4]=1; y1[4]=14; y2[4]=5; - x1[5]=8; x2[5]=0; y1[5]=8; y2[5]=8; - x1[6]=12; x2[6]=7; y1[6]=1; y2[6]=1; - x1[7]=4; x2[7]=4; y1[7]=12; y2[7]=7; - x1[8]=10; x2[8]=9; y1[8]=2; y2[8]=2; - x1[9]=11; x2[9]=5; y1[9]=13; y2[9]=13; - x1[10]=0; x2[10]=0; y1[10]=6; y2[10]=0; - x1[11]=2; x2[11]=2; y1[11]=9; y2[11]=6; - x1[12]=3; x2[12]=3; y1[12]=4; y2[12]=1; - break; - case 84: - x1[0]=4; x2[0]=4; y1[0]=13; y2[0]=6; - x1[1]=10; x2[1]=10; y1[1]=7; y2[1]=3; - x1[2]=14; x2[2]=2; y1[2]=4; y2[2]=4; - x1[3]=10; x2[3]=0; y1[3]=1; y2[3]=1; - x1[4]=9; x2[4]=8; y1[4]=4; y2[4]=4; - x1[5]=5; x2[5]=2; y1[5]=2; y2[5]=2; - x1[6]=10; x2[6]=9; y1[6]=14; y2[6]=14; - x1[7]=11; x2[7]=11; y1[7]=2; y2[7]=1; - x1[8]=6; x2[8]=6; y1[8]=11; y2[8]=3; - x1[9]=13; x2[9]=3; y1[9]=9; y2[9]=9; - x1[10]=10; x2[10]=0; y1[10]=4; y2[10]=4; - x1[11]=9; x2[11]=5; y1[11]=12; y2[11]=12; - x1[12]=3; x2[12]=1; y1[12]=9; y2[12]=9; - break; - case 85: - x1[0]=8; x2[0]=8; y1[0]=12; y2[0]=7; - x1[1]=10; x2[1]=4; y1[1]=13; y2[1]=13; - x1[2]=14; x2[2]=1; y1[2]=13; y2[2]=13; - x1[3]=9; x2[3]=7; y1[3]=11; y2[3]=11; - x1[4]=5; x2[4]=5; y1[4]=14; y2[4]=9; - x1[5]=5; x2[5]=5; y1[5]=10; y2[5]=7; - x1[6]=7; x2[6]=5; y1[6]=4; y2[6]=4; - x1[7]=8; x2[7]=1; y1[7]=12; y2[7]=12; - x1[8]=11; x2[8]=4; y1[8]=10; y2[8]=10; - x1[9]=5; x2[9]=3; y1[9]=9; y2[9]=9; - x1[10]=11; x2[10]=4; y1[10]=4; y2[10]=4; - x1[11]=11; x2[11]=11; y1[11]=10; y2[11]=9; - x1[12]=14; x2[12]=6; y1[12]=0; y2[12]=0; - break; - case 86: - x1[0]=9; x2[0]=9; y1[0]=5; y2[0]=1; - x1[1]=6; x2[1]=0; y1[1]=3; y2[1]=3; - x1[2]=2; x2[2]=2; y1[2]=2; y2[2]=1; - x1[3]=0; x2[3]=0; y1[3]=9; y2[3]=0; - x1[4]=10; x2[4]=6; y1[4]=2; y2[4]=2; - x1[5]=8; x2[5]=2; y1[5]=8; y2[5]=8; - x1[6]=8; x2[6]=8; y1[6]=13; y2[6]=3; - x1[7]=11; x2[7]=1; y1[7]=7; y2[7]=7; - x1[8]=12; x2[8]=4; y1[8]=1; y2[8]=1; - x1[9]=14; x2[9]=14; y1[9]=11; y2[9]=10; - x1[10]=6; x2[10]=6; y1[10]=13; y2[10]=7; - x1[11]=14; x2[11]=14; y1[11]=6; y2[11]=5; - x1[12]=11; x2[12]=5; y1[12]=5; y2[12]=5; - break; - case 87: - x1[0]=2; x2[0]=1; y1[0]=8; y2[0]=8; - x1[1]=14; x2[1]=14; y1[1]=13; y2[1]=9; - x1[2]=4; x2[2]=4; y1[2]=13; y2[2]=9; - x1[3]=11; x2[3]=11; y1[3]=8; y2[3]=0; - x1[4]=11; x2[4]=7; y1[4]=13; y2[4]=13; - x1[5]=11; x2[5]=8; y1[5]=3; y2[5]=3; - x1[6]=8; x2[6]=2; y1[6]=13; y2[6]=13; - x1[7]=12; x2[7]=0; y1[7]=13; y2[7]=13; - x1[8]=9; x2[8]=3; y1[8]=14; y2[8]=14; - x1[9]=13; x2[9]=7; y1[9]=11; y2[9]=11; - x1[10]=0; x2[10]=0; y1[10]=12; y2[10]=5; - x1[11]=12; x2[11]=3; y1[11]=5; y2[11]=5; - x1[12]=4; x2[12]=2; y1[12]=9; y2[12]=9; - break; - case 88: - x1[0]=14; x2[0]=2; y1[0]=11; y2[0]=11; - x1[1]=12; x2[1]=10; y1[1]=12; y2[1]=12; - x1[2]=14; x2[2]=7; y1[2]=3; y2[2]=3; - x1[3]=14; x2[3]=14; y1[3]=13; y2[3]=4; - x1[4]=0; x2[4]=0; y1[4]=6; y2[4]=4; - x1[5]=10; x2[5]=2; y1[5]=4; y2[5]=4; - x1[6]=0; x2[6]=0; y1[6]=10; y2[6]=9; - x1[7]=9; x2[7]=4; y1[7]=3; y2[7]=3; - x1[8]=11; x2[8]=2; y1[8]=13; y2[8]=13; - x1[9]=13; x2[9]=1; y1[9]=2; y2[9]=2; - x1[10]=10; x2[10]=6; y1[10]=5; y2[10]=5; - x1[11]=14; x2[11]=10; y1[11]=4; y2[11]=4; - x1[12]=1; x2[12]=1; y1[12]=12; y2[12]=6; - break; - case 89: - x1[0]=4; x2[0]=2; y1[0]=8; y2[0]=8; - x1[1]=6; x2[1]=4; y1[1]=8; y2[1]=8; - x1[2]=12; x2[2]=12; y1[2]=6; y2[2]=2; - x1[3]=4; x2[3]=4; y1[3]=9; y2[3]=3; - x1[4]=12; x2[4]=0; y1[4]=0; y2[4]=0; - x1[5]=9; x2[5]=3; y1[5]=6; y2[5]=6; - x1[6]=11; x2[6]=0; y1[6]=3; y2[6]=3; - x1[7]=2; x2[7]=2; y1[7]=13; y2[7]=7; - x1[8]=12; x2[8]=5; y1[8]=13; y2[8]=13; - x1[9]=13; x2[9]=13; y1[9]=12; y2[9]=3; - x1[10]=2; x2[10]=2; y1[10]=12; y2[10]=11; - x1[11]=4; x2[11]=4; y1[11]=12; y2[11]=5; - x1[12]=6; x2[12]=6; y1[12]=2; y2[12]=0; - break; - case 90: - x1[0]=8; x2[0]=5; y1[0]=9; y2[0]=9; - x1[1]=13; x2[1]=10; y1[1]=10; y2[1]=10; - x1[2]=4; x2[2]=4; y1[2]=7; y2[2]=2; - x1[3]=12; x2[3]=7; y1[3]=14; y2[3]=14; - x1[4]=3; x2[4]=3; y1[4]=12; y2[4]=7; - x1[5]=10; x2[5]=2; y1[5]=12; y2[5]=12; - x1[6]=13; x2[6]=5; y1[6]=2; y2[6]=2; - x1[7]=14; x2[7]=10; y1[7]=7; y2[7]=7; - x1[8]=10; x2[8]=8; y1[8]=14; y2[8]=14; - x1[9]=10; x2[9]=7; y1[9]=12; y2[9]=12; - x1[10]=12; x2[10]=6; y1[10]=4; y2[10]=4; - x1[11]=12; x2[11]=5; y1[11]=12; y2[11]=12; - x1[12]=11; x2[12]=11; y1[12]=14; y2[12]=13; - break; - case 91: - x1[0]=9; x2[0]=2; y1[0]=2; y2[0]=2; - x1[1]=3; x2[1]=3; y1[1]=9; y2[1]=7; - x1[2]=12; x2[2]=11; y1[2]=0; y2[2]=0; - x1[3]=14; x2[3]=4; y1[3]=5; y2[3]=5; - x1[4]=2; x2[4]=2; y1[4]=11; y2[4]=0; - x1[5]=0; x2[5]=0; y1[5]=13; y2[5]=10; - x1[6]=14; x2[6]=10; y1[6]=2; y2[6]=2; - x1[7]=10; x2[7]=10; y1[7]=8; y2[7]=2; - x1[8]=3; x2[8]=3; y1[8]=5; y2[8]=4; - x1[9]=5; x2[9]=2; y1[9]=4; y2[9]=4; - x1[10]=14; x2[10]=14; y1[10]=10; y2[10]=7; - x1[11]=13; x2[11]=10; y1[11]=9; y2[11]=9; - x1[12]=14; x2[12]=1; y1[12]=11; y2[12]=11; - break; - case 92: - x1[0]=10; x2[0]=1; y1[0]=11; y2[0]=11; - x1[1]=9; x2[1]=6; y1[1]=4; y2[1]=4; - x1[2]=9; x2[2]=9; y1[2]=7; y2[2]=4; - x1[3]=13; x2[3]=12; y1[3]=11; y2[3]=11; - x1[4]=9; x2[4]=9; y1[4]=11; y2[4]=4; - x1[5]=14; x2[5]=4; y1[5]=1; y2[5]=1; - x1[6]=9; x2[6]=3; y1[6]=10; y2[6]=10; - x1[7]=5; x2[7]=0; y1[7]=6; y2[7]=6; - x1[8]=2; x2[8]=2; y1[8]=12; y2[8]=8; - x1[9]=10; x2[9]=10; y1[9]=6; y2[9]=5; - x1[10]=10; x2[10]=1; y1[10]=4; y2[10]=4; - x1[11]=12; x2[11]=0; y1[11]=10; y2[11]=10; - x1[12]=4; x2[12]=4; y1[12]=9; y2[12]=7; - break; - case 93: - x1[0]=10; x2[0]=10; y1[0]=10; y2[0]=8; - x1[1]=12; x2[1]=8; y1[1]=10; y2[1]=10; - x1[2]=8; x2[2]=1; y1[2]=10; y2[2]=10; - x1[3]=14; x2[3]=8; y1[3]=6; y2[3]=6; - x1[4]=2; x2[4]=2; y1[4]=8; y2[4]=4; - x1[5]=9; x2[5]=9; y1[5]=10; y2[5]=8; - x1[6]=13; x2[6]=3; y1[6]=4; y2[6]=4; - x1[7]=9; x2[7]=8; y1[7]=5; y2[7]=5; - x1[8]=0; x2[8]=0; y1[8]=11; y2[8]=0; - x1[9]=9; x2[9]=4; y1[9]=13; y2[9]=13; - x1[10]=1; x2[10]=1; y1[10]=9; y2[10]=5; - x1[11]=9; x2[11]=6; y1[11]=3; y2[11]=3; - x1[12]=0; x2[12]=0; y1[12]=14; y2[12]=0; - break; - case 94: - x1[0]=5; x2[0]=5; y1[0]=5; y2[0]=0; - x1[1]=9; x2[1]=9; y1[1]=10; y2[1]=9; - x1[2]=4; x2[2]=4; y1[2]=12; y2[2]=11; - x1[3]=10; x2[3]=4; y1[3]=1; y2[3]=1; - x1[4]=13; x2[4]=4; y1[4]=3; y2[4]=3; - x1[5]=9; x2[5]=9; y1[5]=8; y2[5]=6; - x1[6]=13; x2[6]=13; y1[6]=13; y2[6]=0; - x1[7]=0; x2[7]=0; y1[7]=7; y2[7]=4; - x1[8]=4; x2[8]=1; y1[8]=6; y2[8]=6; - x1[9]=8; x2[9]=3; y1[9]=5; y2[9]=5; - x1[10]=11; x2[10]=6; y1[10]=11; y2[10]=11; - x1[11]=10; x2[11]=10; y1[11]=12; y2[11]=8; - x1[12]=10; x2[12]=4; y1[12]=9; y2[12]=9; - break; - case 95: - x1[0]=12; x2[0]=12; y1[0]=7; y2[0]=2; - x1[1]=12; x2[1]=8; y1[1]=5; y2[1]=5; - x1[2]=9; x2[2]=8; y1[2]=10; y2[2]=10; - x1[3]=3; x2[3]=3; y1[3]=7; y2[3]=5; - x1[4]=5; x2[4]=5; y1[4]=12; y2[4]=3; - x1[5]=14; x2[5]=11; y1[5]=5; y2[5]=5; - x1[6]=0; x2[6]=0; y1[6]=6; y2[6]=2; - x1[7]=5; x2[7]=5; y1[7]=6; y2[7]=5; - x1[8]=11; x2[8]=11; y1[8]=14; y2[8]=6; - x1[9]=10; x2[9]=7; y1[9]=6; y2[9]=6; - x1[10]=14; x2[10]=14; y1[10]=14; y2[10]=3; - x1[11]=4; x2[11]=3; y1[11]=8; y2[11]=8; - x1[12]=1; x2[12]=1; y1[12]=5; y2[12]=1; - break; - case 96: - x1[0]=9; x2[0]=9; y1[0]=8; y2[0]=5; - x1[1]=2; x2[1]=2; y1[1]=14; y2[1]=3; - x1[2]=14; x2[2]=5; y1[2]=11; y2[2]=11; - x1[3]=11; x2[3]=7; y1[3]=7; y2[3]=7; - x1[4]=14; x2[4]=12; y1[4]=7; y2[4]=7; - x1[5]=5; x2[5]=5; y1[5]=13; y2[5]=5; - x1[6]=8; x2[6]=1; y1[6]=4; y2[6]=4; - x1[7]=3; x2[7]=0; y1[7]=14; y2[7]=14; - x1[8]=8; x2[8]=8; y1[8]=14; y2[8]=7; - x1[9]=9; x2[9]=1; y1[9]=3; y2[9]=3; - x1[10]=4; x2[10]=4; y1[10]=8; y2[10]=4; - x1[11]=5; x2[11]=5; y1[11]=6; y2[11]=0; - x1[12]=11; x2[12]=11; y1[12]=3; y2[12]=0; - break; - case 97: - x1[0]=12; x2[0]=6; y1[0]=6; y2[0]=6; - x1[1]=10; x2[1]=6; y1[1]=13; y2[1]=13; - x1[2]=11; x2[2]=8; y1[2]=5; y2[2]=5; - x1[3]=0; x2[3]=0; y1[3]=9; y2[3]=1; - x1[4]=13; x2[4]=1; y1[4]=6; y2[4]=6; - x1[5]=8; x2[5]=0; y1[5]=12; y2[5]=12; - x1[6]=1; x2[6]=1; y1[6]=6; y2[6]=3; - x1[7]=1; x2[7]=1; y1[7]=3; y2[7]=0; - x1[8]=7; x2[8]=4; y1[8]=12; y2[8]=12; - x1[9]=11; x2[9]=6; y1[9]=1; y2[9]=1; - x1[10]=10; x2[10]=7; y1[10]=1; y2[10]=1; - x1[11]=8; x2[11]=5; y1[11]=6; y2[11]=6; - x1[12]=5; x2[12]=3; y1[12]=6; y2[12]=6; - break; - case 98: - x1[0]=1; x2[0]=1; y1[0]=7; y2[0]=1; - x1[1]=9; x2[1]=9; y1[1]=14; y2[1]=5; - x1[2]=9; x2[2]=9; y1[2]=11; y2[2]=6; - x1[3]=11; x2[3]=11; y1[3]=4; y2[3]=0; - x1[4]=0; x2[4]=0; y1[4]=11; y2[4]=8; - x1[5]=12; x2[5]=8; y1[5]=3; y2[5]=3; - x1[6]=11; x2[6]=7; y1[6]=11; y2[6]=11; - x1[7]=7; x2[7]=0; y1[7]=8; y2[7]=8; - x1[8]=12; x2[8]=12; y1[8]=3; y2[8]=2; - x1[9]=10; x2[9]=4; y1[9]=14; y2[9]=14; - x1[10]=6; x2[10]=6; y1[10]=8; y2[10]=0; - x1[11]=6; x2[11]=6; y1[11]=14; y2[11]=12; - x1[12]=11; x2[12]=9; y1[12]=9; y2[12]=9; - break; - case 99: - x1[0]=8; x2[0]=5; y1[0]=14; y2[0]=14; - x1[1]=13; x2[1]=6; y1[1]=1; y2[1]=1; - x1[2]=8; x2[2]=0; y1[2]=13; y2[2]=13; - x1[3]=5; x2[3]=5; y1[3]=2; y2[3]=0; - x1[4]=9; x2[4]=1; y1[4]=14; y2[4]=14; - x1[5]=12; x2[5]=12; y1[5]=11; y2[5]=10; - x1[6]=7; x2[6]=3; y1[6]=0; y2[6]=0; - x1[7]=8; x2[7]=8; y1[7]=5; y2[7]=4; - x1[8]=10; x2[8]=5; y1[8]=9; y2[8]=9; - x1[9]=14; x2[9]=6; y1[9]=14; y2[9]=14; - x1[10]=9; x2[10]=9; y1[10]=11; y2[10]=8; - x1[11]=8; x2[11]=5; y1[11]=13; y2[11]=13; - x1[12]=12; x2[12]=5; y1[12]=1; y2[12]=1; - break; - case 100: - x1[0]=5; x2[0]=5; y1[0]=14; y2[0]=12; - x1[1]=8; x2[1]=8; y1[1]=14; y2[1]=12; - x1[2]=8; x2[2]=8; y1[2]=13; y2[2]=8; - x1[3]=11; x2[3]=2; y1[3]=7; y2[3]=7; - x1[4]=5; x2[4]=2; y1[4]=6; y2[4]=6; - x1[5]=14; x2[5]=14; y1[5]=5; y2[5]=4; - x1[6]=7; x2[6]=7; y1[6]=10; y2[6]=2; - x1[7]=5; x2[7]=2; y1[7]=7; y2[7]=7; - x1[8]=14; x2[8]=11; y1[8]=13; y2[8]=13; - x1[9]=1; x2[9]=1; y1[9]=13; y2[9]=9; - x1[10]=10; x2[10]=10; y1[10]=13; y2[10]=5; - x1[11]=7; x2[11]=1; y1[11]=13; y2[11]=13; - x1[12]=6; x2[12]=3; y1[12]=13; y2[12]=13; - break; - case 101: - x1[0]=4; x2[0]=1; y1[0]=0; y2[0]=0; - x1[1]=6; x2[1]=0; y1[1]=14; y2[1]=14; - x1[2]=13; x2[2]=4; y1[2]=8; y2[2]=8; - x1[3]=5; x2[3]=4; y1[3]=11; y2[3]=11; - x1[4]=2; x2[4]=1; y1[4]=14; y2[4]=14; - x1[5]=4; x2[5]=1; y1[5]=11; y2[5]=11; - x1[6]=12; x2[6]=12; y1[6]=7; y2[6]=0; - x1[7]=7; x2[7]=7; y1[7]=10; y2[7]=3; - x1[8]=4; x2[8]=4; y1[8]=4; y2[8]=3; - x1[9]=2; x2[9]=2; y1[9]=14; y2[9]=13; - x1[10]=0; x2[10]=0; y1[10]=9; y2[10]=7; - x1[11]=12; x2[11]=3; y1[11]=6; y2[11]=6; - x1[12]=2; x2[12]=2; y1[12]=11; y2[12]=2; - break; - case 102: - x1[0]=13; x2[0]=9; y1[0]=1; y2[0]=1; - x1[1]=6; x2[1]=6; y1[1]=13; y2[1]=2; - x1[2]=11; x2[2]=11; y1[2]=13; y2[2]=11; - x1[3]=11; x2[3]=11; y1[3]=12; y2[3]=11; - x1[4]=6; x2[4]=6; y1[4]=12; y2[4]=6; - x1[5]=12; x2[5]=6; y1[5]=3; y2[5]=3; - x1[6]=12; x2[6]=12; y1[6]=7; y2[6]=5; - x1[7]=7; x2[7]=7; y1[7]=9; y2[7]=5; - x1[8]=7; x2[8]=1; y1[8]=6; y2[8]=6; - x1[9]=9; x2[9]=9; y1[9]=14; y2[9]=3; - x1[10]=3; x2[10]=3; y1[10]=11; y2[10]=7; - x1[11]=5; x2[11]=2; y1[11]=9; y2[11]=9; - x1[12]=14; x2[12]=6; y1[12]=11; y2[12]=11; - break; - case 103: - x1[0]=11; x2[0]=4; y1[0]=12; y2[0]=12; - x1[1]=7; x2[1]=5; y1[1]=11; y2[1]=11; - x1[2]=1; x2[2]=1; y1[2]=9; y2[2]=3; - x1[3]=10; x2[3]=9; y1[3]=4; y2[3]=4; - x1[4]=6; x2[4]=2; y1[4]=9; y2[4]=9; - x1[5]=3; x2[5]=3; y1[5]=14; y2[5]=8; - x1[6]=10; x2[6]=10; y1[6]=12; y2[6]=2; - x1[7]=10; x2[7]=8; y1[7]=4; y2[7]=4; - x1[8]=4; x2[8]=4; y1[8]=4; y2[8]=2; - x1[9]=8; x2[9]=8; y1[9]=9; y2[9]=5; - x1[10]=5; x2[10]=0; y1[10]=14; y2[10]=14; - x1[11]=11; x2[11]=7; y1[11]=1; y2[11]=1; - x1[12]=6; x2[12]=6; y1[12]=14; y2[12]=0; - break; - case 104: - x1[0]=8; x2[0]=4; y1[0]=1; y2[0]=1; - x1[1]=5; x2[1]=2; y1[1]=3; y2[1]=3; - x1[2]=7; x2[2]=7; y1[2]=10; y2[2]=4; - x1[3]=4; x2[3]=4; y1[3]=1; y2[3]=0; - x1[4]=6; x2[4]=5; y1[4]=13; y2[4]=13; - x1[5]=12; x2[5]=5; y1[5]=3; y2[5]=3; - x1[6]=13; x2[6]=13; y1[6]=10; y2[6]=4; - x1[7]=14; x2[7]=14; y1[7]=8; y2[7]=2; - x1[8]=1; x2[8]=1; y1[8]=9; y2[8]=8; - x1[9]=2; x2[9]=2; y1[9]=11; y2[9]=7; - x1[10]=1; x2[10]=1; y1[10]=2; y2[10]=1; - x1[11]=2; x2[11]=2; y1[11]=14; y2[11]=10; - x1[12]=3; x2[12]=3; y1[12]=8; y2[12]=4; - break; - case 105: - x1[0]=13; x2[0]=10; y1[0]=0; y2[0]=0; - x1[1]=7; x2[1]=5; y1[1]=2; y2[1]=2; - x1[2]=14; x2[2]=8; y1[2]=8; y2[2]=8; - x1[3]=10; x2[3]=10; y1[3]=3; y2[3]=1; - x1[4]=7; x2[4]=7; y1[4]=6; y2[4]=3; - x1[5]=10; x2[5]=7; y1[5]=8; y2[5]=8; - x1[6]=8; x2[6]=8; y1[6]=5; y2[6]=0; - x1[7]=8; x2[7]=5; y1[7]=10; y2[7]=10; - x1[8]=10; x2[8]=4; y1[8]=6; y2[8]=6; - x1[9]=12; x2[9]=7; y1[9]=9; y2[9]=9; - x1[10]=11; x2[10]=0; y1[10]=13; y2[10]=13; - x1[11]=2; x2[11]=2; y1[11]=13; y2[11]=0; - x1[12]=4; x2[12]=3; y1[12]=12; y2[12]=12; - break; - case 106: - x1[0]=4; x2[0]=1; y1[0]=5; y2[0]=5; - x1[1]=12; x2[1]=1; y1[1]=9; y2[1]=9; - x1[2]=12; x2[2]=12; y1[2]=6; y2[2]=5; - x1[3]=8; x2[3]=8; y1[3]=9; y2[3]=6; - x1[4]=8; x2[4]=1; y1[4]=5; y2[4]=5; - x1[5]=13; x2[5]=13; y1[5]=8; y2[5]=0; - x1[6]=4; x2[6]=4; y1[6]=12; y2[6]=10; - x1[7]=3; x2[7]=3; y1[7]=12; y2[7]=2; - x1[8]=8; x2[8]=8; y1[8]=13; y2[8]=0; - x1[9]=11; x2[9]=10; y1[9]=6; y2[9]=6; - x1[10]=13; x2[10]=12; y1[10]=8; y2[10]=8; - x1[11]=3; x2[11]=3; y1[11]=12; y2[11]=0; - x1[12]=6; x2[12]=6; y1[12]=5; y2[12]=1; - break; - case 107: - x1[0]=8; x2[0]=8; y1[0]=7; y2[0]=3; - x1[1]=9; x2[1]=0; y1[1]=0; y2[1]=0; - x1[2]=8; x2[2]=6; y1[2]=7; y2[2]=7; - x1[3]=9; x2[3]=0; y1[3]=3; y2[3]=3; - x1[4]=7; x2[4]=7; y1[4]=6; y2[4]=4; - x1[5]=11; x2[5]=5; y1[5]=8; y2[5]=8; - x1[6]=10; x2[6]=4; y1[6]=3; y2[6]=3; - x1[7]=2; x2[7]=2; y1[7]=10; y2[7]=1; - x1[8]=10; x2[8]=4; y1[8]=7; y2[8]=7; - x1[9]=6; x2[9]=2; y1[9]=10; y2[9]=10; - x1[10]=10; x2[10]=10; y1[10]=14; y2[10]=0; - x1[11]=3; x2[11]=3; y1[11]=13; y2[11]=2; - x1[12]=9; x2[12]=7; y1[12]=8; y2[12]=8; - break; - case 108: - x1[0]=13; x2[0]=13; y1[0]=5; y2[0]=1; - x1[1]=13; x2[1]=7; y1[1]=6; y2[1]=6; - x1[2]=14; x2[2]=12; y1[2]=9; y2[2]=9; - x1[3]=3; x2[3]=3; y1[3]=13; y2[3]=11; - x1[4]=14; x2[4]=14; y1[4]=10; y2[4]=9; - x1[5]=9; x2[5]=5; y1[5]=4; y2[5]=4; - x1[6]=12; x2[6]=1; y1[6]=12; y2[6]=12; - x1[7]=14; x2[7]=14; y1[7]=10; y2[7]=6; - x1[8]=7; x2[8]=7; y1[8]=13; y2[8]=6; - x1[9]=0; x2[9]=0; y1[9]=13; y2[9]=5; - x1[10]=10; x2[10]=10; y1[10]=9; y2[10]=1; - x1[11]=12; x2[11]=1; y1[11]=3; y2[11]=3; - x1[12]=5; x2[12]=5; y1[12]=9; y2[12]=0; - break; - case 109: - x1[0]=1; x2[0]=1; y1[0]=2; y2[0]=0; - x1[1]=6; x2[1]=1; y1[1]=10; y2[1]=10; - x1[2]=9; x2[2]=9; y1[2]=9; y2[2]=1; - x1[3]=0; x2[3]=0; y1[3]=13; y2[3]=12; - x1[4]=0; x2[4]=0; y1[4]=12; y2[4]=8; - x1[5]=12; x2[5]=9; y1[5]=7; y2[5]=7; - x1[6]=13; x2[6]=0; y1[6]=14; y2[6]=14; - x1[7]=4; x2[7]=4; y1[7]=5; y2[7]=2; - x1[8]=9; x2[8]=9; y1[8]=9; y2[8]=3; - x1[9]=11; x2[9]=7; y1[9]=5; y2[9]=5; - x1[10]=10; x2[10]=0; y1[10]=11; y2[10]=11; - x1[11]=12; x2[11]=12; y1[11]=4; y2[11]=2; - x1[12]=13; x2[12]=13; y1[12]=3; y2[12]=2; - break; - case 110: - x1[0]=8; x2[0]=8; y1[0]=13; y2[0]=6; - x1[1]=2; x2[1]=2; y1[1]=3; y2[1]=1; - x1[2]=13; x2[2]=10; y1[2]=8; y2[2]=8; - x1[3]=9; x2[3]=2; y1[3]=1; y2[3]=1; - x1[4]=7; x2[4]=6; y1[4]=12; y2[4]=12; - x1[5]=6; x2[5]=1; y1[5]=5; y2[5]=5; - x1[6]=0; x2[6]=0; y1[6]=10; y2[6]=2; - x1[7]=12; x2[7]=0; y1[7]=7; y2[7]=7; - x1[8]=11; x2[8]=0; y1[8]=11; y2[8]=11; - x1[9]=13; x2[9]=1; y1[9]=11; y2[9]=11; - x1[10]=13; x2[10]=13; y1[10]=7; y2[10]=0; - x1[11]=0; x2[11]=0; y1[11]=14; y2[11]=8; - x1[12]=4; x2[12]=4; y1[12]=4; y2[12]=0; - break; - case 111: - x1[0]=4; x2[0]=2; y1[0]=13; y2[0]=13; - x1[1]=6; x2[1]=0; y1[1]=11; y2[1]=11; - x1[2]=14; x2[2]=7; y1[2]=11; y2[2]=11; - x1[3]=3; x2[3]=3; y1[3]=11; y2[3]=2; - x1[4]=3; x2[4]=0; y1[4]=3; y2[4]=3; - x1[5]=13; x2[5]=1; y1[5]=13; y2[5]=13; - x1[6]=5; x2[6]=0; y1[6]=9; y2[6]=9; - x1[7]=9; x2[7]=2; y1[7]=10; y2[7]=10; - x1[8]=13; x2[8]=13; y1[8]=11; y2[8]=5; - x1[9]=7; x2[9]=2; y1[9]=6; y2[9]=6; - x1[10]=0; x2[10]=0; y1[10]=13; y2[10]=3; - x1[11]=10; x2[11]=7; y1[11]=0; y2[11]=0; - x1[12]=1; x2[12]=1; y1[12]=14; y2[12]=1; - break; - case 112: - x1[0]=7; x2[0]=7; y1[0]=12; y2[0]=7; - x1[1]=7; x2[1]=7; y1[1]=14; y2[1]=2; - x1[2]=4; x2[2]=4; y1[2]=14; y2[2]=5; - x1[3]=5; x2[3]=5; y1[3]=9; y2[3]=2; - x1[4]=2; x2[4]=2; y1[4]=11; y2[4]=9; - x1[5]=4; x2[5]=4; y1[5]=14; y2[5]=2; - x1[6]=9; x2[6]=8; y1[6]=12; y2[6]=12; - x1[7]=12; x2[7]=5; y1[7]=6; y2[7]=6; - x1[8]=13; x2[8]=9; y1[8]=14; y2[8]=14; - x1[9]=2; x2[9]=1; y1[9]=6; y2[9]=6; - x1[10]=4; x2[10]=4; y1[10]=14; y2[10]=11; - x1[11]=14; x2[11]=14; y1[11]=6; y2[11]=0; - x1[12]=13; x2[12]=13; y1[12]=11; y2[12]=6; - break; - case 113: - x1[0]=10; x2[0]=0; y1[0]=7; y2[0]=7; - x1[1]=7; x2[1]=5; y1[1]=7; y2[1]=7; - x1[2]=13; x2[2]=5; y1[2]=4; y2[2]=4; - x1[3]=5; x2[3]=5; y1[3]=14; y2[3]=11; - x1[4]=8; x2[4]=0; y1[4]=0; y2[4]=0; - x1[5]=11; x2[5]=11; y1[5]=7; y2[5]=1; - x1[6]=4; x2[6]=4; y1[6]=5; y2[6]=3; - x1[7]=3; x2[7]=3; y1[7]=12; y2[7]=9; - x1[8]=4; x2[8]=1; y1[8]=9; y2[8]=9; - x1[9]=14; x2[9]=0; y1[9]=7; y2[9]=7; - x1[10]=12; x2[10]=9; y1[10]=2; y2[10]=2; - x1[11]=13; x2[11]=10; y1[11]=2; y2[11]=2; - x1[12]=1; x2[12]=0; y1[12]=5; y2[12]=5; - break; - case 114: - x1[0]=3; x2[0]=3; y1[0]=2; y2[0]=0; - x1[1]=4; x2[1]=4; y1[1]=11; y2[1]=4; - x1[2]=7; x2[2]=3; y1[2]=11; y2[2]=11; - x1[3]=4; x2[3]=4; y1[3]=13; y2[3]=12; - x1[4]=10; x2[4]=10; y1[4]=14; y2[4]=8; - x1[5]=3; x2[5]=2; y1[5]=6; y2[5]=6; - x1[6]=5; x2[6]=5; y1[6]=12; y2[6]=8; - x1[7]=8; x2[7]=3; y1[7]=3; y2[7]=3; - x1[8]=13; x2[8]=5; y1[8]=1; y2[8]=1; - x1[9]=14; x2[9]=3; y1[9]=13; y2[9]=13; - x1[10]=11; x2[10]=11; y1[10]=5; y2[10]=0; - x1[11]=8; x2[11]=8; y1[11]=11; y2[11]=7; - x1[12]=7; x2[12]=7; y1[12]=7; y2[12]=6; - break; - case 115: - x1[0]=11; x2[0]=11; y1[0]=11; y2[0]=4; - x1[1]=7; x2[1]=7; y1[1]=14; y2[1]=0; - x1[2]=14; x2[2]=10; y1[2]=12; y2[2]=12; - x1[3]=13; x2[3]=13; y1[3]=10; y2[3]=3; - x1[4]=6; x2[4]=6; y1[4]=13; y2[4]=1; - x1[5]=13; x2[5]=13; y1[5]=13; y2[5]=11; - x1[6]=12; x2[6]=11; y1[6]=12; y2[6]=12; - x1[7]=10; x2[7]=10; y1[7]=8; y2[7]=3; - x1[8]=3; x2[8]=1; y1[8]=13; y2[8]=13; - x1[9]=8; x2[9]=3; y1[9]=9; y2[9]=9; - x1[10]=13; x2[10]=12; y1[10]=10; y2[10]=10; - x1[11]=14; x2[11]=14; y1[11]=12; y2[11]=9; - x1[12]=10; x2[12]=8; y1[12]=13; y2[12]=13; - break; - case 116: - x1[0]=8; x2[0]=8; y1[0]=14; y2[0]=0; - x1[1]=7; x2[1]=7; y1[1]=4; y2[1]=0; - x1[2]=12; x2[2]=8; y1[2]=1; y2[2]=1; - x1[3]=12; x2[3]=10; y1[3]=1; y2[3]=1; - x1[4]=13; x2[4]=4; y1[4]=14; y2[4]=14; - x1[5]=6; x2[5]=4; y1[5]=11; y2[5]=11; - x1[6]=13; x2[6]=10; y1[6]=3; y2[6]=3; - x1[7]=5; x2[7]=5; y1[7]=3; y2[7]=2; - x1[8]=14; x2[8]=6; y1[8]=7; y2[8]=7; - x1[9]=7; x2[9]=7; y1[9]=8; y2[9]=1; - x1[10]=8; x2[10]=1; y1[10]=9; y2[10]=9; - x1[11]=13; x2[11]=13; y1[11]=8; y2[11]=4; - x1[12]=9; x2[12]=6; y1[12]=8; y2[12]=8; - break; - case 117: - x1[0]=11; x2[0]=11; y1[0]=10; y2[0]=6; - x1[1]=12; x2[1]=12; y1[1]=12; y2[1]=8; - x1[2]=4; x2[2]=4; y1[2]=10; y2[2]=4; - x1[3]=7; x2[3]=0; y1[3]=6; y2[3]=6; - x1[4]=7; x2[4]=1; y1[4]=2; y2[4]=2; - x1[5]=3; x2[5]=3; y1[5]=9; y2[5]=5; - x1[6]=12; x2[6]=12; y1[6]=8; y2[6]=5; - x1[7]=13; x2[7]=13; y1[7]=9; y2[7]=3; - x1[8]=5; x2[8]=5; y1[8]=13; y2[8]=0; - x1[9]=11; x2[9]=7; y1[9]=4; y2[9]=4; - x1[10]=7; x2[10]=3; y1[10]=12; y2[10]=12; - x1[11]=14; x2[11]=14; y1[11]=11; y2[11]=9; - x1[12]=2; x2[12]=2; y1[12]=13; y2[12]=12; - break; - case 118: - x1[0]=3; x2[0]=3; y1[0]=12; y2[0]=11; - x1[1]=5; x2[1]=3; y1[1]=12; y2[1]=12; - x1[2]=13; x2[2]=0; y1[2]=8; y2[2]=8; - x1[3]=12; x2[3]=12; y1[3]=10; y2[3]=2; - x1[4]=9; x2[4]=0; y1[4]=13; y2[4]=13; - x1[5]=1; x2[5]=1; y1[5]=7; y2[5]=3; - x1[6]=13; x2[6]=13; y1[6]=11; y2[6]=0; - x1[7]=4; x2[7]=4; y1[7]=8; y2[7]=7; - x1[8]=12; x2[8]=12; y1[8]=9; y2[8]=3; - x1[9]=11; x2[9]=5; y1[9]=2; y2[9]=2; - x1[10]=6; x2[10]=6; y1[10]=13; y2[10]=3; - x1[11]=9; x2[11]=9; y1[11]=12; y2[11]=3; - x1[12]=13; x2[12]=0; y1[12]=13; y2[12]=13; - break; - case 119: - x1[0]=13; x2[0]=10; y1[0]=5; y2[0]=5; - x1[1]=11; x2[1]=10; y1[1]=11; y2[1]=11; - x1[2]=12; x2[2]=12; y1[2]=14; y2[2]=12; - x1[3]=8; x2[3]=2; y1[3]=11; y2[3]=11; - x1[4]=12; x2[4]=10; y1[4]=8; y2[4]=8; - x1[5]=13; x2[5]=2; y1[5]=4; y2[5]=4; - x1[6]=5; x2[6]=5; y1[6]=8; y2[6]=2; - x1[7]=5; x2[7]=0; y1[7]=2; y2[7]=2; - x1[8]=7; x2[8]=7; y1[8]=13; y2[8]=11; - x1[9]=3; x2[9]=3; y1[9]=10; y2[9]=8; - x1[10]=4; x2[10]=4; y1[10]=5; y2[10]=4; - x1[11]=5; x2[11]=5; y1[11]=14; y2[11]=1; - x1[12]=12; x2[12]=2; y1[12]=2; y2[12]=2; - break; - case 120: - x1[0]=8; x2[0]=1; y1[0]=1; y2[0]=1; - x1[1]=7; x2[1]=2; y1[1]=11; y2[1]=11; - x1[2]=8; x2[2]=4; y1[2]=8; y2[2]=8; - x1[3]=6; x2[3]=6; y1[3]=11; y2[3]=4; - x1[4]=4; x2[4]=4; y1[4]=13; y2[4]=11; - x1[5]=1; x2[5]=1; y1[5]=11; y2[5]=1; - x1[6]=8; x2[6]=0; y1[6]=4; y2[6]=4; - x1[7]=14; x2[7]=0; y1[7]=12; y2[7]=12; - x1[8]=13; x2[8]=13; y1[8]=10; y2[8]=5; - x1[9]=6; x2[9]=5; y1[9]=14; y2[9]=14; - x1[10]=12; x2[10]=3; y1[10]=2; y2[10]=2; - x1[11]=5; x2[11]=1; y1[11]=13; y2[11]=13; - x1[12]=0; x2[12]=0; y1[12]=13; y2[12]=11; - break; - case 121: - x1[0]=3; x2[0]=2; y1[0]=7; y2[0]=7; - x1[1]=13; x2[1]=6; y1[1]=4; y2[1]=4; - x1[2]=4; x2[2]=4; y1[2]=7; y2[2]=5; - x1[3]=7; x2[3]=7; y1[3]=10; y2[3]=7; - x1[4]=8; x2[4]=4; y1[4]=9; y2[4]=9; - x1[5]=14; x2[5]=10; y1[5]=1; y2[5]=1; - x1[6]=9; x2[6]=5; y1[6]=1; y2[6]=1; - x1[7]=10; x2[7]=6; y1[7]=9; y2[7]=9; - x1[8]=8; x2[8]=4; y1[8]=7; y2[8]=7; - x1[9]=6; x2[9]=6; y1[9]=5; y2[9]=4; - x1[10]=7; x2[10]=7; y1[10]=14; y2[10]=9; - x1[11]=9; x2[11]=9; y1[11]=11; y2[11]=0; - x1[12]=14; x2[12]=12; y1[12]=2; y2[12]=2; - break; - case 122: - x1[0]=0; x2[0]=0; y1[0]=6; y2[0]=1; - x1[1]=13; x2[1]=13; y1[1]=5; y2[1]=2; - x1[2]=9; x2[2]=9; y1[2]=8; y2[2]=1; - x1[3]=1; x2[3]=1; y1[3]=4; y2[3]=3; - x1[4]=6; x2[4]=6; y1[4]=10; y2[4]=4; - x1[5]=6; x2[5]=6; y1[5]=6; y2[5]=4; - x1[6]=1; x2[6]=1; y1[6]=10; y2[6]=1; - x1[7]=3; x2[7]=3; y1[7]=10; y2[7]=9; - x1[8]=13; x2[8]=13; y1[8]=6; y2[8]=1; - x1[9]=12; x2[9]=6; y1[9]=2; y2[9]=2; - x1[10]=11; x2[10]=11; y1[10]=11; y2[10]=7; - x1[11]=8; x2[11]=8; y1[11]=6; y2[11]=1; - x1[12]=12; x2[12]=12; y1[12]=9; y2[12]=2; - break; - case 123: - x1[0]=12; x2[0]=2; y1[0]=12; y2[0]=12; - x1[1]=14; x2[1]=14; y1[1]=2; y2[1]=0; - x1[2]=11; x2[2]=7; y1[2]=0; y2[2]=0; - x1[3]=7; x2[3]=7; y1[3]=12; y2[3]=2; - x1[4]=13; x2[4]=5; y1[4]=6; y2[4]=6; - x1[5]=14; x2[5]=14; y1[5]=10; y2[5]=4; - x1[6]=13; x2[6]=13; y1[6]=13; y2[6]=6; - x1[7]=12; x2[7]=12; y1[7]=5; y2[7]=4; - x1[8]=14; x2[8]=13; y1[8]=1; y2[8]=1; - x1[9]=14; x2[9]=14; y1[9]=6; y2[9]=1; - x1[10]=8; x2[10]=8; y1[10]=6; y2[10]=4; - x1[11]=5; x2[11]=5; y1[11]=3; y2[11]=0; - x1[12]=9; x2[12]=3; y1[12]=8; y2[12]=8; - break; - case 124: - x1[0]=11; x2[0]=11; y1[0]=4; y2[0]=2; - x1[1]=7; x2[1]=2; y1[1]=5; y2[1]=5; - x1[2]=6; x2[2]=5; y1[2]=4; y2[2]=4; - x1[3]=14; x2[3]=13; y1[3]=5; y2[3]=5; - x1[4]=10; x2[4]=5; y1[4]=1; y2[4]=1; - x1[5]=14; x2[5]=14; y1[5]=10; y2[5]=3; - x1[6]=10; x2[6]=10; y1[6]=12; y2[6]=11; - x1[7]=13; x2[7]=13; y1[7]=10; y2[7]=6; - x1[8]=13; x2[8]=11; y1[8]=9; y2[8]=9; - x1[9]=2; x2[9]=2; y1[9]=6; y2[9]=4; - x1[10]=2; x2[10]=1; y1[10]=13; y2[10]=13; - x1[11]=5; x2[11]=5; y1[11]=12; y2[11]=2; - x1[12]=7; x2[12]=7; y1[12]=12; y2[12]=0; - break; - case 125: - x1[0]=7; x2[0]=0; y1[0]=0; y2[0]=0; - x1[1]=1; x2[1]=0; y1[1]=0; y2[1]=0; - x1[2]=2; x2[2]=2; y1[2]=13; y2[2]=6; - x1[3]=5; x2[3]=5; y1[3]=14; y2[3]=13; - x1[4]=12; x2[4]=8; y1[4]=14; y2[4]=14; - x1[5]=9; x2[5]=3; y1[5]=2; y2[5]=2; - x1[6]=11; x2[6]=4; y1[6]=14; y2[6]=14; - x1[7]=12; x2[7]=7; y1[7]=7; y2[7]=7; - x1[8]=7; x2[8]=7; y1[8]=8; y2[8]=4; - x1[9]=12; x2[9]=9; y1[9]=4; y2[9]=4; - x1[10]=11; x2[10]=3; y1[10]=3; y2[10]=3; - x1[11]=14; x2[11]=5; y1[11]=9; y2[11]=9; - x1[12]=4; x2[12]=1; y1[12]=12; y2[12]=12; - break; - case 126: - x1[0]=8; x2[0]=8; y1[0]=12; y2[0]=5; - x1[1]=8; x2[1]=5; y1[1]=2; y2[1]=2; - x1[2]=11; x2[2]=11; y1[2]=13; y2[2]=7; - x1[3]=1; x2[3]=1; y1[3]=11; y2[3]=2; - x1[4]=4; x2[4]=4; y1[4]=13; y2[4]=10; - x1[5]=5; x2[5]=2; y1[5]=11; y2[5]=11; - x1[6]=11; x2[6]=11; y1[6]=11; y2[6]=6; - x1[7]=14; x2[7]=7; y1[7]=8; y2[7]=8; - x1[8]=6; x2[8]=6; y1[8]=13; y2[8]=6; - x1[9]=7; x2[9]=4; y1[9]=8; y2[9]=8; - x1[10]=5; x2[10]=5; y1[10]=14; y2[10]=2; - x1[11]=2; x2[11]=0; y1[11]=2; y2[11]=2; - x1[12]=7; x2[12]=4; y1[12]=9; y2[12]=9; - break; - case 127: - x1[0]=8; x2[0]=8; y1[0]=12; y2[0]=11; - x1[1]=4; x2[1]=4; y1[1]=13; y2[1]=0; - x1[2]=14; x2[2]=14; y1[2]=8; y2[2]=7; - x1[3]=4; x2[3]=1; y1[3]=2; y2[3]=2; - x1[4]=5; x2[4]=4; y1[4]=9; y2[4]=9; - x1[5]=11; x2[5]=5; y1[5]=3; y2[5]=3; - x1[6]=10; x2[6]=10; y1[6]=9; y2[6]=6; - x1[7]=3; x2[7]=3; y1[7]=11; y2[7]=3; - x1[8]=4; x2[8]=4; y1[8]=10; y2[8]=7; - x1[9]=6; x2[9]=6; y1[9]=8; y2[9]=1; - x1[10]=11; x2[10]=0; y1[10]=0; y2[10]=0; - x1[11]=13; x2[11]=2; y1[11]=8; y2[11]=8; - x1[12]=8; x2[12]=8; y1[12]=10; y2[12]=5; - break; - case 128: - x1[0]=13; x2[0]=1; y1[0]=9; y2[0]=9; - x1[1]=1; x2[1]=1; y1[1]=8; y2[1]=6; - x1[2]=12; x2[2]=3; y1[2]=10; y2[2]=10; - x1[3]=8; x2[3]=2; y1[3]=5; y2[3]=5; - x1[4]=14; x2[4]=3; y1[4]=12; y2[4]=12; - x1[5]=1; x2[5]=1; y1[5]=10; y2[5]=7; - x1[6]=13; x2[6]=13; y1[6]=12; y2[6]=1; - x1[7]=3; x2[7]=3; y1[7]=11; y2[7]=5; - x1[8]=12; x2[8]=4; y1[8]=13; y2[8]=13; - x1[9]=3; x2[9]=3; y1[9]=14; y2[9]=1; - x1[10]=13; x2[10]=13; y1[10]=11; y2[10]=1; - x1[11]=5; x2[11]=5; y1[11]=11; y2[11]=3; - x1[12]=10; x2[12]=10; y1[12]=12; y2[12]=0; - break; - case 129: - x1[0]=13; x2[0]=3; y1[0]=10; y2[0]=10; - x1[1]=7; x2[1]=7; y1[1]=6; y2[1]=1; - x1[2]=12; x2[2]=2; y1[2]=0; y2[2]=0; - x1[3]=10; x2[3]=10; y1[3]=9; y2[3]=5; - x1[4]=11; x2[4]=11; y1[4]=6; y2[4]=1; - x1[5]=8; x2[5]=8; y1[5]=6; y2[5]=0; - x1[6]=14; x2[6]=9; y1[6]=13; y2[6]=13; - x1[7]=2; x2[7]=2; y1[7]=12; y2[7]=3; - x1[8]=5; x2[8]=3; y1[8]=8; y2[8]=8; - x1[9]=14; x2[9]=14; y1[9]=8; y2[9]=3; - x1[10]=5; x2[10]=0; y1[10]=7; y2[10]=7; - x1[11]=1; x2[11]=1; y1[11]=11; y2[11]=0; - x1[12]=3; x2[12]=1; y1[12]=8; y2[12]=8; - break; - case 130: - x1[0]=9; x2[0]=3; y1[0]=5; y2[0]=5; - x1[1]=9; x2[1]=8; y1[1]=6; y2[1]=6; - x1[2]=8; x2[2]=8; y1[2]=4; y2[2]=3; - x1[3]=14; x2[3]=14; y1[3]=14; y2[3]=12; - x1[4]=12; x2[4]=12; y1[4]=13; y2[4]=3; - x1[5]=1; x2[5]=1; y1[5]=11; y2[5]=5; - x1[6]=2; x2[6]=2; y1[6]=4; y2[6]=0; - x1[7]=0; x2[7]=0; y1[7]=5; y2[7]=1; - x1[8]=5; x2[8]=4; y1[8]=10; y2[8]=10; - x1[9]=11; x2[9]=6; y1[9]=3; y2[9]=3; - x1[10]=13; x2[10]=6; y1[10]=6; y2[10]=6; - x1[11]=3; x2[11]=0; y1[11]=13; y2[11]=13; - x1[12]=8; x2[12]=3; y1[12]=0; y2[12]=0; - break; - case 131: - x1[0]=11; x2[0]=5; y1[0]=6; y2[0]=6; - x1[1]=11; x2[1]=9; y1[1]=12; y2[1]=12; - x1[2]=7; x2[2]=7; y1[2]=1; y2[2]=0; - x1[3]=6; x2[3]=2; y1[3]=4; y2[3]=4; - x1[4]=11; x2[4]=7; y1[4]=8; y2[4]=8; - x1[5]=11; x2[5]=2; y1[5]=14; y2[5]=14; - x1[6]=14; x2[6]=14; y1[6]=8; y2[6]=5; - x1[7]=11; x2[7]=4; y1[7]=6; y2[7]=6; - x1[8]=12; x2[8]=0; y1[8]=2; y2[8]=2; - x1[9]=0; x2[9]=0; y1[9]=7; y2[9]=0; - x1[10]=12; x2[10]=0; y1[10]=5; y2[10]=5; - x1[11]=13; x2[11]=6; y1[11]=8; y2[11]=8; - x1[12]=0; x2[12]=0; y1[12]=1; y2[12]=0; - break; - case 132: - x1[0]=7; x2[0]=7; y1[0]=14; y2[0]=4; - x1[1]=14; x2[1]=1; y1[1]=14; y2[1]=14; - x1[2]=10; x2[2]=10; y1[2]=12; y2[2]=6; - x1[3]=6; x2[3]=3; y1[3]=14; y2[3]=14; - x1[4]=11; x2[4]=11; y1[4]=8; y2[4]=5; - x1[5]=12; x2[5]=7; y1[5]=8; y2[5]=8; - x1[6]=6; x2[6]=2; y1[6]=7; y2[6]=7; - x1[7]=7; x2[7]=1; y1[7]=12; y2[7]=12; - x1[8]=3; x2[8]=3; y1[8]=13; y2[8]=10; - x1[9]=8; x2[9]=8; y1[9]=7; y2[9]=0; - x1[10]=5; x2[10]=5; y1[10]=11; y2[10]=7; - x1[11]=10; x2[11]=3; y1[11]=9; y2[11]=9; - x1[12]=14; x2[12]=5; y1[12]=4; y2[12]=4; - break; - case 133: - x1[0]=9; x2[0]=4; y1[0]=6; y2[0]=6; - x1[1]=5; x2[1]=5; y1[1]=13; y2[1]=6; - x1[2]=5; x2[2]=5; y1[2]=2; y2[2]=1; - x1[3]=10; x2[3]=5; y1[3]=4; y2[3]=4; - x1[4]=7; x2[4]=2; y1[4]=0; y2[4]=0; - x1[5]=10; x2[5]=10; y1[5]=11; y2[5]=0; - x1[6]=13; x2[6]=2; y1[6]=1; y2[6]=1; - x1[7]=4; x2[7]=2; y1[7]=5; y2[7]=5; - x1[8]=8; x2[8]=8; y1[8]=14; y2[8]=4; - x1[9]=14; x2[9]=14; y1[9]=14; y2[9]=6; - x1[10]=8; x2[10]=8; y1[10]=13; y2[10]=9; - x1[11]=13; x2[11]=2; y1[11]=5; y2[11]=5; - x1[12]=10; x2[12]=10; y1[12]=12; y2[12]=1; - break; - case 134: - x1[0]=12; x2[0]=3; y1[0]=11; y2[0]=11; - x1[1]=9; x2[1]=9; y1[1]=12; y2[1]=0; - x1[2]=8; x2[2]=8; y1[2]=8; y2[2]=7; - x1[3]=14; x2[3]=12; y1[3]=8; y2[3]=8; - x1[4]=10; x2[4]=3; y1[4]=7; y2[4]=7; - x1[5]=9; x2[5]=5; y1[5]=3; y2[5]=3; - x1[6]=7; x2[6]=7; y1[6]=14; y2[6]=5; - x1[7]=11; x2[7]=8; y1[7]=12; y2[7]=12; - x1[8]=8; x2[8]=4; y1[8]=6; y2[8]=6; - x1[9]=10; x2[9]=10; y1[9]=13; y2[9]=3; - x1[10]=9; x2[10]=9; y1[10]=3; y2[10]=2; - x1[11]=2; x2[11]=1; y1[11]=4; y2[11]=4; - x1[12]=10; x2[12]=5; y1[12]=7; y2[12]=7; - break; - case 135: - x1[0]=4; x2[0]=4; y1[0]=14; y2[0]=7; - x1[1]=8; x2[1]=8; y1[1]=10; y2[1]=8; - x1[2]=5; x2[2]=5; y1[2]=6; y2[2]=3; - x1[3]=12; x2[3]=12; y1[3]=14; y2[3]=13; - x1[4]=14; x2[4]=14; y1[4]=2; y2[4]=1; - x1[5]=13; x2[5]=4; y1[5]=11; y2[5]=11; - x1[6]=5; x2[6]=2; y1[6]=5; y2[6]=5; - x1[7]=2; x2[7]=2; y1[7]=12; y2[7]=2; - x1[8]=9; x2[8]=9; y1[8]=10; y2[8]=0; - x1[9]=12; x2[9]=11; y1[9]=6; y2[9]=6; - x1[10]=13; x2[10]=3; y1[10]=3; y2[10]=3; - x1[11]=13; x2[11]=4; y1[11]=13; y2[11]=13; - x1[12]=5; x2[12]=5; y1[12]=7; y2[12]=5; - break; - case 136: - x1[0]=8; x2[0]=8; y1[0]=14; y2[0]=10; - x1[1]=11; x2[1]=11; y1[1]=7; y2[1]=4; - x1[2]=2; x2[2]=1; y1[2]=1; y2[2]=1; - x1[3]=10; x2[3]=2; y1[3]=2; y2[3]=2; - x1[4]=7; x2[4]=1; y1[4]=5; y2[4]=5; - x1[5]=9; x2[5]=6; y1[5]=0; y2[5]=0; - x1[6]=12; x2[6]=12; y1[6]=10; y2[6]=8; - x1[7]=13; x2[7]=13; y1[7]=11; y2[7]=8; - x1[8]=6; x2[8]=6; y1[8]=12; y2[8]=10; - x1[9]=4; x2[9]=4; y1[9]=10; y2[9]=0; - x1[10]=14; x2[10]=2; y1[10]=7; y2[10]=7; - x1[11]=8; x2[11]=8; y1[11]=9; y2[11]=4; - x1[12]=10; x2[12]=10; y1[12]=13; y2[12]=1; - break; - case 137: - x1[0]=14; x2[0]=14; y1[0]=11; y2[0]=3; - x1[1]=8; x2[1]=8; y1[1]=10; y2[1]=0; - x1[2]=9; x2[2]=4; y1[2]=7; y2[2]=7; - x1[3]=1; x2[3]=1; y1[3]=14; y2[3]=7; - x1[4]=10; x2[4]=2; y1[4]=6; y2[4]=6; - x1[5]=10; x2[5]=4; y1[5]=5; y2[5]=5; - x1[6]=3; x2[6]=3; y1[6]=9; y2[6]=0; - x1[7]=12; x2[7]=2; y1[7]=1; y2[7]=1; - x1[8]=7; x2[8]=7; y1[8]=8; y2[8]=5; - x1[9]=11; x2[9]=11; y1[9]=5; y2[9]=1; - x1[10]=5; x2[10]=5; y1[10]=5; y2[10]=2; - x1[11]=7; x2[11]=7; y1[11]=12; y2[11]=10; - x1[12]=13; x2[12]=13; y1[12]=5; y2[12]=3; - break; - case 138: - x1[0]=3; x2[0]=0; y1[0]=1; y2[0]=1; - x1[1]=10; x2[1]=6; y1[1]=14; y2[1]=14; - x1[2]=10; x2[2]=9; y1[2]=5; y2[2]=5; - x1[3]=10; x2[3]=10; y1[3]=7; y2[3]=0; - x1[4]=7; x2[4]=7; y1[4]=13; y2[4]=3; - x1[5]=13; x2[5]=13; y1[5]=7; y2[5]=4; - x1[6]=4; x2[6]=1; y1[6]=14; y2[6]=14; - x1[7]=9; x2[7]=1; y1[7]=13; y2[7]=13; - x1[8]=12; x2[8]=10; y1[8]=3; y2[8]=3; - x1[9]=14; x2[9]=12; y1[9]=13; y2[9]=13; - x1[10]=12; x2[10]=12; y1[10]=14; y2[10]=7; - x1[11]=10; x2[11]=10; y1[11]=5; y2[11]=3; - x1[12]=11; x2[12]=11; y1[12]=3; y2[12]=2; - break; - case 139: - x1[0]=10; x2[0]=9; y1[0]=10; y2[0]=10; - x1[1]=7; x2[1]=1; y1[1]=14; y2[1]=14; - x1[2]=11; x2[2]=3; y1[2]=0; y2[2]=0; - x1[3]=7; x2[3]=4; y1[3]=4; y2[3]=4; - x1[4]=3; x2[4]=3; y1[4]=13; y2[4]=8; - x1[5]=12; x2[5]=12; y1[5]=2; y2[5]=0; - x1[6]=8; x2[6]=5; y1[6]=8; y2[6]=8; - x1[7]=13; x2[7]=9; y1[7]=6; y2[7]=6; - x1[8]=12; x2[8]=2; y1[8]=13; y2[8]=13; - x1[9]=8; x2[9]=8; y1[9]=11; y2[9]=9; - x1[10]=8; x2[10]=4; y1[10]=12; y2[10]=12; - x1[11]=12; x2[11]=12; y1[11]=8; y2[11]=1; - x1[12]=13; x2[12]=10; y1[12]=13; y2[12]=13; - break; - case 140: - x1[0]=7; x2[0]=0; y1[0]=14; y2[0]=14; - x1[1]=7; x2[1]=5; y1[1]=1; y2[1]=1; - x1[2]=0; x2[2]=0; y1[2]=11; y2[2]=6; - x1[3]=13; x2[3]=13; y1[3]=11; y2[3]=4; - x1[4]=8; x2[4]=5; y1[4]=5; y2[4]=5; - x1[5]=8; x2[5]=8; y1[5]=10; y2[5]=4; - x1[6]=3; x2[6]=2; y1[6]=2; y2[6]=2; - x1[7]=5; x2[7]=5; y1[7]=11; y2[7]=1; - x1[8]=14; x2[8]=6; y1[8]=12; y2[8]=12; - x1[9]=9; x2[9]=9; y1[9]=7; y2[9]=3; - x1[10]=8; x2[10]=7; y1[10]=5; y2[10]=5; - x1[11]=3; x2[11]=3; y1[11]=11; y2[11]=9; - x1[12]=4; x2[12]=0; y1[12]=14; y2[12]=14; - break; - case 141: - x1[0]=6; x2[0]=5; y1[0]=2; y2[0]=2; - x1[1]=9; x2[1]=1; y1[1]=12; y2[1]=12; - x1[2]=9; x2[2]=9; y1[2]=10; y2[2]=7; - x1[3]=13; x2[3]=13; y1[3]=6; y2[3]=2; - x1[4]=11; x2[4]=10; y1[4]=9; y2[4]=9; - x1[5]=1; x2[5]=1; y1[5]=12; y2[5]=11; - x1[6]=14; x2[6]=14; y1[6]=10; y2[6]=5; - x1[7]=1; x2[7]=1; y1[7]=9; y2[7]=4; - x1[8]=5; x2[8]=5; y1[8]=10; y2[8]=4; - x1[9]=9; x2[9]=9; y1[9]=11; y2[9]=3; - x1[10]=8; x2[10]=8; y1[10]=10; y2[10]=1; - x1[11]=6; x2[11]=6; y1[11]=9; y2[11]=2; - x1[12]=8; x2[12]=8; y1[12]=7; y2[12]=2; - break; - case 142: - x1[0]=12; x2[0]=12; y1[0]=13; y2[0]=9; - x1[1]=13; x2[1]=4; y1[1]=0; y2[1]=0; - x1[2]=13; x2[2]=10; y1[2]=11; y2[2]=11; - x1[3]=14; x2[3]=5; y1[3]=7; y2[3]=7; - x1[4]=14; x2[4]=6; y1[4]=2; y2[4]=2; - x1[5]=13; x2[5]=12; y1[5]=4; y2[5]=4; - x1[6]=13; x2[6]=6; y1[6]=0; y2[6]=0; - x1[7]=3; x2[7]=3; y1[7]=13; y2[7]=5; - x1[8]=0; x2[8]=0; y1[8]=2; y2[8]=0; - x1[9]=8; x2[9]=4; y1[9]=13; y2[9]=13; - x1[10]=14; x2[10]=2; y1[10]=1; y2[10]=1; - x1[11]=7; x2[11]=7; y1[11]=11; y2[11]=0; - x1[12]=13; x2[12]=13; y1[12]=14; y2[12]=0; - break; - case 143: - x1[0]=3; x2[0]=2; y1[0]=8; y2[0]=8; - x1[1]=13; x2[1]=13; y1[1]=14; y2[1]=11; - x1[2]=1; x2[2]=0; y1[2]=12; y2[2]=12; - x1[3]=2; x2[3]=2; y1[3]=13; y2[3]=1; - x1[4]=9; x2[4]=2; y1[4]=9; y2[4]=9; - x1[5]=8; x2[5]=8; y1[5]=9; y2[5]=2; - x1[6]=0; x2[6]=0; y1[6]=14; y2[6]=6; - x1[7]=11; x2[7]=11; y1[7]=10; y2[7]=8; - x1[8]=6; x2[8]=6; y1[8]=6; y2[8]=2; - x1[9]=12; x2[9]=3; y1[9]=9; y2[9]=9; - x1[10]=11; x2[10]=11; y1[10]=6; y2[10]=3; - x1[11]=8; x2[11]=8; y1[11]=12; y2[11]=8; - x1[12]=9; x2[12]=9; y1[12]=14; y2[12]=8; - break; - case 144: - x1[0]=8; x2[0]=8; y1[0]=13; y2[0]=10; - x1[1]=5; x2[1]=5; y1[1]=9; y2[1]=4; - x1[2]=6; x2[2]=6; y1[2]=10; y2[2]=1; - x1[3]=1; x2[3]=1; y1[3]=13; y2[3]=7; - x1[4]=13; x2[4]=11; y1[4]=2; y2[4]=2; - x1[5]=14; x2[5]=4; y1[5]=11; y2[5]=11; - x1[6]=11; x2[6]=10; y1[6]=14; y2[6]=14; - x1[7]=2; x2[7]=2; y1[7]=14; y2[7]=4; - x1[8]=3; x2[8]=3; y1[8]=12; y2[8]=5; - x1[9]=9; x2[9]=9; y1[9]=9; y2[9]=4; - x1[10]=4; x2[10]=4; y1[10]=12; y2[10]=0; - x1[11]=12; x2[11]=12; y1[11]=13; y2[11]=12; - x1[12]=4; x2[12]=4; y1[12]=9; y2[12]=1; - break; - case 145: - x1[0]=9; x2[0]=4; y1[0]=8; y2[0]=8; - x1[1]=11; x2[1]=3; y1[1]=7; y2[1]=7; - x1[2]=11; x2[2]=0; y1[2]=1; y2[2]=1; - x1[3]=7; x2[3]=7; y1[3]=5; y2[3]=0; - x1[4]=6; x2[4]=1; y1[4]=6; y2[4]=6; - x1[5]=9; x2[5]=7; y1[5]=4; y2[5]=4; - x1[6]=9; x2[6]=9; y1[6]=11; y2[6]=10; - x1[7]=7; x2[7]=4; y1[7]=3; y2[7]=3; - x1[8]=3; x2[8]=3; y1[8]=11; y2[8]=6; - x1[9]=14; x2[9]=2; y1[9]=12; y2[9]=12; - x1[10]=8; x2[10]=7; y1[10]=6; y2[10]=6; - x1[11]=6; x2[11]=4; y1[11]=4; y2[11]=4; - x1[12]=10; x2[12]=10; y1[12]=10; y2[12]=7; - break; - case 146: - x1[0]=7; x2[0]=0; y1[0]=7; y2[0]=7; - x1[1]=6; x2[1]=6; y1[1]=5; y2[1]=0; - x1[2]=12; x2[2]=10; y1[2]=6; y2[2]=6; - x1[3]=10; x2[3]=10; y1[3]=14; y2[3]=4; - x1[4]=2; x2[4]=2; y1[4]=7; y2[4]=2; - x1[5]=10; x2[5]=10; y1[5]=7; y2[5]=2; - x1[6]=4; x2[6]=4; y1[6]=12; y2[6]=3; - x1[7]=4; x2[7]=0; y1[7]=6; y2[7]=6; - x1[8]=7; x2[8]=7; y1[8]=12; y2[8]=4; - x1[9]=4; x2[9]=3; y1[9]=0; y2[9]=0; - x1[10]=3; x2[10]=3; y1[10]=9; y2[10]=3; - x1[11]=9; x2[11]=4; y1[11]=11; y2[11]=11; - x1[12]=9; x2[12]=9; y1[12]=14; y2[12]=0; - break; - case 147: - x1[0]=14; x2[0]=10; y1[0]=14; y2[0]=14; - x1[1]=14; x2[1]=3; y1[1]=7; y2[1]=7; - x1[2]=14; x2[2]=14; y1[2]=8; y2[2]=1; - x1[3]=6; x2[3]=2; y1[3]=2; y2[3]=2; - x1[4]=0; x2[4]=0; y1[4]=14; y2[4]=2; - x1[5]=13; x2[5]=0; y1[5]=9; y2[5]=9; - x1[6]=0; x2[6]=0; y1[6]=5; y2[6]=2; - x1[7]=5; x2[7]=5; y1[7]=8; y2[7]=7; - x1[8]=6; x2[8]=4; y1[8]=0; y2[8]=0; - x1[9]=11; x2[9]=8; y1[9]=0; y2[9]=0; - x1[10]=0; x2[10]=0; y1[10]=12; y2[10]=0; - x1[11]=9; x2[11]=9; y1[11]=13; y2[11]=8; - x1[12]=9; x2[12]=9; y1[12]=14; y2[12]=4; - break; - case 148: - x1[0]=7; x2[0]=7; y1[0]=9; y2[0]=6; - x1[1]=8; x2[1]=6; y1[1]=14; y2[1]=14; - x1[2]=4; x2[2]=4; y1[2]=6; y2[2]=1; - x1[3]=5; x2[3]=5; y1[3]=4; y2[3]=1; - x1[4]=4; x2[4]=3; y1[4]=9; y2[4]=9; - x1[5]=1; x2[5]=1; y1[5]=14; y2[5]=2; - x1[6]=0; x2[6]=0; y1[6]=14; y2[6]=12; - x1[7]=8; x2[7]=2; y1[7]=9; y2[7]=9; - x1[8]=8; x2[8]=8; y1[8]=14; y2[8]=9; - x1[9]=12; x2[9]=11; y1[9]=3; y2[9]=3; - x1[10]=13; x2[10]=6; y1[10]=2; y2[10]=2; - x1[11]=6; x2[11]=6; y1[11]=1; y2[11]=0; - x1[12]=4; x2[12]=4; y1[12]=8; y2[12]=0; - break; - case 149: - x1[0]=8; x2[0]=8; y1[0]=12; y2[0]=0; - x1[1]=5; x2[1]=5; y1[1]=10; y2[1]=3; - x1[2]=8; x2[2]=6; y1[2]=11; y2[2]=11; - x1[3]=7; x2[3]=1; y1[3]=11; y2[3]=11; - x1[4]=11; x2[4]=0; y1[4]=9; y2[4]=9; - x1[5]=9; x2[5]=6; y1[5]=5; y2[5]=5; - x1[6]=2; x2[6]=2; y1[6]=7; y2[6]=4; - x1[7]=13; x2[7]=13; y1[7]=13; y2[7]=9; - x1[8]=10; x2[8]=6; y1[8]=12; y2[8]=12; - x1[9]=4; x2[9]=4; y1[9]=10; y2[9]=3; - x1[10]=14; x2[10]=1; y1[10]=1; y2[10]=1; - x1[11]=9; x2[11]=6; y1[11]=11; y2[11]=11; - x1[12]=10; x2[12]=3; y1[12]=2; y2[12]=2; - break; - case 150: - x1[0]=10; x2[0]=10; y1[0]=8; y2[0]=7; - x1[1]=3; x2[1]=3; y1[1]=6; y2[1]=2; - x1[2]=12; x2[2]=10; y1[2]=11; y2[2]=11; - x1[3]=7; x2[3]=7; y1[3]=5; y2[3]=4; - x1[4]=7; x2[4]=2; y1[4]=7; y2[4]=7; - x1[5]=0; x2[5]=0; y1[5]=7; y2[5]=5; - x1[6]=9; x2[6]=7; y1[6]=0; y2[6]=0; - x1[7]=5; x2[7]=5; y1[7]=12; y2[7]=1; - x1[8]=12; x2[8]=12; y1[8]=14; y2[8]=10; - x1[9]=1; x2[9]=1; y1[9]=4; y2[9]=0; - x1[10]=14; x2[10]=10; y1[10]=11; y2[10]=11; - x1[11]=11; x2[11]=11; y1[11]=11; y2[11]=3; - x1[12]=2; x2[12]=0; y1[12]=14; y2[12]=14; - break; - case 151: - x1[0]=9; x2[0]=9; y1[0]=7; y2[0]=6; - x1[1]=13; x2[1]=4; y1[1]=2; y2[1]=2; - x1[2]=10; x2[2]=4; y1[2]=4; y2[2]=4; - x1[3]=6; x2[3]=6; y1[3]=10; y2[3]=6; - x1[4]=10; x2[4]=10; y1[4]=13; y2[4]=7; - x1[5]=13; x2[5]=2; y1[5]=2; y2[5]=2; - x1[6]=14; x2[6]=14; y1[6]=14; y2[6]=5; - x1[7]=10; x2[7]=5; y1[7]=13; y2[7]=13; - x1[8]=11; x2[8]=11; y1[8]=14; y2[8]=10; - x1[9]=13; x2[9]=11; y1[9]=0; y2[9]=0; - x1[10]=14; x2[10]=14; y1[10]=3; y2[10]=1; - x1[11]=13; x2[11]=9; y1[11]=8; y2[11]=8; - x1[12]=10; x2[12]=6; y1[12]=1; y2[12]=1; - break; - case 152: - x1[0]=3; x2[0]=3; y1[0]=6; y2[0]=4; - x1[1]=3; x2[1]=3; y1[1]=11; y2[1]=8; - x1[2]=9; x2[2]=9; y1[2]=7; y2[2]=1; - x1[3]=8; x2[3]=4; y1[3]=5; y2[3]=5; - x1[4]=7; x2[4]=7; y1[4]=9; y2[4]=4; - x1[5]=11; x2[5]=6; y1[5]=7; y2[5]=7; - x1[6]=11; x2[6]=1; y1[6]=12; y2[6]=12; - x1[7]=14; x2[7]=14; y1[7]=12; y2[7]=1; - x1[8]=14; x2[8]=14; y1[8]=9; y2[8]=2; - x1[9]=10; x2[9]=3; y1[9]=12; y2[9]=12; - x1[10]=9; x2[10]=7; y1[10]=5; y2[10]=5; - x1[11]=5; x2[11]=5; y1[11]=14; y2[11]=0; - x1[12]=8; x2[12]=8; y1[12]=13; y2[12]=7; - break; - case 153: - x1[0]=10; x2[0]=10; y1[0]=13; y2[0]=8; - x1[1]=10; x2[1]=3; y1[1]=0; y2[1]=0; - x1[2]=14; x2[2]=12; y1[2]=11; y2[2]=11; - x1[3]=3; x2[3]=3; y1[3]=13; y2[3]=3; - x1[4]=14; x2[4]=8; y1[4]=13; y2[4]=13; - x1[5]=3; x2[5]=3; y1[5]=13; y2[5]=9; - x1[6]=0; x2[6]=0; y1[6]=14; y2[6]=5; - x1[7]=2; x2[7]=2; y1[7]=13; y2[7]=11; - x1[8]=13; x2[8]=2; y1[8]=14; y2[8]=14; - x1[9]=11; x2[9]=11; y1[9]=7; y2[9]=3; - x1[10]=6; x2[10]=6; y1[10]=12; y2[10]=5; - x1[11]=9; x2[11]=4; y1[11]=2; y2[11]=2; - x1[12]=14; x2[12]=13; y1[12]=11; y2[12]=11; - break; - case 154: - x1[0]=14; x2[0]=13; y1[0]=0; y2[0]=0; - x1[1]=14; x2[1]=14; y1[1]=9; y2[1]=5; - x1[2]=4; x2[2]=3; y1[2]=4; y2[2]=4; - x1[3]=11; x2[3]=11; y1[3]=13; y2[3]=0; - x1[4]=10; x2[4]=10; y1[4]=13; y2[4]=6; - x1[5]=4; x2[5]=4; y1[5]=7; y2[5]=0; - x1[6]=13; x2[6]=13; y1[6]=12; y2[6]=5; - x1[7]=1; x2[7]=1; y1[7]=5; y2[7]=3; - x1[8]=3; x2[8]=2; y1[8]=1; y2[8]=1; - x1[9]=7; x2[9]=7; y1[9]=12; y2[9]=9; - x1[10]=3; x2[10]=3; y1[10]=11; y2[10]=1; - x1[11]=4; x2[11]=4; y1[11]=8; y2[11]=2; - x1[12]=9; x2[12]=5; y1[12]=10; y2[12]=10; - break; - case 155: - x1[0]=11; x2[0]=11; y1[0]=12; y2[0]=9; - x1[1]=8; x2[1]=7; y1[1]=4; y2[1]=4; - x1[2]=11; x2[2]=11; y1[2]=12; y2[2]=3; - x1[3]=11; x2[3]=6; y1[3]=5; y2[3]=5; - x1[4]=1; x2[4]=1; y1[4]=9; y2[4]=7; - x1[5]=12; x2[5]=5; y1[5]=11; y2[5]=11; - x1[6]=6; x2[6]=5; y1[6]=12; y2[6]=12; - x1[7]=7; x2[7]=6; y1[7]=7; y2[7]=7; - x1[8]=7; x2[8]=7; y1[8]=11; y2[8]=9; - x1[9]=13; x2[9]=13; y1[9]=3; y2[9]=1; - x1[10]=11; x2[10]=6; y1[10]=9; y2[10]=9; - x1[11]=13; x2[11]=12; y1[11]=9; y2[11]=9; - x1[12]=6; x2[12]=6; y1[12]=11; y2[12]=2; - break; - case 156: - x1[0]=4; x2[0]=2; y1[0]=11; y2[0]=11; - x1[1]=11; x2[1]=11; y1[1]=12; y2[1]=10; - x1[2]=10; x2[2]=7; y1[2]=2; y2[2]=2; - x1[3]=14; x2[3]=0; y1[3]=11; y2[3]=11; - x1[4]=14; x2[4]=2; y1[4]=5; y2[4]=5; - x1[5]=7; x2[5]=2; y1[5]=8; y2[5]=8; - x1[6]=4; x2[6]=3; y1[6]=1; y2[6]=1; - x1[7]=5; x2[7]=1; y1[7]=3; y2[7]=3; - x1[8]=12; x2[8]=9; y1[8]=10; y2[8]=10; - x1[9]=6; x2[9]=5; y1[9]=0; y2[9]=0; - x1[10]=13; x2[10]=1; y1[10]=4; y2[10]=4; - x1[11]=1; x2[11]=1; y1[11]=12; y2[11]=3; - x1[12]=10; x2[12]=1; y1[12]=1; y2[12]=1; - break; - case 157: - x1[0]=8; x2[0]=8; y1[0]=3; y2[0]=2; - x1[1]=3; x2[1]=1; y1[1]=14; y2[1]=14; - x1[2]=9; x2[2]=2; y1[2]=5; y2[2]=5; - x1[3]=14; x2[3]=14; y1[3]=14; y2[3]=8; - x1[4]=6; x2[4]=6; y1[4]=6; y2[4]=0; - x1[5]=11; x2[5]=5; y1[5]=9; y2[5]=9; - x1[6]=11; x2[6]=11; y1[6]=14; y2[6]=7; - x1[7]=5; x2[7]=0; y1[7]=10; y2[7]=10; - x1[8]=10; x2[8]=10; y1[8]=13; y2[8]=9; - x1[9]=1; x2[9]=0; y1[9]=13; y2[9]=13; - x1[10]=0; x2[10]=0; y1[10]=13; y2[10]=0; - x1[11]=6; x2[11]=6; y1[11]=10; y2[11]=9; - x1[12]=2; x2[12]=2; y1[12]=8; y2[12]=5; - break; - case 158: - x1[0]=2; x2[0]=1; y1[0]=3; y2[0]=3; - x1[1]=1; x2[1]=0; y1[1]=10; y2[1]=10; - x1[2]=1; x2[2]=1; y1[2]=14; y2[2]=4; - x1[3]=14; x2[3]=7; y1[3]=9; y2[3]=9; - x1[4]=10; x2[4]=8; y1[4]=9; y2[4]=9; - x1[5]=9; x2[5]=9; y1[5]=6; y2[5]=1; - x1[6]=4; x2[6]=4; y1[6]=14; y2[6]=4; - x1[7]=10; x2[7]=1; y1[7]=13; y2[7]=13; - x1[8]=1; x2[8]=1; y1[8]=13; y2[8]=5; - x1[9]=3; x2[9]=1; y1[9]=10; y2[9]=10; - x1[10]=2; x2[10]=2; y1[10]=5; y2[10]=4; - x1[11]=3; x2[11]=3; y1[11]=3; y2[11]=0; - x1[12]=9; x2[12]=9; y1[12]=13; y2[12]=11; - break; - case 159: - x1[0]=8; x2[0]=7; y1[0]=11; y2[0]=11; - x1[1]=11; x2[1]=11; y1[1]=9; y2[1]=0; - x1[2]=13; x2[2]=9; y1[2]=12; y2[2]=12; - x1[3]=8; x2[3]=6; y1[3]=3; y2[3]=3; - x1[4]=8; x2[4]=8; y1[4]=12; y2[4]=1; - x1[5]=14; x2[5]=11; y1[5]=6; y2[5]=6; - x1[6]=2; x2[6]=2; y1[6]=4; y2[6]=3; - x1[7]=10; x2[7]=10; y1[7]=3; y2[7]=2; - x1[8]=12; x2[8]=10; y1[8]=2; y2[8]=2; - x1[9]=6; x2[9]=6; y1[9]=3; y2[9]=2; - x1[10]=0; x2[10]=0; y1[10]=12; y2[10]=7; - x1[11]=7; x2[11]=4; y1[11]=1; y2[11]=1; - x1[12]=11; x2[12]=2; y1[12]=4; y2[12]=4; - break; - case 160: - x1[0]=10; x2[0]=1; y1[0]=9; y2[0]=9; - x1[1]=4; x2[1]=4; y1[1]=2; y2[1]=0; - x1[2]=11; x2[2]=10; y1[2]=8; y2[2]=8; - x1[3]=12; x2[3]=12; y1[3]=1; y2[3]=0; - x1[4]=13; x2[4]=6; y1[4]=5; y2[4]=5; - x1[5]=12; x2[5]=12; y1[5]=13; y2[5]=0; - x1[6]=5; x2[6]=1; y1[6]=10; y2[6]=10; - x1[7]=14; x2[7]=9; y1[7]=12; y2[7]=12; - x1[8]=9; x2[8]=1; y1[8]=6; y2[8]=6; - x1[9]=11; x2[9]=11; y1[9]=11; y2[9]=5; - x1[10]=12; x2[10]=12; y1[10]=13; y2[10]=11; - x1[11]=10; x2[11]=10; y1[11]=14; y2[11]=5; - x1[12]=6; x2[12]=5; y1[12]=6; y2[12]=6; - break; - case 161: - x1[0]=14; x2[0]=13; y1[0]=3; y2[0]=3; - x1[1]=6; x2[1]=3; y1[1]=0; y2[1]=0; - x1[2]=5; x2[2]=5; y1[2]=9; y2[2]=6; - x1[3]=11; x2[3]=11; y1[3]=9; y2[3]=8; - x1[4]=7; x2[4]=7; y1[4]=11; y2[4]=7; - x1[5]=0; x2[5]=0; y1[5]=13; y2[5]=8; - x1[6]=12; x2[6]=7; y1[6]=12; y2[6]=12; - x1[7]=11; x2[7]=9; y1[7]=1; y2[7]=1; - x1[8]=14; x2[8]=13; y1[8]=7; y2[8]=7; - x1[9]=6; x2[9]=4; y1[9]=12; y2[9]=12; - x1[10]=8; x2[10]=8; y1[10]=11; y2[10]=2; - x1[11]=13; x2[11]=13; y1[11]=13; y2[11]=2; - x1[12]=10; x2[12]=10; y1[12]=11; y2[12]=4; - break; - case 162: - x1[0]=11; x2[0]=9; y1[0]=2; y2[0]=2; - x1[1]=6; x2[1]=6; y1[1]=11; y2[1]=9; - x1[2]=13; x2[2]=13; y1[2]=12; y2[2]=7; - x1[3]=0; x2[3]=0; y1[3]=14; y2[3]=9; - x1[4]=12; x2[4]=9; y1[4]=11; y2[4]=11; - x1[5]=10; x2[5]=4; y1[5]=2; y2[5]=2; - x1[6]=10; x2[6]=3; y1[6]=1; y2[6]=1; - x1[7]=6; x2[7]=6; y1[7]=13; y2[7]=10; - x1[8]=11; x2[8]=11; y1[8]=14; y2[8]=9; - x1[9]=13; x2[9]=13; y1[9]=9; y2[9]=8; - x1[10]=5; x2[10]=2; y1[10]=12; y2[10]=12; - x1[11]=12; x2[11]=6; y1[11]=14; y2[11]=14; - x1[12]=5; x2[12]=0; y1[12]=5; y2[12]=5; - break; - case 163: - x1[0]=10; x2[0]=1; y1[0]=7; y2[0]=7; - x1[1]=12; x2[1]=1; y1[1]=1; y2[1]=1; - x1[2]=7; x2[2]=7; y1[2]=11; y2[2]=5; - x1[3]=12; x2[3]=6; y1[3]=10; y2[3]=10; - x1[4]=5; x2[4]=5; y1[4]=7; y2[4]=0; - x1[5]=8; x2[5]=5; y1[5]=3; y2[5]=3; - x1[6]=5; x2[6]=5; y1[6]=6; y2[6]=1; - x1[7]=6; x2[7]=6; y1[7]=11; y2[7]=7; - x1[8]=8; x2[8]=8; y1[8]=11; y2[8]=10; - x1[9]=9; x2[9]=9; y1[9]=10; y2[9]=2; - x1[10]=11; x2[10]=11; y1[10]=12; y2[10]=4; - x1[11]=4; x2[11]=4; y1[11]=3; y2[11]=1; - x1[12]=5; x2[12]=0; y1[12]=12; y2[12]=12; - break; - case 164: - x1[0]=12; x2[0]=0; y1[0]=4; y2[0]=4; - x1[1]=8; x2[1]=6; y1[1]=12; y2[1]=12; - x1[2]=14; x2[2]=5; y1[2]=13; y2[2]=13; - x1[3]=5; x2[3]=5; y1[3]=13; y2[3]=9; - x1[4]=4; x2[4]=4; y1[4]=11; y2[4]=9; - x1[5]=14; x2[5]=14; y1[5]=10; y2[5]=1; - x1[6]=10; x2[6]=5; y1[6]=12; y2[6]=12; - x1[7]=8; x2[7]=8; y1[7]=4; y2[7]=1; - x1[8]=1; x2[8]=1; y1[8]=5; y2[8]=2; - x1[9]=11; x2[9]=8; y1[9]=8; y2[9]=8; - x1[10]=9; x2[10]=9; y1[10]=13; y2[10]=10; - x1[11]=4; x2[11]=3; y1[11]=10; y2[11]=10; - x1[12]=8; x2[12]=8; y1[12]=8; y2[12]=1; - break; - case 165: - x1[0]=11; x2[0]=0; y1[0]=5; y2[0]=5; - x1[1]=3; x2[1]=3; y1[1]=13; y2[1]=4; - x1[2]=13; x2[2]=13; y1[2]=12; y2[2]=2; - x1[3]=9; x2[3]=7; y1[3]=12; y2[3]=12; - x1[4]=11; x2[4]=9; y1[4]=10; y2[4]=10; - x1[5]=10; x2[5]=10; y1[5]=7; y2[5]=6; - x1[6]=11; x2[6]=11; y1[6]=8; y2[6]=2; - x1[7]=10; x2[7]=0; y1[7]=14; y2[7]=14; - x1[8]=9; x2[8]=9; y1[8]=14; y2[8]=9; - x1[9]=13; x2[9]=8; y1[9]=2; y2[9]=2; - x1[10]=2; x2[10]=1; y1[10]=0; y2[10]=0; - x1[11]=7; x2[11]=7; y1[11]=13; y2[11]=5; - x1[12]=7; x2[12]=7; y1[12]=6; y2[12]=5; - break; - case 166: - x1[0]=3; x2[0]=3; y1[0]=14; y2[0]=10; - x1[1]=12; x2[1]=1; y1[1]=10; y2[1]=10; - x1[2]=9; x2[2]=9; y1[2]=12; y2[2]=4; - x1[3]=11; x2[3]=3; y1[3]=1; y2[3]=1; - x1[4]=2; x2[4]=2; y1[4]=9; y2[4]=5; - x1[5]=14; x2[5]=8; y1[5]=2; y2[5]=2; - x1[6]=14; x2[6]=14; y1[6]=7; y2[6]=2; - x1[7]=8; x2[7]=8; y1[7]=2; y2[7]=1; - x1[8]=12; x2[8]=10; y1[8]=14; y2[8]=14; - x1[9]=12; x2[9]=8; y1[9]=7; y2[9]=7; - x1[10]=9; x2[10]=5; y1[10]=5; y2[10]=5; - x1[11]=12; x2[11]=11; y1[11]=14; y2[11]=14; - x1[12]=4; x2[12]=4; y1[12]=3; y2[12]=0; - break; - case 167: - x1[0]=6; x2[0]=0; y1[0]=8; y2[0]=8; - x1[1]=10; x2[1]=8; y1[1]=6; y2[1]=6; - x1[2]=9; x2[2]=4; y1[2]=12; y2[2]=12; - x1[3]=6; x2[3]=6; y1[3]=14; y2[3]=10; - x1[4]=13; x2[4]=9; y1[4]=10; y2[4]=10; - x1[5]=3; x2[5]=3; y1[5]=7; y2[5]=6; - x1[6]=14; x2[6]=11; y1[6]=10; y2[6]=10; - x1[7]=0; x2[7]=0; y1[7]=14; y2[7]=13; - x1[8]=3; x2[8]=3; y1[8]=12; y2[8]=8; - x1[9]=8; x2[9]=6; y1[9]=2; y2[9]=2; - x1[10]=6; x2[10]=2; y1[10]=5; y2[10]=5; - x1[11]=10; x2[11]=0; y1[11]=3; y2[11]=3; - x1[12]=9; x2[12]=9; y1[12]=12; y2[12]=1; - break; - case 168: - x1[0]=4; x2[0]=4; y1[0]=6; y2[0]=4; - x1[1]=11; x2[1]=11; y1[1]=14; y2[1]=3; - x1[2]=14; x2[2]=14; y1[2]=12; y2[2]=4; - x1[3]=8; x2[3]=5; y1[3]=7; y2[3]=7; - x1[4]=12; x2[4]=9; y1[4]=14; y2[4]=14; - x1[5]=2; x2[5]=2; y1[5]=11; y2[5]=5; - x1[6]=13; x2[6]=13; y1[6]=14; y2[6]=1; - x1[7]=5; x2[7]=5; y1[7]=5; y2[7]=1; - x1[8]=14; x2[8]=11; y1[8]=12; y2[8]=12; - x1[9]=6; x2[9]=6; y1[9]=10; y2[9]=0; - x1[10]=4; x2[10]=4; y1[10]=3; y2[10]=2; - x1[11]=7; x2[11]=1; y1[11]=8; y2[11]=8; - x1[12]=7; x2[12]=3; y1[12]=9; y2[12]=9; - break; - case 169: - x1[0]=11; x2[0]=1; y1[0]=11; y2[0]=11; - x1[1]=6; x2[1]=6; y1[1]=7; y2[1]=0; - x1[2]=5; x2[2]=5; y1[2]=11; y2[2]=8; - x1[3]=14; x2[3]=2; y1[3]=2; y2[3]=2; - x1[4]=7; x2[4]=7; y1[4]=11; y2[4]=4; - x1[5]=7; x2[5]=7; y1[5]=7; y2[5]=3; - x1[6]=9; x2[6]=9; y1[6]=10; y2[6]=3; - x1[7]=2; x2[7]=2; y1[7]=12; y2[7]=7; - x1[8]=12; x2[8]=2; y1[8]=8; y2[8]=8; - x1[9]=14; x2[9]=14; y1[9]=12; y2[9]=3; - x1[10]=9; x2[10]=2; y1[10]=8; y2[10]=8; - x1[11]=4; x2[11]=4; y1[11]=4; y2[11]=1; - x1[12]=8; x2[12]=0; y1[12]=1; y2[12]=1; - break; - case 170: - x1[0]=8; x2[0]=7; y1[0]=0; y2[0]=0; - x1[1]=8; x2[1]=3; y1[1]=8; y2[1]=8; - x1[2]=13; x2[2]=2; y1[2]=10; y2[2]=10; - x1[3]=12; x2[3]=5; y1[3]=7; y2[3]=7; - x1[4]=2; x2[4]=2; y1[4]=11; y2[4]=4; - x1[5]=6; x2[5]=6; y1[5]=14; y2[5]=4; - x1[6]=11; x2[6]=5; y1[6]=11; y2[6]=11; - x1[7]=9; x2[7]=6; y1[7]=2; y2[7]=2; - x1[8]=1; x2[8]=1; y1[8]=5; y2[8]=4; - x1[9]=4; x2[9]=4; y1[9]=10; y2[9]=5; - x1[10]=12; x2[10]=12; y1[10]=9; y2[10]=6; - x1[11]=8; x2[11]=8; y1[11]=1; y2[11]=0; - x1[12]=4; x2[12]=4; y1[12]=8; y2[12]=5; - break; - case 171: - x1[0]=12; x2[0]=12; y1[0]=5; y2[0]=2; - x1[1]=3; x2[1]=3; y1[1]=6; y2[1]=5; - x1[2]=14; x2[2]=14; y1[2]=13; y2[2]=12; - x1[3]=10; x2[3]=10; y1[3]=9; y2[3]=7; - x1[4]=5; x2[4]=3; y1[4]=10; y2[4]=10; - x1[5]=5; x2[5]=4; y1[5]=0; y2[5]=0; - x1[6]=8; x2[6]=8; y1[6]=13; y2[6]=12; - x1[7]=14; x2[7]=11; y1[7]=11; y2[7]=11; - x1[8]=13; x2[8]=1; y1[8]=7; y2[8]=7; - x1[9]=6; x2[9]=3; y1[9]=10; y2[9]=10; - x1[10]=3; x2[10]=3; y1[10]=14; y2[10]=5; - x1[11]=2; x2[11]=2; y1[11]=7; y2[11]=6; - x1[12]=7; x2[12]=7; y1[12]=8; y2[12]=0; - break; - case 172: - x1[0]=2; x2[0]=2; y1[0]=10; y2[0]=3; - x1[1]=9; x2[1]=6; y1[1]=13; y2[1]=13; - x1[2]=6; x2[2]=0; y1[2]=12; y2[2]=12; - x1[3]=4; x2[3]=0; y1[3]=4; y2[3]=4; - x1[4]=13; x2[4]=9; y1[4]=9; y2[4]=9; - x1[5]=2; x2[5]=0; y1[5]=3; y2[5]=3; - x1[6]=1; x2[6]=1; y1[6]=7; y2[6]=6; - x1[7]=13; x2[7]=13; y1[7]=10; y2[7]=9; - x1[8]=7; x2[8]=7; y1[8]=7; y2[8]=2; - x1[9]=6; x2[9]=3; y1[9]=1; y2[9]=1; - x1[10]=12; x2[10]=12; y1[10]=11; y2[10]=7; - x1[11]=11; x2[11]=3; y1[11]=14; y2[11]=14; - x1[12]=8; x2[12]=8; y1[12]=6; y2[12]=3; - break; - case 173: - x1[0]=12; x2[0]=12; y1[0]=12; y2[0]=1; - x1[1]=4; x2[1]=4; y1[1]=14; y2[1]=1; - x1[2]=1; x2[2]=1; y1[2]=4; y2[2]=1; - x1[3]=14; x2[3]=14; y1[3]=14; y2[3]=4; - x1[4]=10; x2[4]=6; y1[4]=0; y2[4]=0; - x1[5]=11; x2[5]=8; y1[5]=4; y2[5]=4; - x1[6]=11; x2[6]=11; y1[6]=14; y2[6]=12; - x1[7]=12; x2[7]=0; y1[7]=1; y2[7]=1; - x1[8]=3; x2[8]=2; y1[8]=5; y2[8]=5; - x1[9]=9; x2[9]=9; y1[9]=7; y2[9]=0; - x1[10]=11; x2[10]=0; y1[10]=6; y2[10]=6; - x1[11]=11; x2[11]=4; y1[11]=2; y2[11]=2; - x1[12]=8; x2[12]=8; y1[12]=14; y2[12]=6; - break; - case 174: - x1[0]=9; x2[0]=8; y1[0]=8; y2[0]=8; - x1[1]=8; x2[1]=5; y1[1]=11; y2[1]=11; - x1[2]=9; x2[2]=8; y1[2]=7; y2[2]=7; - x1[3]=5; x2[3]=5; y1[3]=8; y2[3]=6; - x1[4]=3; x2[4]=0; y1[4]=4; y2[4]=4; - x1[5]=8; x2[5]=1; y1[5]=13; y2[5]=13; - x1[6]=9; x2[6]=9; y1[6]=5; y2[6]=4; - x1[7]=10; x2[7]=10; y1[7]=11; y2[7]=10; - x1[8]=11; x2[8]=9; y1[8]=4; y2[8]=4; - x1[9]=11; x2[9]=11; y1[9]=14; y2[9]=2; - x1[10]=2; x2[10]=0; y1[10]=5; y2[10]=5; - x1[11]=0; x2[11]=0; y1[11]=7; y2[11]=2; - x1[12]=8; x2[12]=8; y1[12]=3; y2[12]=1; - break; - case 175: - x1[0]=14; x2[0]=13; y1[0]=9; y2[0]=9; - x1[1]=4; x2[1]=4; y1[1]=14; y2[1]=6; - x1[2]=9; x2[2]=9; y1[2]=9; y2[2]=5; - x1[3]=11; x2[3]=11; y1[3]=8; y2[3]=7; - x1[4]=0; x2[4]=0; y1[4]=9; y2[4]=4; - x1[5]=8; x2[5]=8; y1[5]=5; y2[5]=2; - x1[6]=8; x2[6]=6; y1[6]=10; y2[6]=10; - x1[7]=13; x2[7]=2; y1[7]=9; y2[7]=9; - x1[8]=0; x2[8]=0; y1[8]=10; y2[8]=0; - x1[9]=12; x2[9]=12; y1[9]=14; y2[9]=11; - x1[10]=5; x2[10]=5; y1[10]=13; y2[10]=7; - x1[11]=14; x2[11]=14; y1[11]=10; y2[11]=0; - x1[12]=7; x2[12]=0; y1[12]=5; y2[12]=5; - break; - case 176: - x1[0]=5; x2[0]=5; y1[0]=10; y2[0]=0; - x1[1]=13; x2[1]=5; y1[1]=0; y2[1]=0; - x1[2]=14; x2[2]=14; y1[2]=5; y2[2]=0; - x1[3]=2; x2[3]=2; y1[3]=13; y2[3]=9; - x1[4]=10; x2[4]=10; y1[4]=7; y2[4]=1; - x1[5]=11; x2[5]=11; y1[5]=13; y2[5]=8; - x1[6]=12; x2[6]=11; y1[6]=2; y2[6]=2; - x1[7]=3; x2[7]=1; y1[7]=0; y2[7]=0; - x1[8]=8; x2[8]=8; y1[8]=13; y2[8]=2; - x1[9]=14; x2[9]=6; y1[9]=8; y2[9]=8; - x1[10]=6; x2[10]=6; y1[10]=14; y2[10]=11; - x1[11]=7; x2[11]=7; y1[11]=14; y2[11]=3; - x1[12]=8; x2[12]=3; y1[12]=4; y2[12]=4; - break; - case 177: - x1[0]=2; x2[0]=0; y1[0]=9; y2[0]=9; - x1[1]=3; x2[1]=3; y1[1]=8; y2[1]=2; - x1[2]=7; x2[2]=7; y1[2]=4; y2[2]=1; - x1[3]=9; x2[3]=1; y1[3]=10; y2[3]=10; - x1[4]=11; x2[4]=3; y1[4]=2; y2[4]=2; - x1[5]=11; x2[5]=11; y1[5]=6; y2[5]=2; - x1[6]=4; x2[6]=4; y1[6]=13; y2[6]=7; - x1[7]=10; x2[7]=10; y1[7]=3; y2[7]=0; - x1[8]=10; x2[8]=2; y1[8]=3; y2[8]=3; - x1[9]=5; x2[9]=1; y1[9]=2; y2[9]=2; - x1[10]=5; x2[10]=5; y1[10]=10; y2[10]=6; - x1[11]=13; x2[11]=7; y1[11]=8; y2[11]=8; - x1[12]=12; x2[12]=6; y1[12]=8; y2[12]=8; - break; - case 178: - x1[0]=14; x2[0]=8; y1[0]=11; y2[0]=11; - x1[1]=10; x2[1]=10; y1[1]=9; y2[1]=3; - x1[2]=1; x2[2]=1; y1[2]=9; y2[2]=1; - x1[3]=13; x2[3]=13; y1[3]=14; y2[3]=9; - x1[4]=0; x2[4]=0; y1[4]=12; y2[4]=9; - x1[5]=12; x2[5]=12; y1[5]=5; y2[5]=1; - x1[6]=8; x2[6]=8; y1[6]=8; y2[6]=3; - x1[7]=0; x2[7]=0; y1[7]=4; y2[7]=0; - x1[8]=11; x2[8]=10; y1[8]=1; y2[8]=1; - x1[9]=2; x2[9]=2; y1[9]=13; y2[9]=3; - x1[10]=14; x2[10]=0; y1[10]=2; y2[10]=2; - x1[11]=9; x2[11]=3; y1[11]=4; y2[11]=4; - x1[12]=10; x2[12]=10; y1[12]=2; y2[12]=0; - break; - case 179: - x1[0]=14; x2[0]=14; y1[0]=13; y2[0]=5; - x1[1]=6; x2[1]=6; y1[1]=3; y2[1]=0; - x1[2]=6; x2[2]=6; y1[2]=13; y2[2]=5; - x1[3]=5; x2[3]=5; y1[3]=14; y2[3]=6; - x1[4]=5; x2[4]=0; y1[4]=8; y2[4]=8; - x1[5]=12; x2[5]=12; y1[5]=10; y2[5]=4; - x1[6]=2; x2[6]=2; y1[6]=5; y2[6]=0; - x1[7]=6; x2[7]=6; y1[7]=4; y2[7]=3; - x1[8]=12; x2[8]=11; y1[8]=1; y2[8]=1; - x1[9]=2; x2[9]=2; y1[9]=7; y2[9]=0; - x1[10]=6; x2[10]=6; y1[10]=9; y2[10]=0; - x1[11]=14; x2[11]=13; y1[11]=2; y2[11]=2; - x1[12]=2; x2[12]=1; y1[12]=7; y2[12]=7; - break; - case 180: - x1[0]=13; x2[0]=13; y1[0]=8; y2[0]=3; - x1[1]=3; x2[1]=3; y1[1]=14; y2[1]=6; - x1[2]=10; x2[2]=10; y1[2]=5; y2[2]=4; - x1[3]=13; x2[3]=5; y1[3]=10; y2[3]=10; - x1[4]=2; x2[4]=2; y1[4]=8; y2[4]=3; - x1[5]=10; x2[5]=6; y1[5]=10; y2[5]=10; - x1[6]=12; x2[6]=12; y1[6]=14; y2[6]=8; - x1[7]=6; x2[7]=6; y1[7]=10; y2[7]=2; - x1[8]=8; x2[8]=4; y1[8]=0; y2[8]=0; - x1[9]=10; x2[9]=8; y1[9]=2; y2[9]=2; - x1[10]=6; x2[10]=5; y1[10]=1; y2[10]=1; - x1[11]=11; x2[11]=11; y1[11]=11; y2[11]=1; - x1[12]=7; x2[12]=5; y1[12]=8; y2[12]=8; - break; - case 181: - x1[0]=13; x2[0]=13; y1[0]=11; y2[0]=7; - x1[1]=13; x2[1]=2; y1[1]=13; y2[1]=13; - x1[2]=11; x2[2]=11; y1[2]=9; y2[2]=3; - x1[3]=6; x2[3]=3; y1[3]=2; y2[3]=2; - x1[4]=9; x2[4]=4; y1[4]=9; y2[4]=9; - x1[5]=13; x2[5]=7; y1[5]=7; y2[5]=7; - x1[6]=14; x2[6]=8; y1[6]=9; y2[6]=9; - x1[7]=9; x2[7]=1; y1[7]=8; y2[7]=8; - x1[8]=11; x2[8]=11; y1[8]=12; y2[8]=8; - x1[9]=6; x2[9]=4; y1[9]=1; y2[9]=1; - x1[10]=14; x2[10]=14; y1[10]=11; y2[10]=7; - x1[11]=13; x2[11]=4; y1[11]=1; y2[11]=1; - x1[12]=5; x2[12]=5; y1[12]=12; y2[12]=0; - break; - case 182: - x1[0]=14; x2[0]=6; y1[0]=4; y2[0]=4; - x1[1]=13; x2[1]=2; y1[1]=12; y2[1]=12; - x1[2]=13; x2[2]=13; y1[2]=13; y2[2]=3; - x1[3]=14; x2[3]=0; y1[3]=0; y2[3]=0; - x1[4]=12; x2[4]=12; y1[4]=12; y2[4]=6; - x1[5]=10; x2[5]=9; y1[5]=11; y2[5]=11; - x1[6]=13; x2[6]=13; y1[6]=7; y2[6]=5; - x1[7]=0; x2[7]=0; y1[7]=8; y2[7]=6; - x1[8]=13; x2[8]=13; y1[8]=4; y2[8]=2; - x1[9]=4; x2[9]=4; y1[9]=11; y2[9]=1; - x1[10]=1; x2[10]=1; y1[10]=11; y2[10]=7; - x1[11]=13; x2[11]=6; y1[11]=13; y2[11]=13; - x1[12]=12; x2[12]=10; y1[12]=5; y2[12]=5; - break; - case 183: - x1[0]=13; x2[0]=1; y1[0]=0; y2[0]=0; - x1[1]=4; x2[1]=4; y1[1]=11; y2[1]=0; - x1[2]=14; x2[2]=5; y1[2]=3; y2[2]=3; - x1[3]=9; x2[3]=9; y1[3]=13; y2[3]=9; - x1[4]=0; x2[4]=0; y1[4]=10; y2[4]=1; - x1[5]=4; x2[5]=4; y1[5]=13; y2[5]=5; - x1[6]=12; x2[6]=0; y1[6]=9; y2[6]=9; - x1[7]=0; x2[7]=0; y1[7]=11; y2[7]=9; - x1[8]=13; x2[8]=1; y1[8]=5; y2[8]=5; - x1[9]=0; x2[9]=0; y1[9]=13; y2[9]=2; - x1[10]=12; x2[10]=10; y1[10]=0; y2[10]=0; - x1[11]=7; x2[11]=7; y1[11]=7; y2[11]=5; - x1[12]=4; x2[12]=2; y1[12]=1; y2[12]=1; - break; - case 184: - x1[0]=5; x2[0]=5; y1[0]=14; y2[0]=7; - x1[1]=6; x2[1]=1; y1[1]=4; y2[1]=4; - x1[2]=13; x2[2]=6; y1[2]=9; y2[2]=9; - x1[3]=8; x2[3]=8; y1[3]=9; y2[3]=0; - x1[4]=5; x2[4]=0; y1[4]=1; y2[4]=1; - x1[5]=6; x2[5]=5; y1[5]=11; y2[5]=11; - x1[6]=11; x2[6]=11; y1[6]=13; y2[6]=12; - x1[7]=3; x2[7]=3; y1[7]=12; y2[7]=3; - x1[8]=11; x2[8]=0; y1[8]=14; y2[8]=14; - x1[9]=14; x2[9]=1; y1[9]=2; y2[9]=2; - x1[10]=13; x2[10]=13; y1[10]=3; y2[10]=0; - x1[11]=14; x2[11]=3; y1[11]=2; y2[11]=2; - x1[12]=14; x2[12]=9; y1[12]=9; y2[12]=9; - break; - case 185: - x1[0]=10; x2[0]=5; y1[0]=2; y2[0]=2; - x1[1]=13; x2[1]=2; y1[1]=3; y2[1]=3; - x1[2]=7; x2[2]=5; y1[2]=10; y2[2]=10; - x1[3]=11; x2[3]=1; y1[3]=3; y2[3]=3; - x1[4]=12; x2[4]=6; y1[4]=5; y2[4]=5; - x1[5]=6; x2[5]=6; y1[5]=8; y2[5]=7; - x1[6]=10; x2[6]=6; y1[6]=3; y2[6]=3; - x1[7]=11; x2[7]=7; y1[7]=10; y2[7]=10; - x1[8]=3; x2[8]=1; y1[8]=5; y2[8]=5; - x1[9]=12; x2[9]=12; y1[9]=10; y2[9]=0; - x1[10]=12; x2[10]=9; y1[10]=12; y2[10]=12; - x1[11]=10; x2[11]=10; y1[11]=11; y2[11]=3; - x1[12]=8; x2[12]=8; y1[12]=9; y2[12]=1; - break; - case 186: - x1[0]=12; x2[0]=0; y1[0]=3; y2[0]=3; - x1[1]=11; x2[1]=11; y1[1]=6; y2[1]=5; - x1[2]=12; x2[2]=2; y1[2]=6; y2[2]=6; - x1[3]=5; x2[3]=1; y1[3]=8; y2[3]=8; - x1[4]=13; x2[4]=6; y1[4]=12; y2[4]=12; - x1[5]=5; x2[5]=4; y1[5]=12; y2[5]=12; - x1[6]=8; x2[6]=3; y1[6]=11; y2[6]=11; - x1[7]=14; x2[7]=7; y1[7]=1; y2[7]=1; - x1[8]=14; x2[8]=6; y1[8]=13; y2[8]=13; - x1[9]=10; x2[9]=9; y1[9]=13; y2[9]=13; - x1[10]=11; x2[10]=4; y1[10]=9; y2[10]=9; - x1[11]=7; x2[11]=5; y1[11]=14; y2[11]=14; - x1[12]=3; x2[12]=2; y1[12]=4; y2[12]=4; - break; - case 187: - x1[0]=13; x2[0]=13; y1[0]=11; y2[0]=3; - x1[1]=8; x2[1]=1; y1[1]=7; y2[1]=7; - x1[2]=6; x2[2]=0; y1[2]=7; y2[2]=7; - x1[3]=8; x2[3]=8; y1[3]=11; y2[3]=0; - x1[4]=7; x2[4]=3; y1[4]=3; y2[4]=3; - x1[5]=3; x2[5]=3; y1[5]=5; y2[5]=3; - x1[6]=11; x2[6]=11; y1[6]=14; y2[6]=5; - x1[7]=11; x2[7]=8; y1[7]=6; y2[7]=6; - x1[8]=8; x2[8]=7; y1[8]=13; y2[8]=13; - x1[9]=8; x2[9]=8; y1[9]=11; y2[9]=1; - x1[10]=8; x2[10]=2; y1[10]=3; y2[10]=3; - x1[11]=11; x2[11]=4; y1[11]=8; y2[11]=8; - x1[12]=14; x2[12]=14; y1[12]=13; y2[12]=7; - break; - case 188: - x1[0]=12; x2[0]=5; y1[0]=4; y2[0]=4; - x1[1]=6; x2[1]=6; y1[1]=11; y2[1]=6; - x1[2]=6; x2[2]=4; y1[2]=2; y2[2]=2; - x1[3]=8; x2[3]=3; y1[3]=1; y2[3]=1; - x1[4]=12; x2[4]=9; y1[4]=6; y2[4]=6; - x1[5]=13; x2[5]=0; y1[5]=4; y2[5]=4; - x1[6]=7; x2[6]=7; y1[6]=8; y2[6]=7; - x1[7]=8; x2[7]=7; y1[7]=8; y2[7]=8; - x1[8]=14; x2[8]=14; y1[8]=13; y2[8]=6; - x1[9]=8; x2[9]=8; y1[9]=10; y2[9]=7; - x1[10]=9; x2[10]=3; y1[10]=7; y2[10]=7; - x1[11]=11; x2[11]=4; y1[11]=3; y2[11]=3; - x1[12]=10; x2[12]=10; y1[12]=11; y2[12]=6; - break; - case 189: - x1[0]=7; x2[0]=7; y1[0]=3; y2[0]=1; - x1[1]=13; x2[1]=12; y1[1]=5; y2[1]=5; - x1[2]=11; x2[2]=11; y1[2]=8; y2[2]=4; - x1[3]=1; x2[3]=1; y1[3]=14; y2[3]=0; - x1[4]=10; x2[4]=0; y1[4]=13; y2[4]=13; - x1[5]=8; x2[5]=7; y1[5]=10; y2[5]=10; - x1[6]=11; x2[6]=4; y1[6]=7; y2[6]=7; - x1[7]=12; x2[7]=1; y1[7]=8; y2[7]=8; - x1[8]=12; x2[8]=5; y1[8]=10; y2[8]=10; - x1[9]=9; x2[9]=5; y1[9]=6; y2[9]=6; - x1[10]=2; x2[10]=0; y1[10]=8; y2[10]=8; - x1[11]=12; x2[11]=12; y1[11]=13; y2[11]=1; - x1[12]=6; x2[12]=6; y1[12]=8; y2[12]=5; - break; - case 190: - x1[0]=6; x2[0]=2; y1[0]=6; y2[0]=6; - x1[1]=5; x2[1]=5; y1[1]=13; y2[1]=11; - x1[2]=4; x2[2]=4; y1[2]=5; y2[2]=0; - x1[3]=12; x2[3]=8; y1[3]=4; y2[3]=4; - x1[4]=4; x2[4]=2; y1[4]=0; y2[4]=0; - x1[5]=13; x2[5]=12; y1[5]=0; y2[5]=0; - x1[6]=3; x2[6]=2; y1[6]=3; y2[6]=3; - x1[7]=3; x2[7]=2; y1[7]=10; y2[7]=10; - x1[8]=11; x2[8]=9; y1[8]=5; y2[8]=5; - x1[9]=14; x2[9]=8; y1[9]=5; y2[9]=5; - x1[10]=14; x2[10]=0; y1[10]=1; y2[10]=1; - x1[11]=10; x2[11]=10; y1[11]=7; y2[11]=4; - x1[12]=9; x2[12]=9; y1[12]=14; y2[12]=13; - break; - case 191: - x1[0]=10; x2[0]=5; y1[0]=11; y2[0]=11; - x1[1]=7; x2[1]=7; y1[1]=6; y2[1]=2; - x1[2]=1; x2[2]=1; y1[2]=10; y2[2]=6; - x1[3]=4; x2[3]=1; y1[3]=3; y2[3]=3; - x1[4]=8; x2[4]=0; y1[4]=7; y2[4]=7; - x1[5]=11; x2[5]=9; y1[5]=7; y2[5]=7; - x1[6]=6; x2[6]=6; y1[6]=14; y2[6]=9; - x1[7]=4; x2[7]=1; y1[7]=1; y2[7]=1; - x1[8]=0; x2[8]=0; y1[8]=8; y2[8]=1; - x1[9]=13; x2[9]=8; y1[9]=8; y2[9]=8; - x1[10]=9; x2[10]=9; y1[10]=6; y2[10]=2; - x1[11]=7; x2[11]=7; y1[11]=13; y2[11]=2; - x1[12]=14; x2[12]=2; y1[12]=8; y2[12]=8; - break; - case 192: - x1[0]=14; x2[0]=1; y1[0]=12; y2[0]=12; - x1[1]=6; x2[1]=0; y1[1]=10; y2[1]=10; - x1[2]=10; x2[2]=0; y1[2]=5; y2[2]=5; - x1[3]=14; x2[3]=12; y1[3]=14; y2[3]=14; - x1[4]=13; x2[4]=0; y1[4]=0; y2[4]=0; - x1[5]=3; x2[5]=3; y1[5]=11; y2[5]=4; - x1[6]=12; x2[6]=4; y1[6]=11; y2[6]=11; - x1[7]=5; x2[7]=5; y1[7]=13; y2[7]=2; - x1[8]=14; x2[8]=3; y1[8]=5; y2[8]=5; - x1[9]=12; x2[9]=12; y1[9]=10; y2[9]=9; - x1[10]=5; x2[10]=2; y1[10]=10; y2[10]=10; - x1[11]=1; x2[11]=1; y1[11]=6; y2[11]=5; - x1[12]=8; x2[12]=8; y1[12]=7; y2[12]=4; - break; - case 193: - x1[0]=6; x2[0]=3; y1[0]=4; y2[0]=4; - x1[1]=6; x2[1]=1; y1[1]=9; y2[1]=9; - x1[2]=2; x2[2]=2; y1[2]=8; y2[2]=0; - x1[3]=6; x2[3]=5; y1[3]=8; y2[3]=8; - x1[4]=2; x2[4]=2; y1[4]=6; y2[4]=3; - x1[5]=1; x2[5]=0; y1[5]=8; y2[5]=8; - x1[6]=12; x2[6]=0; y1[6]=11; y2[6]=11; - x1[7]=12; x2[7]=12; y1[7]=8; y2[7]=3; - x1[8]=10; x2[8]=10; y1[8]=12; y2[8]=10; - x1[9]=13; x2[9]=9; y1[9]=11; y2[9]=11; - x1[10]=4; x2[10]=3; y1[10]=7; y2[10]=7; - x1[11]=14; x2[11]=14; y1[11]=12; y2[11]=0; - x1[12]=7; x2[12]=7; y1[12]=12; y2[12]=6; - break; - case 194: - x1[0]=12; x2[0]=12; y1[0]=12; y2[0]=0; - x1[1]=12; x2[1]=12; y1[1]=14; y2[1]=6; - x1[2]=4; x2[2]=4; y1[2]=13; y2[2]=1; - x1[3]=4; x2[3]=4; y1[3]=11; y2[3]=2; - x1[4]=11; x2[4]=11; y1[4]=1; y2[4]=0; - x1[5]=6; x2[5]=6; y1[5]=7; y2[5]=1; - x1[6]=12; x2[6]=6; y1[6]=0; y2[6]=0; - x1[7]=5; x2[7]=5; y1[7]=7; y2[7]=6; - x1[8]=2; x2[8]=1; y1[8]=12; y2[8]=12; - x1[9]=7; x2[9]=5; y1[9]=3; y2[9]=3; - x1[10]=4; x2[10]=0; y1[10]=8; y2[10]=8; - x1[11]=10; x2[11]=3; y1[11]=13; y2[11]=13; - x1[12]=2; x2[12]=2; y1[12]=6; y2[12]=2; - break; - case 195: - x1[0]=14; x2[0]=10; y1[0]=6; y2[0]=6; - x1[1]=7; x2[1]=6; y1[1]=5; y2[1]=5; - x1[2]=4; x2[2]=3; y1[2]=3; y2[2]=3; - x1[3]=14; x2[3]=8; y1[3]=4; y2[3]=4; - x1[4]=14; x2[4]=1; y1[4]=4; y2[4]=4; - x1[5]=11; x2[5]=10; y1[5]=2; y2[5]=2; - x1[6]=7; x2[6]=7; y1[6]=13; y2[6]=8; - x1[7]=6; x2[7]=6; y1[7]=12; y2[7]=9; - x1[8]=13; x2[8]=0; y1[8]=5; y2[8]=5; - x1[9]=12; x2[9]=12; y1[9]=12; y2[9]=11; - x1[10]=12; x2[10]=12; y1[10]=12; y2[10]=7; - x1[11]=7; x2[11]=1; y1[11]=3; y2[11]=3; - x1[12]=9; x2[12]=3; y1[12]=9; y2[12]=9; - break; - case 196: - x1[0]=12; x2[0]=6; y1[0]=13; y2[0]=13; - x1[1]=13; x2[1]=8; y1[1]=4; y2[1]=4; - x1[2]=3; x2[2]=0; y1[2]=7; y2[2]=7; - x1[3]=3; x2[3]=3; y1[3]=3; y2[3]=2; - x1[4]=7; x2[4]=5; y1[4]=6; y2[4]=6; - x1[5]=11; x2[5]=6; y1[5]=12; y2[5]=12; - x1[6]=12; x2[6]=1; y1[6]=13; y2[6]=13; - x1[7]=13; x2[7]=10; y1[7]=4; y2[7]=4; - x1[8]=9; x2[8]=1; y1[8]=5; y2[8]=5; - x1[9]=12; x2[9]=3; y1[9]=1; y2[9]=1; - x1[10]=0; x2[10]=0; y1[10]=3; y2[10]=0; - x1[11]=11; x2[11]=11; y1[11]=5; y2[11]=2; - x1[12]=12; x2[12]=12; y1[12]=13; y2[12]=4; - break; - case 197: - x1[0]=2; x2[0]=0; y1[0]=6; y2[0]=6; - x1[1]=14; x2[1]=14; y1[1]=11; y2[1]=2; - x1[2]=6; x2[2]=6; y1[2]=9; y2[2]=5; - x1[3]=3; x2[3]=2; y1[3]=14; y2[3]=14; - x1[4]=12; x2[4]=12; y1[4]=14; y2[4]=4; - x1[5]=4; x2[5]=0; y1[5]=5; y2[5]=5; - x1[6]=13; x2[6]=13; y1[6]=12; y2[6]=6; - x1[7]=12; x2[7]=4; y1[7]=4; y2[7]=4; - x1[8]=0; x2[8]=0; y1[8]=10; y2[8]=5; - x1[9]=9; x2[9]=6; y1[9]=10; y2[9]=10; - x1[10]=12; x2[10]=12; y1[10]=13; y2[10]=7; - x1[11]=7; x2[11]=7; y1[11]=3; y2[11]=0; - x1[12]=6; x2[12]=0; y1[12]=1; y2[12]=1; - break; - case 198: - x1[0]=10; x2[0]=0; y1[0]=12; y2[0]=12; - x1[1]=9; x2[1]=5; y1[1]=13; y2[1]=13; - x1[2]=12; x2[2]=2; y1[2]=3; y2[2]=3; - x1[3]=12; x2[3]=4; y1[3]=7; y2[3]=7; - x1[4]=6; x2[4]=4; y1[4]=9; y2[4]=9; - x1[5]=14; x2[5]=5; y1[5]=2; y2[5]=2; - x1[6]=14; x2[6]=3; y1[6]=11; y2[6]=11; - x1[7]=10; x2[7]=10; y1[7]=12; y2[7]=7; - x1[8]=1; x2[8]=1; y1[8]=6; y2[8]=2; - x1[9]=0; x2[9]=0; y1[9]=12; y2[9]=1; - x1[10]=6; x2[10]=6; y1[10]=11; y2[10]=1; - x1[11]=1; x2[11]=1; y1[11]=13; y2[11]=6; - x1[12]=11; x2[12]=7; y1[12]=3; y2[12]=3; - break; - case 199: - x1[0]=0; x2[0]=0; y1[0]=10; y2[0]=6; - x1[1]=7; x2[1]=3; y1[1]=5; y2[1]=5; - x1[2]=3; x2[2]=0; y1[2]=6; y2[2]=6; - x1[3]=3; x2[3]=2; y1[3]=0; y2[3]=0; - x1[4]=0; x2[4]=0; y1[4]=14; y2[4]=3; - x1[5]=12; x2[5]=2; y1[5]=11; y2[5]=11; - x1[6]=10; x2[6]=6; y1[6]=6; y2[6]=6; - x1[7]=14; x2[7]=13; y1[7]=4; y2[7]=4; - x1[8]=11; x2[8]=1; y1[8]=1; y2[8]=1; - x1[9]=7; x2[9]=7; y1[9]=6; y2[9]=0; - x1[10]=13; x2[10]=11; y1[10]=5; y2[10]=5; - x1[11]=6; x2[11]=6; y1[11]=8; y2[11]=2; - x1[12]=12; x2[12]=7; y1[12]=6; y2[12]=6; - break; - case 200: - x1[0]=10; x2[0]=10; y1[0]=2; y2[0]=1; - x1[1]=7; x2[1]=2; y1[1]=10; y2[1]=10; - x1[2]=13; x2[2]=7; y1[2]=10; y2[2]=10; - x1[3]=1; x2[3]=1; y1[3]=3; y2[3]=2; - x1[4]=10; x2[4]=8; y1[4]=11; y2[4]=11; - x1[5]=13; x2[5]=6; y1[5]=10; y2[5]=10; - x1[6]=12; x2[6]=12; y1[6]=12; y2[6]=2; - x1[7]=13; x2[7]=13; y1[7]=8; y2[7]=5; - x1[8]=13; x2[8]=13; y1[8]=11; y2[8]=2; - x1[9]=14; x2[9]=11; y1[9]=1; y2[9]=1; - x1[10]=12; x2[10]=5; y1[10]=9; y2[10]=9; - x1[11]=14; x2[11]=8; y1[11]=10; y2[11]=10; - x1[12]=2; x2[12]=2; y1[12]=12; y2[12]=6; - break; - case 201: - x1[0]=13; x2[0]=7; y1[0]=12; y2[0]=12; - x1[1]=4; x2[1]=2; y1[1]=6; y2[1]=6; - x1[2]=2; x2[2]=2; y1[2]=9; y2[2]=2; - x1[3]=11; x2[3]=1; y1[3]=9; y2[3]=9; - x1[4]=12; x2[4]=12; y1[4]=13; y2[4]=5; - x1[5]=10; x2[5]=10; y1[5]=4; y2[5]=3; - x1[6]=11; x2[6]=11; y1[6]=8; y2[6]=1; - x1[7]=7; x2[7]=6; y1[7]=3; y2[7]=3; - x1[8]=4; x2[8]=1; y1[8]=13; y2[8]=13; - x1[9]=7; x2[9]=3; y1[9]=13; y2[9]=13; - x1[10]=3; x2[10]=3; y1[10]=5; y2[10]=1; - x1[11]=14; x2[11]=1; y1[11]=9; y2[11]=9; - x1[12]=7; x2[12]=2; y1[12]=13; y2[12]=13; - break; - case 202: - x1[0]=1; x2[0]=1; y1[0]=8; y2[0]=0; - x1[1]=12; x2[1]=7; y1[1]=10; y2[1]=10; - x1[2]=0; x2[2]=0; y1[2]=2; y2[2]=1; - x1[3]=2; x2[3]=2; y1[3]=14; y2[3]=12; - x1[4]=10; x2[4]=10; y1[4]=13; y2[4]=11; - x1[5]=2; x2[5]=2; y1[5]=10; y2[5]=6; - x1[6]=3; x2[6]=3; y1[6]=4; y2[6]=0; - x1[7]=13; x2[7]=7; y1[7]=3; y2[7]=3; - x1[8]=13; x2[8]=8; y1[8]=7; y2[8]=7; - x1[9]=14; x2[9]=14; y1[9]=7; y2[9]=6; - x1[10]=14; x2[10]=5; y1[10]=5; y2[10]=5; - x1[11]=6; x2[11]=1; y1[11]=13; y2[11]=13; - x1[12]=12; x2[12]=7; y1[12]=2; y2[12]=2; - break; - case 203: - x1[0]=11; x2[0]=7; y1[0]=14; y2[0]=14; - x1[1]=6; x2[1]=6; y1[1]=9; y2[1]=6; - x1[2]=12; x2[2]=9; y1[2]=9; y2[2]=9; - x1[3]=14; x2[3]=8; y1[3]=7; y2[3]=7; - x1[4]=13; x2[4]=4; y1[4]=5; y2[4]=5; - x1[5]=9; x2[5]=9; y1[5]=6; y2[5]=4; - x1[6]=10; x2[6]=7; y1[6]=5; y2[6]=5; - x1[7]=7; x2[7]=7; y1[7]=7; y2[7]=4; - x1[8]=12; x2[8]=7; y1[8]=11; y2[8]=11; - x1[9]=13; x2[9]=3; y1[9]=14; y2[9]=14; - x1[10]=12; x2[10]=4; y1[10]=2; y2[10]=2; - x1[11]=13; x2[11]=13; y1[11]=7; y2[11]=3; - x1[12]=11; x2[12]=11; y1[12]=8; y2[12]=6; - break; - case 204: - x1[0]=12; x2[0]=4; y1[0]=9; y2[0]=9; - x1[1]=11; x2[1]=11; y1[1]=4; y2[1]=1; - x1[2]=14; x2[2]=7; y1[2]=2; y2[2]=2; - x1[3]=14; x2[3]=0; y1[3]=14; y2[3]=14; - x1[4]=8; x2[4]=8; y1[4]=3; y2[4]=0; - x1[5]=6; x2[5]=6; y1[5]=12; y2[5]=0; - x1[6]=6; x2[6]=6; y1[6]=12; y2[6]=11; - x1[7]=13; x2[7]=9; y1[7]=3; y2[7]=3; - x1[8]=8; x2[8]=8; y1[8]=5; y2[8]=3; - x1[9]=1; x2[9]=1; y1[9]=7; y2[9]=2; - x1[10]=3; x2[10]=3; y1[10]=13; y2[10]=0; - x1[11]=11; x2[11]=10; y1[11]=10; y2[11]=10; - x1[12]=9; x2[12]=0; y1[12]=10; y2[12]=10; - break; - case 205: - x1[0]=14; x2[0]=7; y1[0]=6; y2[0]=6; - x1[1]=3; x2[1]=0; y1[1]=0; y2[1]=0; - x1[2]=14; x2[2]=6; y1[2]=5; y2[2]=5; - x1[3]=11; x2[3]=11; y1[3]=10; y2[3]=7; - x1[4]=12; x2[4]=3; y1[4]=7; y2[4]=7; - x1[5]=14; x2[5]=8; y1[5]=14; y2[5]=14; - x1[6]=6; x2[6]=6; y1[6]=12; y2[6]=8; - x1[7]=12; x2[7]=12; y1[7]=7; y2[7]=6; - x1[8]=11; x2[8]=3; y1[8]=9; y2[8]=9; - x1[9]=13; x2[9]=0; y1[9]=12; y2[9]=12; - x1[10]=3; x2[10]=3; y1[10]=6; y2[10]=0; - x1[11]=13; x2[11]=1; y1[11]=8; y2[11]=8; - x1[12]=7; x2[12]=5; y1[12]=0; y2[12]=0; - break; - case 206: - x1[0]=1; x2[0]=1; y1[0]=12; y2[0]=1; - x1[1]=1; x2[1]=0; y1[1]=7; y2[1]=7; - x1[2]=11; x2[2]=8; y1[2]=13; y2[2]=13; - x1[3]=2; x2[3]=1; y1[3]=5; y2[3]=5; - x1[4]=14; x2[4]=14; y1[4]=12; y2[4]=10; - x1[5]=14; x2[5]=3; y1[5]=6; y2[5]=6; - x1[6]=7; x2[6]=7; y1[6]=11; y2[6]=1; - x1[7]=9; x2[7]=5; y1[7]=14; y2[7]=14; - x1[8]=14; x2[8]=14; y1[8]=4; y2[8]=1; - x1[9]=11; x2[9]=11; y1[9]=7; y2[9]=5; - x1[10]=3; x2[10]=3; y1[10]=6; y2[10]=1; - x1[11]=0; x2[11]=0; y1[11]=9; y2[11]=6; - x1[12]=9; x2[12]=9; y1[12]=8; y2[12]=2; - break; - case 207: - x1[0]=8; x2[0]=6; y1[0]=5; y2[0]=5; - x1[1]=13; x2[1]=13; y1[1]=13; y2[1]=5; - x1[2]=1; x2[2]=1; y1[2]=12; y2[2]=7; - x1[3]=13; x2[3]=3; y1[3]=2; y2[3]=2; - x1[4]=3; x2[4]=3; y1[4]=14; y2[4]=11; - x1[5]=14; x2[5]=12; y1[5]=0; y2[5]=0; - x1[6]=2; x2[6]=2; y1[6]=3; y2[6]=2; - x1[7]=10; x2[7]=2; y1[7]=11; y2[7]=11; - x1[8]=0; x2[8]=0; y1[8]=13; y2[8]=6; - x1[9]=9; x2[9]=9; y1[9]=14; y2[9]=7; - x1[10]=2; x2[10]=2; y1[10]=12; y2[10]=10; - x1[11]=3; x2[11]=3; y1[11]=7; y2[11]=2; - x1[12]=9; x2[12]=7; y1[12]=6; y2[12]=6; - break; - case 208: - x1[0]=14; x2[0]=4; y1[0]=0; y2[0]=0; - x1[1]=14; x2[1]=12; y1[1]=3; y2[1]=3; - x1[2]=1; x2[2]=1; y1[2]=12; y2[2]=5; - x1[3]=0; x2[3]=0; y1[3]=5; y2[3]=0; - x1[4]=13; x2[4]=13; y1[4]=2; y2[4]=1; - x1[5]=4; x2[5]=4; y1[5]=10; y2[5]=2; - x1[6]=14; x2[6]=14; y1[6]=4; y2[6]=0; - x1[7]=13; x2[7]=13; y1[7]=12; y2[7]=4; - x1[8]=8; x2[8]=8; y1[8]=11; y2[8]=3; - x1[9]=4; x2[9]=0; y1[9]=1; y2[9]=1; - x1[10]=10; x2[10]=10; y1[10]=6; y2[10]=4; - x1[11]=6; x2[11]=4; y1[11]=6; y2[11]=6; - x1[12]=5; x2[12]=3; y1[12]=1; y2[12]=1; - break; - case 209: - x1[0]=11; x2[0]=4; y1[0]=11; y2[0]=11; - x1[1]=13; x2[1]=7; y1[1]=9; y2[1]=9; - x1[2]=3; x2[2]=3; y1[2]=10; y2[2]=5; - x1[3]=3; x2[3]=3; y1[3]=9; y2[3]=8; - x1[4]=0; x2[4]=0; y1[4]=9; y2[4]=5; - x1[5]=13; x2[5]=13; y1[5]=4; y2[5]=0; - x1[6]=12; x2[6]=8; y1[6]=8; y2[6]=8; - x1[7]=12; x2[7]=12; y1[7]=11; y2[7]=9; - x1[8]=1; x2[8]=1; y1[8]=14; y2[8]=13; - x1[9]=9; x2[9]=8; y1[9]=1; y2[9]=1; - x1[10]=10; x2[10]=9; y1[10]=7; y2[10]=7; - x1[11]=5; x2[11]=5; y1[11]=4; y2[11]=0; - x1[12]=5; x2[12]=4; y1[12]=5; y2[12]=5; - break; - case 210: - x1[0]=11; x2[0]=1; y1[0]=2; y2[0]=2; - x1[1]=7; x2[1]=7; y1[1]=2; y2[1]=0; - x1[2]=3; x2[2]=3; y1[2]=10; y2[2]=6; - x1[3]=7; x2[3]=7; y1[3]=12; y2[3]=3; - x1[4]=0; x2[4]=0; y1[4]=14; y2[4]=7; - x1[5]=13; x2[5]=13; y1[5]=14; y2[5]=2; - x1[6]=7; x2[6]=7; y1[6]=5; y2[6]=2; - x1[7]=13; x2[7]=3; y1[7]=11; y2[7]=11; - x1[8]=7; x2[8]=7; y1[8]=14; y2[8]=12; - x1[9]=12; x2[9]=12; y1[9]=9; y2[9]=7; - x1[10]=10; x2[10]=10; y1[10]=6; y2[10]=1; - x1[11]=4; x2[11]=4; y1[11]=12; y2[11]=4; - x1[12]=9; x2[12]=9; y1[12]=2; y2[12]=1; - break; - case 211: - x1[0]=12; x2[0]=8; y1[0]=12; y2[0]=12; - x1[1]=13; x2[1]=13; y1[1]=12; y2[1]=10; - x1[2]=7; x2[2]=3; y1[2]=8; y2[2]=8; - x1[3]=13; x2[3]=13; y1[3]=6; y2[3]=5; - x1[4]=9; x2[4]=1; y1[4]=1; y2[4]=1; - x1[5]=13; x2[5]=13; y1[5]=12; y2[5]=9; - x1[6]=11; x2[6]=11; y1[6]=9; y2[6]=7; - x1[7]=11; x2[7]=4; y1[7]=5; y2[7]=5; - x1[8]=6; x2[8]=6; y1[8]=14; y2[8]=7; - x1[9]=5; x2[9]=5; y1[9]=13; y2[9]=3; - x1[10]=6; x2[10]=5; y1[10]=5; y2[10]=5; - x1[11]=12; x2[11]=12; y1[11]=8; y2[11]=0; - x1[12]=8; x2[12]=8; y1[12]=8; y2[12]=6; - break; - case 212: - x1[0]=0; x2[0]=0; y1[0]=11; y2[0]=3; - x1[1]=13; x2[1]=2; y1[1]=7; y2[1]=7; - x1[2]=14; x2[2]=4; y1[2]=9; y2[2]=9; - x1[3]=9; x2[3]=2; y1[3]=13; y2[3]=13; - x1[4]=14; x2[4]=14; y1[4]=8; y2[4]=0; - x1[5]=11; x2[5]=6; y1[5]=4; y2[5]=4; - x1[6]=3; x2[6]=3; y1[6]=1; y2[6]=0; - x1[7]=9; x2[7]=9; y1[7]=11; y2[7]=1; - x1[8]=3; x2[8]=3; y1[8]=10; y2[8]=1; - x1[9]=14; x2[9]=1; y1[9]=6; y2[9]=6; - x1[10]=13; x2[10]=13; y1[10]=14; y2[10]=4; - x1[11]=11; x2[11]=10; y1[11]=5; y2[11]=5; - x1[12]=7; x2[12]=7; y1[12]=9; y2[12]=7; - break; - case 213: - x1[0]=2; x2[0]=2; y1[0]=10; y2[0]=8; - x1[1]=6; x2[1]=3; y1[1]=11; y2[1]=11; - x1[2]=2; x2[2]=0; y1[2]=7; y2[2]=7; - x1[3]=6; x2[3]=6; y1[3]=14; y2[3]=5; - x1[4]=14; x2[4]=10; y1[4]=5; y2[4]=5; - x1[5]=12; x2[5]=0; y1[5]=12; y2[5]=12; - x1[6]=6; x2[6]=4; y1[6]=5; y2[6]=5; - x1[7]=12; x2[7]=0; y1[7]=8; y2[7]=8; - x1[8]=10; x2[8]=10; y1[8]=11; y2[8]=7; - x1[9]=10; x2[9]=10; y1[9]=10; y2[9]=9; - x1[10]=10; x2[10]=6; y1[10]=7; y2[10]=7; - x1[11]=9; x2[11]=4; y1[11]=4; y2[11]=4; - x1[12]=5; x2[12]=4; y1[12]=2; y2[12]=2; - break; - case 214: - x1[0]=14; x2[0]=12; y1[0]=5; y2[0]=5; - x1[1]=4; x2[1]=4; y1[1]=11; y2[1]=5; - x1[2]=4; x2[2]=4; y1[2]=9; y2[2]=5; - x1[3]=11; x2[3]=11; y1[3]=7; y2[3]=0; - x1[4]=8; x2[4]=4; y1[4]=3; y2[4]=3; - x1[5]=5; x2[5]=5; y1[5]=14; y2[5]=3; - x1[6]=14; x2[6]=14; y1[6]=7; y2[6]=1; - x1[7]=7; x2[7]=0; y1[7]=12; y2[7]=12; - x1[8]=9; x2[8]=0; y1[8]=7; y2[8]=7; - x1[9]=11; x2[9]=11; y1[9]=8; y2[9]=3; - x1[10]=9; x2[10]=0; y1[10]=6; y2[10]=6; - x1[11]=12; x2[11]=1; y1[11]=14; y2[11]=14; - x1[12]=10; x2[12]=10; y1[12]=12; y2[12]=9; - break; - case 215: - x1[0]=13; x2[0]=13; y1[0]=9; y2[0]=7; - x1[1]=12; x2[1]=2; y1[1]=5; y2[1]=5; - x1[2]=6; x2[2]=3; y1[2]=5; y2[2]=5; - x1[3]=3; x2[3]=3; y1[3]=14; y2[3]=9; - x1[4]=8; x2[4]=8; y1[4]=11; y2[4]=6; - x1[5]=7; x2[5]=0; y1[5]=9; y2[5]=9; - x1[6]=9; x2[6]=9; y1[6]=14; y2[6]=10; - x1[7]=12; x2[7]=12; y1[7]=11; y2[7]=5; - x1[8]=10; x2[8]=10; y1[8]=6; y2[8]=3; - x1[9]=10; x2[9]=10; y1[9]=4; y2[9]=2; - x1[10]=5; x2[10]=1; y1[10]=0; y2[10]=0; - x1[11]=4; x2[11]=4; y1[11]=12; y2[11]=9; - x1[12]=9; x2[12]=9; y1[12]=8; y2[12]=3; - break; - case 216: - x1[0]=14; x2[0]=14; y1[0]=3; y2[0]=0; - x1[1]=10; x2[1]=2; y1[1]=13; y2[1]=13; - x1[2]=4; x2[2]=4; y1[2]=7; y2[2]=1; - x1[3]=8; x2[3]=8; y1[3]=12; y2[3]=6; - x1[4]=3; x2[4]=3; y1[4]=4; y2[4]=2; - x1[5]=8; x2[5]=8; y1[5]=8; y2[5]=5; - x1[6]=6; x2[6]=0; y1[6]=9; y2[6]=9; - x1[7]=14; x2[7]=9; y1[7]=5; y2[7]=5; - x1[8]=5; x2[8]=3; y1[8]=14; y2[8]=14; - x1[9]=6; x2[9]=6; y1[9]=13; y2[9]=9; - x1[10]=1; x2[10]=1; y1[10]=10; y2[10]=2; - x1[11]=4; x2[11]=4; y1[11]=11; y2[11]=8; - x1[12]=10; x2[12]=5; y1[12]=5; y2[12]=5; - break; - case 217: - x1[0]=12; x2[0]=7; y1[0]=5; y2[0]=5; - x1[1]=4; x2[1]=4; y1[1]=10; y2[1]=8; - x1[2]=9; x2[2]=9; y1[2]=13; y2[2]=3; - x1[3]=14; x2[3]=13; y1[3]=13; y2[3]=13; - x1[4]=0; x2[4]=0; y1[4]=3; y2[4]=2; - x1[5]=10; x2[5]=8; y1[5]=12; y2[5]=12; - x1[6]=7; x2[6]=7; y1[6]=14; y2[6]=13; - x1[7]=13; x2[7]=13; y1[7]=14; y2[7]=8; - x1[8]=13; x2[8]=4; y1[8]=7; y2[8]=7; - x1[9]=9; x2[9]=4; y1[9]=5; y2[9]=5; - x1[10]=6; x2[10]=0; y1[10]=5; y2[10]=5; - x1[11]=7; x2[11]=1; y1[11]=9; y2[11]=9; - x1[12]=0; x2[12]=0; y1[12]=13; y2[12]=7; - break; - case 218: - x1[0]=14; x2[0]=14; y1[0]=5; y2[0]=3; - x1[1]=8; x2[1]=8; y1[1]=11; y2[1]=8; - x1[2]=6; x2[2]=3; y1[2]=3; y2[2]=3; - x1[3]=14; x2[3]=13; y1[3]=10; y2[3]=10; - x1[4]=7; x2[4]=1; y1[4]=7; y2[4]=7; - x1[5]=6; x2[5]=2; y1[5]=0; y2[5]=0; - x1[6]=10; x2[6]=4; y1[6]=0; y2[6]=0; - x1[7]=13; x2[7]=3; y1[7]=8; y2[7]=8; - x1[8]=12; x2[8]=11; y1[8]=4; y2[8]=4; - x1[9]=8; x2[9]=0; y1[9]=6; y2[9]=6; - x1[10]=11; x2[10]=0; y1[10]=8; y2[10]=8; - x1[11]=10; x2[11]=10; y1[11]=9; y2[11]=2; - x1[12]=8; x2[12]=6; y1[12]=6; y2[12]=6; - break; - case 219: - x1[0]=2; x2[0]=2; y1[0]=10; y2[0]=2; - x1[1]=1; x2[1]=1; y1[1]=6; y2[1]=0; - x1[2]=5; x2[2]=5; y1[2]=13; y2[2]=1; - x1[3]=12; x2[3]=5; y1[3]=2; y2[3]=2; - x1[4]=7; x2[4]=7; y1[4]=14; y2[4]=7; - x1[5]=13; x2[5]=11; y1[5]=12; y2[5]=12; - x1[6]=8; x2[6]=5; y1[6]=4; y2[6]=4; - x1[7]=1; x2[7]=1; y1[7]=11; y2[7]=9; - x1[8]=7; x2[8]=7; y1[8]=10; y2[8]=0; - x1[9]=7; x2[9]=4; y1[9]=2; y2[9]=2; - x1[10]=4; x2[10]=4; y1[10]=11; y2[10]=7; - x1[11]=12; x2[11]=2; y1[11]=10; y2[11]=10; - x1[12]=14; x2[12]=14; y1[12]=12; y2[12]=5; - break; - case 220: - x1[0]=14; x2[0]=0; y1[0]=9; y2[0]=9; - x1[1]=13; x2[1]=10; y1[1]=12; y2[1]=12; - x1[2]=1; x2[2]=1; y1[2]=1; y2[2]=0; - x1[3]=3; x2[3]=1; y1[3]=11; y2[3]=11; - x1[4]=12; x2[4]=12; y1[4]=14; y2[4]=5; - x1[5]=5; x2[5]=3; y1[5]=0; y2[5]=0; - x1[6]=7; x2[6]=7; y1[6]=5; y2[6]=3; - x1[7]=8; x2[7]=8; y1[7]=8; y2[7]=2; - x1[8]=6; x2[8]=4; y1[8]=10; y2[8]=10; - x1[9]=11; x2[9]=11; y1[9]=13; y2[9]=3; - x1[10]=12; x2[10]=11; y1[10]=11; y2[10]=11; - x1[11]=10; x2[11]=2; y1[11]=8; y2[11]=8; - x1[12]=11; x2[12]=11; y1[12]=12; y2[12]=2; - break; - case 221: - x1[0]=10; x2[0]=3; y1[0]=3; y2[0]=3; - x1[1]=3; x2[1]=3; y1[1]=14; y2[1]=13; - x1[2]=7; x2[2]=6; y1[2]=1; y2[2]=1; - x1[3]=10; x2[3]=10; y1[3]=14; y2[3]=1; - x1[4]=10; x2[4]=8; y1[4]=10; y2[4]=10; - x1[5]=2; x2[5]=2; y1[5]=9; y2[5]=8; - x1[6]=1; x2[6]=0; y1[6]=3; y2[6]=3; - x1[7]=4; x2[7]=0; y1[7]=10; y2[7]=10; - x1[8]=12; x2[8]=4; y1[8]=10; y2[8]=10; - x1[9]=10; x2[9]=10; y1[9]=11; y2[9]=8; - x1[10]=9; x2[10]=2; y1[10]=14; y2[10]=14; - x1[11]=14; x2[11]=2; y1[11]=9; y2[11]=9; - x1[12]=11; x2[12]=6; y1[12]=0; y2[12]=0; - break; - case 222: - x1[0]=12; x2[0]=12; y1[0]=9; y2[0]=0; - x1[1]=4; x2[1]=4; y1[1]=6; y2[1]=2; - x1[2]=11; x2[2]=0; y1[2]=4; y2[2]=4; - x1[3]=11; x2[3]=11; y1[3]=12; y2[3]=0; - x1[4]=14; x2[4]=3; y1[4]=8; y2[4]=8; - x1[5]=5; x2[5]=4; y1[5]=3; y2[5]=3; - x1[6]=14; x2[6]=14; y1[6]=14; y2[6]=1; - x1[7]=10; x2[7]=10; y1[7]=6; y2[7]=0; - x1[8]=9; x2[8]=9; y1[8]=11; y2[8]=5; - x1[9]=13; x2[9]=1; y1[9]=3; y2[9]=3; - x1[10]=4; x2[10]=4; y1[10]=11; y2[10]=6; - x1[11]=12; x2[11]=4; y1[11]=6; y2[11]=6; - x1[12]=13; x2[12]=13; y1[12]=14; y2[12]=5; - break; - case 223: - x1[0]=10; x2[0]=5; y1[0]=6; y2[0]=6; - x1[1]=3; x2[1]=3; y1[1]=8; y2[1]=7; - x1[2]=13; x2[2]=13; y1[2]=10; y2[2]=7; - x1[3]=9; x2[3]=9; y1[3]=5; y2[3]=3; - x1[4]=8; x2[4]=2; y1[4]=2; y2[4]=2; - x1[5]=8; x2[5]=2; y1[5]=7; y2[5]=7; - x1[6]=10; x2[6]=10; y1[6]=10; y2[6]=1; - x1[7]=11; x2[7]=2; y1[7]=0; y2[7]=0; - x1[8]=1; x2[8]=1; y1[8]=14; y2[8]=3; - x1[9]=7; x2[9]=7; y1[9]=14; y2[9]=8; - x1[10]=3; x2[10]=3; y1[10]=14; y2[10]=12; - x1[11]=13; x2[11]=13; y1[11]=7; y2[11]=1; - x1[12]=11; x2[12]=10; y1[12]=3; y2[12]=3; - break; - case 224: - x1[0]=8; x2[0]=0; y1[0]=9; y2[0]=9; - x1[1]=3; x2[1]=3; y1[1]=8; y2[1]=0; - x1[2]=13; x2[2]=6; y1[2]=11; y2[2]=11; - x1[3]=10; x2[3]=2; y1[3]=9; y2[3]=9; - x1[4]=10; x2[4]=7; y1[4]=14; y2[4]=14; - x1[5]=14; x2[5]=5; y1[5]=6; y2[5]=6; - x1[6]=13; x2[6]=8; y1[6]=14; y2[6]=14; - x1[7]=0; x2[7]=0; y1[7]=8; y2[7]=0; - x1[8]=13; x2[8]=9; y1[8]=13; y2[8]=13; - x1[9]=14; x2[9]=14; y1[9]=14; y2[9]=11; - x1[10]=12; x2[10]=4; y1[10]=14; y2[10]=14; - x1[11]=14; x2[11]=3; y1[11]=10; y2[11]=10; - x1[12]=14; x2[12]=12; y1[12]=10; y2[12]=10; - break; - case 225: - x1[0]=5; x2[0]=5; y1[0]=10; y2[0]=2; - x1[1]=9; x2[1]=9; y1[1]=4; y2[1]=0; - x1[2]=12; x2[2]=10; y1[2]=4; y2[2]=4; - x1[3]=9; x2[3]=9; y1[3]=9; y2[3]=6; - x1[4]=13; x2[4]=0; y1[4]=3; y2[4]=3; - x1[5]=8; x2[5]=0; y1[5]=10; y2[5]=10; - x1[6]=5; x2[6]=4; y1[6]=4; y2[6]=4; - x1[7]=14; x2[7]=8; y1[7]=0; y2[7]=0; - x1[8]=3; x2[8]=1; y1[8]=7; y2[8]=7; - x1[9]=9; x2[9]=9; y1[9]=12; y2[9]=8; - x1[10]=11; x2[10]=8; y1[10]=7; y2[10]=7; - x1[11]=9; x2[11]=8; y1[11]=0; y2[11]=0; - x1[12]=6; x2[12]=5; y1[12]=10; y2[12]=10; - break; - case 226: - x1[0]=14; x2[0]=4; y1[0]=10; y2[0]=10; - x1[1]=7; x2[1]=7; y1[1]=14; y2[1]=6; - x1[2]=14; x2[2]=9; y1[2]=8; y2[2]=8; - x1[3]=1; x2[3]=1; y1[3]=13; y2[3]=11; - x1[4]=8; x2[4]=8; y1[4]=4; y2[4]=2; - x1[5]=11; x2[5]=8; y1[5]=9; y2[5]=9; - x1[6]=4; x2[6]=2; y1[6]=3; y2[6]=3; - x1[7]=14; x2[7]=6; y1[7]=1; y2[7]=1; - x1[8]=7; x2[8]=7; y1[8]=7; y2[8]=1; - x1[9]=10; x2[9]=10; y1[9]=10; y2[9]=4; - x1[10]=5; x2[10]=4; y1[10]=13; y2[10]=13; - x1[11]=7; x2[11]=7; y1[11]=13; y2[11]=4; - x1[12]=13; x2[12]=9; y1[12]=2; y2[12]=2; - break; - case 227: - x1[0]=13; x2[0]=9; y1[0]=4; y2[0]=4; - x1[1]=4; x2[1]=3; y1[1]=6; y2[1]=6; - x1[2]=12; x2[2]=12; y1[2]=10; y2[2]=1; - x1[3]=9; x2[3]=3; y1[3]=13; y2[3]=13; - x1[4]=10; x2[4]=10; y1[4]=6; y2[4]=2; - x1[5]=9; x2[5]=9; y1[5]=5; y2[5]=0; - x1[6]=14; x2[6]=0; y1[6]=5; y2[6]=5; - x1[7]=14; x2[7]=11; y1[7]=7; y2[7]=7; - x1[8]=11; x2[8]=11; y1[8]=10; y2[8]=3; - x1[9]=14; x2[9]=14; y1[9]=5; y2[9]=1; - x1[10]=7; x2[10]=7; y1[10]=9; y2[10]=1; - x1[11]=6; x2[11]=4; y1[11]=3; y2[11]=3; - x1[12]=10; x2[12]=10; y1[12]=14; y2[12]=11; - break; - case 228: - x1[0]=14; x2[0]=1; y1[0]=3; y2[0]=3; - x1[1]=11; x2[1]=11; y1[1]=11; y2[1]=10; - x1[2]=8; x2[2]=1; y1[2]=0; y2[2]=0; - x1[3]=11; x2[3]=7; y1[3]=12; y2[3]=12; - x1[4]=1; x2[4]=1; y1[4]=13; y2[4]=4; - x1[5]=5; x2[5]=5; y1[5]=8; y2[5]=0; - x1[6]=13; x2[6]=5; y1[6]=3; y2[6]=3; - x1[7]=14; x2[7]=11; y1[7]=3; y2[7]=3; - x1[8]=4; x2[8]=0; y1[8]=7; y2[8]=7; - x1[9]=14; x2[9]=14; y1[9]=12; y2[9]=11; - x1[10]=10; x2[10]=10; y1[10]=8; y2[10]=0; - x1[11]=13; x2[11]=13; y1[11]=11; y2[11]=10; - x1[12]=10; x2[12]=10; y1[12]=13; y2[12]=12; - break; - case 229: - x1[0]=11; x2[0]=9; y1[0]=11; y2[0]=11; - x1[1]=9; x2[1]=3; y1[1]=0; y2[1]=0; - x1[2]=11; x2[2]=5; y1[2]=12; y2[2]=12; - x1[3]=8; x2[3]=6; y1[3]=0; y2[3]=0; - x1[4]=3; x2[4]=3; y1[4]=6; y2[4]=3; - x1[5]=11; x2[5]=11; y1[5]=9; y2[5]=4; - x1[6]=8; x2[6]=6; y1[6]=13; y2[6]=13; - x1[7]=14; x2[7]=2; y1[7]=10; y2[7]=10; - x1[8]=6; x2[8]=3; y1[8]=6; y2[8]=6; - x1[9]=14; x2[9]=11; y1[9]=14; y2[9]=14; - x1[10]=2; x2[10]=2; y1[10]=11; y2[10]=8; - x1[11]=1; x2[11]=1; y1[11]=14; y2[11]=10; - x1[12]=9; x2[12]=9; y1[12]=12; y2[12]=2; - break; - case 230: - x1[0]=12; x2[0]=0; y1[0]=6; y2[0]=6; - x1[1]=11; x2[1]=10; y1[1]=0; y2[1]=0; - x1[2]=10; x2[2]=10; y1[2]=8; y2[2]=6; - x1[3]=2; x2[3]=1; y1[3]=2; y2[3]=2; - x1[4]=3; x2[4]=3; y1[4]=14; y2[4]=7; - x1[5]=14; x2[5]=2; y1[5]=0; y2[5]=0; - x1[6]=11; x2[6]=3; y1[6]=12; y2[6]=12; - x1[7]=5; x2[7]=5; y1[7]=14; y2[7]=5; - x1[8]=10; x2[8]=10; y1[8]=9; y2[8]=0; - x1[9]=11; x2[9]=11; y1[9]=13; y2[9]=1; - x1[10]=1; x2[10]=1; y1[10]=12; y2[10]=0; - x1[11]=5; x2[11]=4; y1[11]=14; y2[11]=14; - x1[12]=2; x2[12]=2; y1[12]=14; y2[12]=11; - break; - case 231: - x1[0]=9; x2[0]=9; y1[0]=14; y2[0]=6; - x1[1]=6; x2[1]=6; y1[1]=10; y2[1]=8; - x1[2]=6; x2[2]=2; y1[2]=8; y2[2]=8; - x1[3]=7; x2[3]=5; y1[3]=13; y2[3]=13; - x1[4]=13; x2[4]=3; y1[4]=6; y2[4]=6; - x1[5]=7; x2[5]=7; y1[5]=2; y2[5]=1; - x1[6]=8; x2[6]=8; y1[6]=14; y2[6]=11; - x1[7]=11; x2[7]=11; y1[7]=11; y2[7]=0; - x1[8]=8; x2[8]=7; y1[8]=2; y2[8]=2; - x1[9]=9; x2[9]=1; y1[9]=4; y2[9]=4; - x1[10]=2; x2[10]=2; y1[10]=13; y2[10]=8; - x1[11]=10; x2[11]=0; y1[11]=0; y2[11]=0; - x1[12]=3; x2[12]=3; y1[12]=10; y2[12]=3; - break; - case 232: - x1[0]=13; x2[0]=4; y1[0]=12; y2[0]=12; - x1[1]=4; x2[1]=0; y1[1]=0; y2[1]=0; - x1[2]=0; x2[2]=0; y1[2]=12; y2[2]=6; - x1[3]=7; x2[3]=5; y1[3]=12; y2[3]=12; - x1[4]=4; x2[4]=4; y1[4]=10; y2[4]=6; - x1[5]=14; x2[5]=14; y1[5]=4; y2[5]=2; - x1[6]=10; x2[6]=2; y1[6]=10; y2[6]=10; - x1[7]=6; x2[7]=6; y1[7]=7; y2[7]=3; - x1[8]=13; x2[8]=13; y1[8]=9; y2[8]=6; - x1[9]=5; x2[9]=3; y1[9]=2; y2[9]=2; - x1[10]=13; x2[10]=13; y1[10]=10; y2[10]=0; - x1[11]=10; x2[11]=6; y1[11]=8; y2[11]=8; - x1[12]=10; x2[12]=3; y1[12]=11; y2[12]=11; - break; - case 233: - x1[0]=14; x2[0]=5; y1[0]=0; y2[0]=0; - x1[1]=2; x2[1]=2; y1[1]=14; y2[1]=0; - x1[2]=6; x2[2]=6; y1[2]=12; y2[2]=2; - x1[3]=11; x2[3]=9; y1[3]=0; y2[3]=0; - x1[4]=3; x2[4]=0; y1[4]=10; y2[4]=10; - x1[5]=10; x2[5]=10; y1[5]=10; y2[5]=0; - x1[6]=12; x2[6]=12; y1[6]=7; y2[6]=3; - x1[7]=9; x2[7]=9; y1[7]=13; y2[7]=4; - x1[8]=5; x2[8]=5; y1[8]=11; y2[8]=2; - x1[9]=0; x2[9]=0; y1[9]=12; y2[9]=3; - x1[10]=9; x2[10]=2; y1[10]=12; y2[10]=12; - x1[11]=1; x2[11]=1; y1[11]=9; y2[11]=0; - x1[12]=1; x2[12]=1; y1[12]=14; y2[12]=9; - break; - case 234: - x1[0]=10; x2[0]=10; y1[0]=14; y2[0]=10; - x1[1]=5; x2[1]=5; y1[1]=14; y2[1]=8; - x1[2]=4; x2[2]=4; y1[2]=11; y2[2]=10; - x1[3]=7; x2[3]=7; y1[3]=4; y2[3]=2; - x1[4]=12; x2[4]=11; y1[4]=13; y2[4]=13; - x1[5]=13; x2[5]=9; y1[5]=7; y2[5]=7; - x1[6]=1; x2[6]=1; y1[6]=10; y2[6]=9; - x1[7]=6; x2[7]=5; y1[7]=7; y2[7]=7; - x1[8]=5; x2[8]=5; y1[8]=8; y2[8]=4; - x1[9]=11; x2[9]=5; y1[9]=4; y2[9]=4; - x1[10]=13; x2[10]=13; y1[10]=2; y2[10]=0; - x1[11]=7; x2[11]=1; y1[11]=4; y2[11]=4; - x1[12]=10; x2[12]=1; y1[12]=5; y2[12]=5; - break; - case 235: - x1[0]=3; x2[0]=3; y1[0]=7; y2[0]=1; - x1[1]=12; x2[1]=8; y1[1]=6; y2[1]=6; - x1[2]=11; x2[2]=8; y1[2]=11; y2[2]=11; - x1[3]=10; x2[3]=9; y1[3]=12; y2[3]=12; - x1[4]=9; x2[4]=9; y1[4]=12; y2[4]=5; - x1[5]=14; x2[5]=6; y1[5]=6; y2[5]=6; - x1[6]=4; x2[6]=4; y1[6]=6; y2[6]=3; - x1[7]=5; x2[7]=5; y1[7]=12; y2[7]=5; - x1[8]=14; x2[8]=14; y1[8]=8; y2[8]=6; - x1[9]=10; x2[9]=7; y1[9]=9; y2[9]=9; - x1[10]=3; x2[10]=3; y1[10]=11; y2[10]=10; - x1[11]=14; x2[11]=9; y1[11]=0; y2[11]=0; - x1[12]=1; x2[12]=1; y1[12]=11; y2[12]=3; - break; - case 236: - x1[0]=13; x2[0]=11; y1[0]=14; y2[0]=14; - x1[1]=3; x2[1]=1; y1[1]=12; y2[1]=12; - x1[2]=14; x2[2]=2; y1[2]=14; y2[2]=14; - x1[3]=3; x2[3]=3; y1[3]=8; y2[3]=6; - x1[4]=12; x2[4]=6; y1[4]=12; y2[4]=12; - x1[5]=14; x2[5]=0; y1[5]=6; y2[5]=6; - x1[6]=14; x2[6]=9; y1[6]=3; y2[6]=3; - x1[7]=2; x2[7]=0; y1[7]=0; y2[7]=0; - x1[8]=8; x2[8]=3; y1[8]=7; y2[8]=7; - x1[9]=3; x2[9]=3; y1[9]=14; y2[9]=3; - x1[10]=11; x2[10]=11; y1[10]=14; y2[10]=1; - x1[11]=7; x2[11]=7; y1[11]=9; y2[11]=8; - x1[12]=7; x2[12]=7; y1[12]=13; y2[12]=12; - break; - case 237: - x1[0]=14; x2[0]=3; y1[0]=14; y2[0]=14; - x1[1]=3; x2[1]=3; y1[1]=9; y2[1]=6; - x1[2]=14; x2[2]=9; y1[2]=7; y2[2]=7; - x1[3]=4; x2[3]=3; y1[3]=2; y2[3]=2; - x1[4]=10; x2[4]=10; y1[4]=11; y2[4]=2; - x1[5]=14; x2[5]=4; y1[5]=13; y2[5]=13; - x1[6]=3; x2[6]=3; y1[6]=14; y2[6]=2; - x1[7]=4; x2[7]=4; y1[7]=8; y2[7]=1; - x1[8]=14; x2[8]=2; y1[8]=6; y2[8]=6; - x1[9]=14; x2[9]=10; y1[9]=13; y2[9]=13; - x1[10]=5; x2[10]=5; y1[10]=6; y2[10]=2; - x1[11]=6; x2[11]=1; y1[11]=11; y2[11]=11; - x1[12]=12; x2[12]=0; y1[12]=14; y2[12]=14; - break; - case 238: - x1[0]=14; x2[0]=4; y1[0]=12; y2[0]=12; - x1[1]=6; x2[1]=6; y1[1]=14; y2[1]=13; - x1[2]=11; x2[2]=3; y1[2]=8; y2[2]=8; - x1[3]=5; x2[3]=5; y1[3]=10; y2[3]=1; - x1[4]=11; x2[4]=1; y1[4]=5; y2[4]=5; - x1[5]=7; x2[5]=4; y1[5]=0; y2[5]=0; - x1[6]=10; x2[6]=9; y1[6]=3; y2[6]=3; - x1[7]=12; x2[7]=12; y1[7]=8; y2[7]=6; - x1[8]=11; x2[8]=1; y1[8]=6; y2[8]=6; - x1[9]=13; x2[9]=5; y1[9]=8; y2[9]=8; - x1[10]=1; x2[10]=1; y1[10]=12; y2[10]=8; - x1[11]=0; x2[11]=0; y1[11]=8; y2[11]=4; - x1[12]=8; x2[12]=8; y1[12]=9; y2[12]=8; - break; - case 239: - x1[0]=8; x2[0]=4; y1[0]=14; y2[0]=14; - x1[1]=5; x2[1]=5; y1[1]=13; y2[1]=10; - x1[2]=9; x2[2]=0; y1[2]=4; y2[2]=4; - x1[3]=10; x2[3]=7; y1[3]=11; y2[3]=11; - x1[4]=11; x2[4]=11; y1[4]=9; y2[4]=6; - x1[5]=14; x2[5]=1; y1[5]=5; y2[5]=5; - x1[6]=12; x2[6]=4; y1[6]=8; y2[6]=8; - x1[7]=0; x2[7]=0; y1[7]=11; y2[7]=4; - x1[8]=1; x2[8]=1; y1[8]=10; y2[8]=4; - x1[9]=12; x2[9]=7; y1[9]=4; y2[9]=4; - x1[10]=10; x2[10]=9; y1[10]=9; y2[10]=9; - x1[11]=12; x2[11]=7; y1[11]=3; y2[11]=3; - x1[12]=2; x2[12]=2; y1[12]=10; y2[12]=7; - break; - case 240: - x1[0]=6; x2[0]=6; y1[0]=13; y2[0]=8; - x1[1]=2; x2[1]=2; y1[1]=6; y2[1]=0; - x1[2]=6; x2[2]=6; y1[2]=12; y2[2]=4; - x1[3]=0; x2[3]=0; y1[3]=11; y2[3]=7; - x1[4]=4; x2[4]=4; y1[4]=6; y2[4]=0; - x1[5]=3; x2[5]=2; y1[5]=11; y2[5]=11; - x1[6]=8; x2[6]=0; y1[6]=11; y2[6]=11; - x1[7]=7; x2[7]=7; y1[7]=14; y2[7]=10; - x1[8]=12; x2[8]=12; y1[8]=5; y2[8]=0; - x1[9]=14; x2[9]=14; y1[9]=14; y2[9]=2; - x1[10]=2; x2[10]=2; y1[10]=13; y2[10]=5; - x1[11]=12; x2[11]=12; y1[11]=14; y2[11]=1; - x1[12]=14; x2[12]=0; y1[12]=13; y2[12]=13; - break; - case 241: - x1[0]=11; x2[0]=6; y1[0]=8; y2[0]=8; - x1[1]=12; x2[1]=12; y1[1]=12; y2[1]=3; - x1[2]=11; x2[2]=6; y1[2]=6; y2[2]=6; - x1[3]=14; x2[3]=7; y1[3]=0; y2[3]=0; - x1[4]=7; x2[4]=7; y1[4]=11; y2[4]=2; - x1[5]=6; x2[5]=6; y1[5]=11; y2[5]=0; - x1[6]=12; x2[6]=1; y1[6]=4; y2[6]=4; - x1[7]=11; x2[7]=1; y1[7]=13; y2[7]=13; - x1[8]=5; x2[8]=3; y1[8]=7; y2[8]=7; - x1[9]=14; x2[9]=14; y1[9]=9; y2[9]=8; - x1[10]=14; x2[10]=12; y1[10]=1; y2[10]=1; - x1[11]=8; x2[11]=2; y1[11]=6; y2[11]=6; - x1[12]=6; x2[12]=6; y1[12]=12; y2[12]=7; - break; - case 242: - x1[0]=7; x2[0]=7; y1[0]=10; y2[0]=5; - x1[1]=13; x2[1]=13; y1[1]=8; y2[1]=2; - x1[2]=9; x2[2]=8; y1[2]=11; y2[2]=11; - x1[3]=8; x2[3]=8; y1[3]=7; y2[3]=5; - x1[4]=2; x2[4]=2; y1[4]=9; y2[4]=0; - x1[5]=1; x2[5]=0; y1[5]=9; y2[5]=9; - x1[6]=11; x2[6]=2; y1[6]=6; y2[6]=6; - x1[7]=3; x2[7]=0; y1[7]=12; y2[7]=12; - x1[8]=13; x2[8]=7; y1[8]=4; y2[8]=4; - x1[9]=13; x2[9]=13; y1[9]=6; y2[9]=3; - x1[10]=11; x2[10]=1; y1[10]=10; y2[10]=10; - x1[11]=13; x2[11]=13; y1[11]=9; y2[11]=0; - x1[12]=3; x2[12]=3; y1[12]=10; y2[12]=0; - break; - } -}}} diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 03483a2a8..e3f9dd0f3 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -55,6 +55,9 @@ #define MAX_EXAMPLES_IN_MODEL 500 #define MEASURES_PER_CLASSIFIER 13 #define SCALE_STEP 1.2 +#define ENSEMBLE_THRESHOLD 0.5 +#define VARIANCE_THRESHOLD 0.5 +#define GRIDSIZE 15 #define DOWNSCALE_MODE INTER_LINEAR #define BLUR_AS_VADIM #undef CLOSED_LOOP @@ -84,10 +87,8 @@ using namespace tld; * ?10. all in one class * 11. group decls logically, order of statements * 12. not v=vector(n), but assign(n,0) - * -->14. TLDEnsembleClassifier * 16. loops limits * 17. inner scope loops - * 18. classify in TLDEnsembleClassifier * 19. var checker * 20. NCC using plain loops * 21. precompute offset @@ -145,7 +146,7 @@ protected: Ptr model; void computeIntegralImages(const Mat& img,Mat_& intImgP,Mat_& intImgP2){integral(img,intImgP,intImgP2,CV_64F);} inline bool patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size); - bool ensembleClassifier(const uchar* data,int rowstep){return ensembleClassifierNum(data,rowstep)>0.5;} + bool ensembleClassifier(const uchar* data,int rowstep){return ensembleClassifierNum(data,rowstep)>ENSEMBLE_THRESHOLD;} double ensembleClassifierNum(const uchar* data,int rowstep); TrackerTLD::Params params_; }; @@ -417,9 +418,7 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ getClosestN(scanGrid,Rect2d(boundingBox.x/scale,boundingBox.y/scale,boundingBox.width/scale,boundingBox.height/scale),10,closest); Mat_ blurredPatch(minSize); - for(int i=0,howMany=TLDEnsembleClassifier::getMaxOrdinal();i& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size){ - return variance(intImgP,intImgP2,Rect(pt.x,pt.y,size.width,size.height)) >= 0.5*originalVariance; + return variance(intImgP,intImgP2,Rect(pt.x,pt.y,size.width,size.height)) >= VARIANCE_THRESHOLD*originalVariance; } double TLDDetector::ensembleClassifierNum(const uchar* data,int rowstep){ @@ -694,7 +693,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector >& eForM p+=classifiers[i].posteriorProbability(eForEnsemble[k].data,(int)eForEnsemble[k].step[0]); } p/=classifiers.size(); - if((p>0.5)!=isPositive){ + if((p>ENSEMBLE_THRESHOLD)!=isPositive){ if(isPositive){ positiveIntoEnsemble++; }else{ diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index c575105ef..a4576c690 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -61,7 +61,7 @@ namespace cv {namespace tld clock_t start;float milisec=0.0;\ start=clock();{a} milisec=1000.0*(clock()-start)/CLOCKS_PER_SEC;\ dprintf(("%-90s took %f milis\n",#a,milisec)); } -#define HERE dprintf(("%d\n",__LINE__));fflush(stderr); +#define HERE dprintf(("line %d\n",__LINE__));fflush(stderr); #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;\ dprintf(("%s took %f milis\n",name,milisec)); } @@ -96,17 +96,15 @@ unsigned int getMedian(const std::vector& values, int size=-1); class TLDEnsembleClassifier{ public: - TLDEnsembleClassifier(int ordinal,Size size,int measurePerClassifier); + static int makeClassifiers(Size size,int measurePerClassifier,int gridSize,std::vector& classifiers); void integrate(const Mat_& patch,bool isPositive); double posteriorProbability(const uchar* data,int rowstep)const; - static int getMaxOrdinal(); private: - static int getGridSize(); - inline void stepPrefSuff(std::vector& arr,int len); - void preinit(int ordinal); + TLDEnsembleClassifier(std::vector meas,int beg,int end); + static void stepPrefSuff(std::vector& arr,int pos,int len,int gridSize); unsigned short int code(const uchar* data,int rowstep)const; std::vector pos,neg; - std::vector x1,y1,x2,y2; + std::vector measurements; }; class TrackerProxy{ diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index d7948ab07..aa2c9aa2f 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -252,8 +252,7 @@ void resample(const Mat& img,const Rect2d& r2,Mat_& samples){ } //other stuff -void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int len){ - int gridSize=getGridSize(); +void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int pos,int len,int gridSize){ #if 0 int step=len/(gridSize-1), pref=(len-step*(gridSize-1))/2; for(int i=0;i<(int)(sizeof(x1)/sizeof(x1[0]));i++){ @@ -266,39 +265,29 @@ void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int len){ int bigOnes=rem,smallOnes=gridSize-bigOnes-1; int bigOnes_front=bigOnes/2,bigOnes_back=bigOnes-bigOnes_front; for(int i=0;i<(int)arr.size();i++){ - if(arr[i](measurePerClassifier,0); - x2=std::vector(measurePerClassifier,0); - y1=std::vector(measurePerClassifier,0); - y2=std::vector(measurePerClassifier,0); - - preinit(ordinal); - - stepPrefSuff(x1,size.width); - stepPrefSuff(x2,size.width); - stepPrefSuff(y1,size.height); - stepPrefSuff(y2,size.height); - +TLDEnsembleClassifier::TLDEnsembleClassifier(std::vector meas,int beg,int end){ int posSize=1; - for(int i=0;i(posSize,0); neg=std::vector(posSize,0); + measurements.assign(meas.begin()+beg,meas.begin()+end); } void TLDEnsembleClassifier::integrate(const Mat_& patch,bool isPositive){ unsigned short int position=code(patch.data,(int)patch.step[0]); @@ -318,15 +307,45 @@ double TLDEnsembleClassifier::posteriorProbability(const uchar* data,int rowstep } } unsigned short int TLDEnsembleClassifier::code(const uchar* data,int rowstep)const{ - unsigned short int position=0; - for(int i=0;i<(int)x1.size();i++){ + unsigned short int position=0;//TODO: this --> encapsule + for(int i=0;i<(int)measurements.size();i++){ position=position<<1; - if(*(data+rowstep*y1[i]+x1[i])<*(data+rowstep*y2[i]+x2[i])){ + if(*(data+rowstep*measurements[i].val[0]+measurements[i].val[1])<*(data+rowstep*measurements[i].val[2]+measurements[i].val[3])){ position++; }else{ } } return position; } +int TLDEnsembleClassifier::makeClassifiers(Size size,int measurePerClassifier,int gridSize, + std::vector& classifiers){ + + std::vector measurements; + + for(int i=0;i Date: Thu, 31 Jul 2014 16:49:37 +0300 Subject: [PATCH 11/26] vadim 18, 19 --- modules/tracking/src/tld_tracker.cpp | 70 ++++++++++++++++++---------- modules/tracking/src/tld_tracker.hpp | 3 -- modules/tracking/src/tld_utils.cpp | 21 --------- 3 files changed, 46 insertions(+), 48 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index e3f9dd0f3..53cde604f 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -80,19 +80,21 @@ using namespace tld; * ||video(0.5<->0.6) --> debug if box size is less than 20 * perfect PN * - * vadim: - * ?3. comment each function/method - * 5. empty lines to separate logical... - * 6. comment logical sections - * ?10. all in one class - * 11. group decls logically, order of statements - * 12. not v=vector(n), but assign(n,0) - * 16. loops limits - * 17. inner scope loops - * 19. var checker - * 20. NCC using plain loops - * 21. precompute offset - * 22. vec of structs (detect and beyond) +* vadim: +* ?3. comment each function/method +* 5. empty lines to separate logical... +* 6. comment logical sections +* 11. group decls logically, order of statements +* +* ?10. all in one class +* +* 16. loops limits +* 17. inner scope loops +* +* 12. not v=vector(n), but assign(n,0) +* 20. NCC using plain loops +* 21. precompute offset +* 22. vec of structs (detect and beyond) * */ @@ -146,8 +148,7 @@ protected: Ptr model; void computeIntegralImages(const Mat& img,Mat_& intImgP,Mat_& intImgP2){integral(img,intImgP,intImgP2,CV_64F);} inline bool patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size); - bool ensembleClassifier(const uchar* data,int rowstep){return ensembleClassifierNum(data,rowstep)>ENSEMBLE_THRESHOLD;} - double ensembleClassifierNum(const uchar* data,int rowstep); + inline bool ensembleClassifier(const uchar* data,int rowstep); TrackerTLD::Params params_; }; @@ -203,7 +204,7 @@ class TrackerTLDModel : public TrackerModel{ Rect2d getBoundingBox(){return boundingBox_;} void setBoudingBox(Rect2d boundingBox){boundingBox_=boundingBox;} double getOriginalVariance(){return originalVariance_;} - std::vector* getClassifiers(){return &classifiers;} + inline double ensembleClassifierNum(const uchar* data,int rowstep); double Sr(const Mat_& patch); double Sc(const Mat_& patch); void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& box,const std::vector& isPositive, @@ -584,18 +585,36 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v return true; } +/** Computes the variance of subimage given by box, with the help of two integral + * images intImgP and intImgP2 (sum of squares), which should be also provided.*/ bool TLDDetector::patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size){ - return variance(intImgP,intImgP2,Rect(pt.x,pt.y,size.width,size.height)) >= VARIANCE_THRESHOLD*originalVariance; + int x=(pt.x),y=(pt.y),width=(size.width),height=(size.height); + CV_Assert(0<=x && (x+width)(model)); - std::vector* classifiers=tldModel->getClassifiers(); +double TrackerTLDModel::ensembleClassifierNum(const uchar* data,int rowstep){ double p=0; - for(int k=0;k<(int)classifiers->size();k++){ - p+=(*classifiers)[k].posteriorProbability(data,rowstep); + for(int k=0;k<(int)classifiers.size();k++){ + p+=classifiers[k].posteriorProbability(data,rowstep); } - p/=classifiers->size(); + p/=classifiers.size(); return p; } @@ -808,7 +827,7 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ i=(int)(x/scale/dx), j=(int)(y/scale/dy); dfprintf((stderr,"patchVariance=%s\n",(detector_->patchVariance(intImgP,intImgP2,originalVariance,Point(dx*i,dy*j),initSize))?"true":"false")); - dfprintf((stderr,"p=%f\n",(detector_->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i),(int)blurred_img.step[0])))); + dfprintf((stderr,"p=%f\n",(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i),(int)blurred_img.step[0])))); fprintf(stderr,"ensembleClassifier=%s\n", (detector_->ensembleClassifier(&blurred_img.at(dy*j,dx*i),(int)blurred_img.step[0]))?"true":"false"); @@ -847,5 +866,8 @@ void TrackerTLDModel::pushIntoModel(const Mat_& example,bool positive){ } (*proxyN)++; } +bool TLDDetector::ensembleClassifier(const uchar* data,int rowstep){ + return (((TrackerTLDModel*)static_cast(model))->ensembleClassifierNum(data,rowstep))>ENSEMBLE_THRESHOLD; +} } /* namespace cv */ diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index a4576c690..8f3b84152 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -84,9 +84,6 @@ void resample(const Mat& img,const RotatedRect& r2,Mat_& samples); void resample(const Mat& img,const Rect2d& r2,Mat_& samples); /** Computes the variance of single given image.*/ double variance(const Mat& img); -/** Computes the variance of subimage given by box, with the help of two integral - * images intImgP and intImgP2 (sum of squares), which should be also provided.*/ -double variance(Mat_& intImgP,Mat_& intImgP2,Rect box); /** Computes normalized corellation coefficient between the two patches (they should be * of the same size).*/ double NCC(const Mat_& patch1,const Mat_& patch2); diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index aa2c9aa2f..02579c097 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -177,27 +177,6 @@ double variance(const Mat& img){ p2/=(img.cols*img.rows); return p2-p*p; } -double variance(Mat_& intImgP,Mat_& intImgP2,Rect box){ - int x=(box.x),y=(box.y),width=(box.width),height=(box.height); - CV_Assert(0<=x && (x+width)& patch1,const Mat_& patch2){ CV_Assert(patch1.rows==patch2.rows); From 2848831ca3a0fcf0ddf8dc897d2bd8652e33da30 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Thu, 31 Jul 2014 23:00:26 +0300 Subject: [PATCH 12/26] vadim 12, 20, 22 --- modules/tracking/src/tld_tracker.cpp | 95 +++++++++++++--------------- modules/tracking/src/tld_tracker.hpp | 4 +- modules/tracking/src/tld_utils.cpp | 34 ++++++---- 3 files changed, 66 insertions(+), 67 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 53cde604f..51371495d 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -88,14 +88,9 @@ using namespace tld; * * ?10. all in one class * +* 21. precompute offset * 16. loops limits * 17. inner scope loops -* -* 12. not v=vector(n), but assign(n,0) -* 20. NCC using plain loops -* 21. precompute offset -* 22. vec of structs (detect and beyond) - * */ /* design decisions: @@ -134,15 +129,16 @@ private: Size minSize; }; -class TrackerTLDModel; - class TLDDetector { public: TLDDetector(const TrackerTLD::Params& params,Ptrmodel_in):model(model_in),params_(params){} ~TLDDetector(){} static void generateScanGrid(int rows,int cols,Size initBox,std::vector& res,bool withScaling=false); - bool detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::vector& rect,std::vector& isObject, - std::vector& shouldBeIntegrated); + struct LabeledPatch{ + Rect2d rect; + bool isObject, shouldBeIntegrated; + }; + bool detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::vector& patches); protected: friend class MyMouseCallbackDEBUG; Ptr model; @@ -207,8 +203,7 @@ class TrackerTLDModel : public TrackerModel{ inline double ensembleClassifierNum(const uchar* data,int rowstep); double Sr(const Mat_& patch); double Sc(const Mat_& patch); - void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& box,const std::vector& isPositive, - const std::vector& alsoIntoModel); + void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches); void integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive); Size getMinSize(){return minSize_;} void printme(FILE* port=stdout); @@ -313,8 +308,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(model)); data->frameNum++; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); - std::vector detectorResults; - std::vector isObject,shouldBeIntegrated; + std::vector detectorResults; //best overlap around 92% Rect2d tmpCandid=boundingBox; @@ -323,7 +317,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ bool trackerNeedsReInit=false; for(int i=0;i<2;i++){ if(((i==0)&&!(data->failedLastTime)&&trackerProxy->update(image,tmpCandid)) || - ((i==1)&&(detector->detect(imageForDetector,image_blurred,tmpCandid,detectorResults,isObject,shouldBeIntegrated)))){ + ((i==1)&&(detector->detect(imageForDetector,image_blurred,tmpCandid,detectorResults)))){ candidates.push_back(tmpCandid); if(i==0){ resample(image_gray,tmpCandid,standardPatch); @@ -380,17 +374,17 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ examplesForModel.reserve(100);examplesForEnsemble.reserve(100); int negRelabeled=0; for(int i=0;i<(int)detectorResults.size();i++){ - if(isObject[i]){ - expertResult=nExpert(detectorResults[i]); - if(expertResult!=isObject[i]){negRelabeled++;} + if(detectorResults[i].isObject){ + expertResult=nExpert(detectorResults[i].rect); + if(expertResult!=detectorResults[i].isObject){negRelabeled++;} }else{ - expertResult=pExpert(detectorResults[i]); + expertResult=pExpert(detectorResults[i].rect); } - shouldBeIntegrated[i]=shouldBeIntegrated[i] || (isObject[i]!=expertResult); - isObject[i]=expertResult; + detectorResults[i].shouldBeIntegrated=detectorResults[i].shouldBeIntegrated || (detectorResults[i].isObject!=expertResult); + detectorResults[i].isObject=expertResult; } - tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults,isObject,shouldBeIntegrated); + tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults); dprintf(("%d relabeled by nExpert\n",negRelabeled)); pExpert.additionalExamples(examplesForModel,examplesForEnsemble); tldModel->integrateAdditional(examplesForModel,examplesForEnsemble,true); @@ -399,7 +393,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ tldModel->integrateAdditional(examplesForModel,examplesForEnsemble,false); }else{ #ifdef CLOSED_LOOP - tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults,isObject,shouldBeIntegrated); + tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults); #endif } @@ -410,7 +404,7 @@ TrackerTLDModel::TrackerTLDModel(TrackerTLD::Params params,const Mat& image, con timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ boundingBox_=boundingBox; originalVariance_=variance(image(boundingBox)); - std::vector closest(10),scanGrid; + std::vector closest,scanGrid; Mat scaledImg,blurredImg,image_blurred; double scale=scaleAndBlur(image,cvRound(log(1.0*boundingBox.width/(minSize.width))/log(SCALE_STEP)),scaledImg,blurredImg,GaussBlurKernelSize); @@ -501,13 +495,10 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector& rect,std::vector& isObject, - std::vector& shouldBeIntegrated){ +bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::vector& patches){ TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(model)); Size initSize=tldModel->getMinSize(); - rect.clear(); - isObject.clear(); - shouldBeIntegrated.clear(); + patches.clear(); Mat resized_img,blurred_img; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); @@ -528,6 +519,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v for(int i=0,imax=cvFloor((0.0+resized_img.cols-initSize.width)/dx);iSr(standardPatch); - isObject.push_back(tmp>THETA_NN); - shouldBeIntegrated.push_back(abs(tmp-THETA_NN)<0.1); - if(!isObject[isObject.size()-1]){ + labPatch.isObject=tmp>THETA_NN; + labPatch.shouldBeIntegrated=abs(tmp-THETA_NN)<0.1; + patches.push_back(labPatch); + + if(!labPatch.isObject){ nneg++; continue; }else{ @@ -551,7 +545,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v tmp=tldModel->Sc(standardPatch); if(tmp>maxSc){ maxSc=tmp; - maxScRect=rect[rect.size()-1]; + maxScRect=labPatch.rect; } } } @@ -567,11 +561,11 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v dfprintf((stdout,"after NCC: nneg=%d npos=%d\n",nneg,npos)); #if !0 std::vector poss,negs; - for(int i=0;i<(int)rect.size();i++){ - if(isObject[i]) - poss.push_back(rect[i]); + for(int i=0;i<(int)patches.size();i++){ + if(patches[i].isObject) + poss.push_back(patches[i].rect); else - negs.push_back(rect[i]); + negs.push_back(patches[i].rect); } dfprintf((stdout,"%d pos and %d neg\n",(int)poss.size(),(int)negs.size())); drawWithRects(img,negs,poss); @@ -606,7 +600,7 @@ bool TLDDetector::patchVariance(Mat_& intImgP,Mat_& intImgP2,dou D=intImgP2(y+height,x+width); p2=(0.0+(D-B)-(C-A))/(width*height); - return p2-p*p; + return ((p2-p*p)>VARIANCE_THRESHOLD*originalVariance); } double TrackerTLDModel::ensembleClassifierNum(const uchar* data,int rowstep){ @@ -651,14 +645,13 @@ double TrackerTLDModel::Sc(const Mat_& patch){ return splus/(sminus+splus); } -void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& box,const std::vector& isPositive, - const std::vector& alsoIntoModel){ +void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches){ Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(minSize_); int positiveIntoModel=0,negativeIntoModel=0,positiveIntoEnsemble=0,negativeIntoEnsemble=0; - for(int k=0;k<(int)box.size();k++){ - if(alsoIntoModel[k]){ - resample(img,box[k],standardPatch); - if(isPositive[k]){ + for(int k=0;k<(int)patches.size();k++){ + if(patches[k].shouldBeIntegrated){ + resample(img,patches[k].rect,standardPatch); + if(patches[k].isObject){ positiveIntoModel++; pushIntoModel(standardPatch,true); }else{ @@ -668,18 +661,18 @@ void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vec } #ifdef CLOSED_LOOP - if(alsoIntoModel[k] || (isPositive[k]==false)){ + if(patches[k].shouldBeIntegrated || (patches[k].isPositive==false)){ #else - if(alsoIntoModel[k]){ + if(patches[k].shouldBeIntegrated){ #endif - resample(imgBlurred,box[k],blurredPatch); - if(isPositive[k]){ + resample(imgBlurred,patches[k].rect,blurredPatch); + if(patches[k].isObject){ positiveIntoEnsemble++; }else{ negativeIntoEnsemble++; } for(int i=0;i<(int)classifiers.size();i++){ - classifiers[i].integrate(blurredPatch,isPositive[k]); + classifiers[i].integrate(blurredPatch,patches[k].isObject); } } } @@ -738,7 +731,7 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: examplesForModel.clear();examplesForEnsemble.clear(); examplesForModel.reserve(100);examplesForEnsemble.reserve(100); - std::vector closest(10),scanGrid; + std::vector closest,scanGrid; Mat scaledImg,blurredImg; double scale=scaleAndBlur(img_,cvRound(log(1.0*resultBox_.width/(initSize_.width))/log(SCALE_STEP)),scaledImg,blurredImg,GaussBlurKernelSize); diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index 8f3b84152..9917f1a22 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -99,8 +99,8 @@ public: private: TLDEnsembleClassifier(std::vector meas,int beg,int end); static void stepPrefSuff(std::vector& arr,int pos,int len,int gridSize); - unsigned short int code(const uchar* data,int rowstep)const; - std::vector pos,neg; + int code(const uchar* data,int rowstep)const; + std::vector posAndNeg; std::vector measurements; }; diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index 02579c097..c37659979 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -136,7 +136,8 @@ void getClosestN(std::vector& scanGrid,Rect2d bBox,int n,std::vector overlaps(n,0.0); + std::vector overlaps; + overlaps.assign(n,0.0); res.assign(scanGrid.begin(),scanGrid.begin()+n); for(int i=0;i& patch1,const Mat_& patch2){ CV_Assert(patch1.cols==patch2.cols); int N=patch1.rows*patch1.cols; - double s1=sum(patch1)(0),s2=sum(patch2)(0); - double n1=norm(patch1),n2=norm(patch2); - double prod=patch1.dot(patch2); - double sq1=sqrt(std::max(0.0,n1*n1-s1*s1/N)),sq2=sqrt(std::max(0.0,n2*n2-s2*s2/N)); + int s1=0,s2=0,n1=0,n2=0,prod=0; + for(int i=0;i& arr,int pos,int len TLDEnsembleClassifier::TLDEnsembleClassifier(std::vector meas,int beg,int end){ int posSize=1; for(int i=0,mpc=end-beg;i(posSize,0); - neg=std::vector(posSize,0); + posAndNeg.assign(posSize,Point2i(0,0)); measurements.assign(meas.begin()+beg,meas.begin()+end); } void TLDEnsembleClassifier::integrate(const Mat_& patch,bool isPositive){ - unsigned short int position=code(patch.data,(int)patch.step[0]); + int position=code(patch.data,(int)patch.step[0]); if(isPositive){ - pos[position]++; + posAndNeg[position].x++; }else{ - neg[position]++; + posAndNeg[position].y++; } } double TLDEnsembleClassifier::posteriorProbability(const uchar* data,int rowstep)const{ - unsigned short int position=code(data,rowstep); - double posNum=(double)pos[position], negNum=(double)neg[position]; + int position=code(data,rowstep); + double posNum=(double)posAndNeg[position].x, negNum=(double)posAndNeg[position].y; if(posNum==0.0 && negNum==0.0){ return 0.0; }else{ return posNum/(posNum+negNum); } } -unsigned short int TLDEnsembleClassifier::code(const uchar* data,int rowstep)const{ - unsigned short int position=0;//TODO: this --> encapsule +int TLDEnsembleClassifier::code(const uchar* data,int rowstep)const{ + unsigned short int position=0; for(int i=0;i<(int)measurements.size();i++){ position=position<<1; if(*(data+rowstep*measurements[i].val[0]+measurements[i].val[1])<*(data+rowstep*measurements[i].val[2]+measurements[i].val[3])){ From 7dca000bf947187b97330a601f7e84fa6ba2f8d5 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Fri, 1 Aug 2014 14:56:11 +0300 Subject: [PATCH 13/26] vadim 21 --- modules/tracking/src/tld_tracker.cpp | 25 +++++++++--------- modules/tracking/src/tld_tracker.hpp | 5 ++++ modules/tracking/src/tld_utils.cpp | 38 ++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 51371495d..dc87db0d4 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -88,14 +88,13 @@ using namespace tld; * * ?10. all in one class * -* 21. precompute offset +* -->21. precompute offset +* * 16. loops limits * 17. inner scope loops */ /* design decisions: - * blur --> resize (vs. resize-->blur) in detect(), ensembleClassifier stage - * no random gauss noise, when making examples for ensembleClassifier */ namespace cv @@ -144,7 +143,6 @@ protected: Ptr model; void computeIntegralImages(const Mat& img,Mat_& intImgP,Mat_& intImgP2){integral(img,intImgP,intImgP2,CV_64F);} inline bool patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size); - inline bool ensembleClassifier(const uchar* data,int rowstep); TrackerTLD::Params params_; }; @@ -200,13 +198,15 @@ class TrackerTLDModel : public TrackerModel{ Rect2d getBoundingBox(){return boundingBox_;} void setBoudingBox(Rect2d boundingBox){boundingBox_=boundingBox;} double getOriginalVariance(){return originalVariance_;} - inline double ensembleClassifierNum(const uchar* data,int rowstep); + inline double ensembleClassifierNum(const uchar* data); + inline void prepareClassifiers(int rowstep){for(int i=0;i<(int)classifiers.size();i++)classifiers[i].prepareClassifier(rowstep);} double Sr(const Mat_& patch); double Sc(const Mat_& patch); void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches); void integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive); Size getMinSize(){return minSize_;} void printme(FILE* port=stdout); + protected: Size minSize_; unsigned int timeStampPositiveNext,timeStampNegativeNext; @@ -517,6 +517,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v Mat_ intImgP,intImgP2; computeIntegralImages(resized_img,intImgP,intImgP2); + tldModel->prepareClassifiers((int)blurred_img.step[0]); for(int i=0,imax=cvFloor((0.0+resized_img.cols-initSize.width)/dx);i(dy*j,dx*i),(int)blurred_img.step[0])){ + if(!(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i))>ENSEMBLE_THRESHOLD)){ continue; } pass++; @@ -603,10 +604,10 @@ bool TLDDetector::patchVariance(Mat_& intImgP,Mat_& intImgP2,dou return ((p2-p*p)>VARIANCE_THRESHOLD*originalVariance); } -double TrackerTLDModel::ensembleClassifierNum(const uchar* data,int rowstep){ +double TrackerTLDModel::ensembleClassifierNum(const uchar* data){ double p=0; for(int k=0;k<(int)classifiers.size();k++){ - p+=classifiers[k].posteriorProbability(data,rowstep); + p+=classifiers[k].posteriorProbabilityFast(data); } p/=classifiers.size(); return p; @@ -820,9 +821,10 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ i=(int)(x/scale/dx), j=(int)(y/scale/dy); dfprintf((stderr,"patchVariance=%s\n",(detector_->patchVariance(intImgP,intImgP2,originalVariance,Point(dx*i,dy*j),initSize))?"true":"false")); - dfprintf((stderr,"p=%f\n",(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i),(int)blurred_img.step[0])))); + tldModel->prepareClassifiers((int)blurred_img.step[0]); + dfprintf((stderr,"p=%f\n",(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i))))); fprintf(stderr,"ensembleClassifier=%s\n", - (detector_->ensembleClassifier(&blurred_img.at(dy*j,dx*i),(int)blurred_img.step[0]))?"true":"false"); + (!(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i))>ENSEMBLE_THRESHOLD))?"true":"false"); resample(resized_img,Rect2d(Point(dx*i,dy*j),initSize),standardPatch); tmp=tldModel->Sr(standardPatch); @@ -859,8 +861,5 @@ void TrackerTLDModel::pushIntoModel(const Mat_& example,bool positive){ } (*proxyN)++; } -bool TLDDetector::ensembleClassifier(const uchar* data,int rowstep){ - return (((TrackerTLDModel*)static_cast(model))->ensembleClassifierNum(data,rowstep))>ENSEMBLE_THRESHOLD; -} } /* namespace cv */ diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index 9917f1a22..6ec0fc3d4 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -96,12 +96,17 @@ public: static int makeClassifiers(Size size,int measurePerClassifier,int gridSize,std::vector& classifiers); void integrate(const Mat_& patch,bool isPositive); double posteriorProbability(const uchar* data,int rowstep)const; + double posteriorProbabilityFast(const uchar* data)const; + void prepareClassifier(int rowstep); private: TLDEnsembleClassifier(std::vector meas,int beg,int end); static void stepPrefSuff(std::vector& arr,int pos,int len,int gridSize); int code(const uchar* data,int rowstep)const; + int codeFast(const uchar* data)const; std::vector posAndNeg; std::vector measurements; + std::vector offset; + int lastStep_; }; class TrackerProxy{ diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index c37659979..080a3acd5 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -268,11 +268,21 @@ void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int pos,int len } #endif } -TLDEnsembleClassifier::TLDEnsembleClassifier(std::vector meas,int beg,int end){ - int posSize=1; - for(int i=0,mpc=end-beg;i meas,int beg,int end):lastStep_(-1){ + int posSize=1,mpc=end-beg; + for(int i=0;i& patch,bool isPositive){ int position=code(patch.data,(int)patch.step[0]); @@ -291,13 +301,31 @@ double TLDEnsembleClassifier::posteriorProbability(const uchar* data,int rowstep return posNum/(posNum+negNum); } } +double TLDEnsembleClassifier::posteriorProbabilityFast(const uchar* data)const{ + int position=codeFast(data); + double posNum=(double)posAndNeg[position].x, negNum=(double)posAndNeg[position].y; + if(posNum==0.0 && negNum==0.0){ + return 0.0; + }else{ + return posNum/(posNum+negNum); + } +} +int TLDEnsembleClassifier::codeFast(const uchar* data)const{ + int position=0; + for(int i=0;i<(int)measurements.size();i++){ + position=position<<1; + if(data[offset[i].x] Date: Fri, 1 Aug 2014 17:10:43 +0300 Subject: [PATCH 14/26] vadim --- modules/tracking/src/tld_tracker.cpp | 4 +--- modules/tracking/src/tld_tracker.hpp | 2 +- modules/tracking/src/tld_utils.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index dc87db0d4..c44386c23 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -88,8 +88,6 @@ using namespace tld; * * ?10. all in one class * -* -->21. precompute offset -* * 16. loops limits * 17. inner scope loops */ @@ -569,7 +567,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v negs.push_back(patches[i].rect); } dfprintf((stdout,"%d pos and %d neg\n",(int)poss.size(),(int)negs.size())); - drawWithRects(img,negs,poss); + drawWithRects(img,negs,poss,"tech"); #endif dfprintf((stdout,"%d after ensemble\n",pass)); diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index 6ec0fc3d4..4acd81175 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -70,7 +70,7 @@ void myassert(const Mat& img); void printPatch(const Mat_& standardPatch); std::string type2str(const Mat& mat); void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne=Rect2d(-1.0,-1.0,-1.0,-1.0)); -void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes); +void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String fileName=""); //aux functions and variables //#define CLIP(x,a,b) std::min(std::max((x),(a)),(b)) diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index 080a3acd5..9ad377994 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -65,8 +65,9 @@ void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne } imshow("img",image); } -void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes){ +void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String filename){ Mat image; + static int frameCounter=1; img.copyTo(image); for(int i=0;i<(int)whiteOnes.size();i++){ rectangle( image,whiteOnes[i], 255, 1, 1 ); @@ -75,6 +76,12 @@ void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector0){ + char inbuf[100]; + sprintf(inbuf,"%s%d.jpg",filename.c_str(),frameCounter); + imwrite(inbuf,image); + frameCounter++; + } } void myassert(const Mat& img){ int count=0; From b6b8196261cfc2d84778f89ee91ccca4f553fd81 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 4 Aug 2014 08:51:58 +0300 Subject: [PATCH 15/26] vadim 10, 16, 17 --- modules/tracking/src/tld_tracker.cpp | 87 +++++++++++++--------------- modules/tracking/src/tld_utils.cpp | 7 ++- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index c44386c23..011192fe8 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -86,10 +86,8 @@ using namespace tld; * 6. comment logical sections * 11. group decls logically, order of statements * -* ?10. all in one class * -* 16. loops limits -* 17. inner scope loops +* ?10. all in one class */ /* design decisions: @@ -144,34 +142,6 @@ protected: TrackerTLD::Params params_; }; -class Pexpert{ -public: - Pexpert(const Mat& img,const Mat& imgBlurred,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params,Size initSize): - img_(img),imgBlurred_(imgBlurred),resultBox_(resultBox),detector_(detector),params_(params),initSize_(initSize){} - bool operator()(Rect2d /*box*/){return false;} - int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble); -protected: - Mat img_,imgBlurred_; - Rect2d resultBox_; - const TLDDetector* detector_; - TrackerTLD::Params params_; - RNG rng; - Size initSize_; -}; - -class Nexpert{ -public: - Nexpert(const Mat& img,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params):img_(img),resultBox_(resultBox), - detector_(detector),params_(params){} - bool operator()(Rect2d box); - int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ - examplesForModel.clear();examplesForEnsemble.clear();return 0;} -protected: - Mat img_; - Rect2d resultBox_; - const TLDDetector* detector_; - TrackerTLD::Params params_; -}; template class TrackerProxyImpl : public TrackerProxy{ @@ -228,6 +198,30 @@ class TrackerTLDImpl : public TrackerTLD void write( FileStorage& fs ) const; protected: + class Pexpert{ + public: + Pexpert(const Mat& img,const Mat& imgBlurred,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params,Size initSize): + img_(img),imgBlurred_(imgBlurred),resultBox_(resultBox),detector_(detector),params_(params),initSize_(initSize){} + bool operator()(Rect2d /*box*/){return false;} + int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble); + protected: + Pexpert(){} + Mat img_,imgBlurred_; + Rect2d resultBox_; + const TLDDetector* detector_; + TrackerTLD::Params params_; + RNG rng; + Size initSize_; + }; + + class Nexpert : public Pexpert{ + public: + Nexpert(const Mat& img,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params){ + img_=img; resultBox_=resultBox; detector_=detector; params_=params;} + bool operator()(Rect2d box); + int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ + examplesForModel.clear();examplesForEnsemble.clear();return 0;} + }; bool initImpl( const Mat& image, const Rect2d& boundingBox ); bool updateImpl( const Mat& image, Rect2d& boundingBox ); @@ -309,11 +303,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ std::vector detectorResults; //best overlap around 92% - Rect2d tmpCandid=boundingBox; std::vector candidates; std::vector candidatesRes; bool trackerNeedsReInit=false; for(int i=0;i<2;i++){ + Rect2d tmpCandid=boundingBox; if(((i==0)&&!(data->failedLastTime)&&trackerProxy->update(image,tmpCandid)) || ((i==1)&&(detector->detect(imageForDetector,image_blurred,tmpCandid,detectorResults)))){ candidates.push_back(tmpCandid); @@ -367,11 +361,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ if(data->confident){ Pexpert pExpert(imageForDetector,image_blurred,boundingBox,detector,params,data->getMinSize()); Nexpert nExpert(imageForDetector,boundingBox,detector,params); - bool expertResult; std::vector > examplesForModel,examplesForEnsemble; examplesForModel.reserve(100);examplesForEnsemble.reserve(100); int negRelabeled=0; for(int i=0;i<(int)detectorResults.size();i++){ + bool expertResult; if(detectorResults[i].isObject){ expertResult=nExpert(detectorResults[i].rect); if(expertResult!=detectorResults[i].isObject){negRelabeled++;} @@ -399,8 +393,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ } TrackerTLDModel::TrackerTLDModel(TrackerTLD::Params params,const Mat& image, const Rect2d& boundingBox,Size minSize):minSize_(minSize), -timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ - boundingBox_=boundingBox; +timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params),boundingBox_(boundingBox){ originalVariance_=variance(image(boundingBox)); std::vector closest,scanGrid; Mat scaledImg,blurredImg,image_blurred; @@ -414,10 +407,10 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params){ TLDEnsembleClassifier::makeClassifiers(minSize,MEASURES_PER_CLASSIFIER,GRIDSIZE,classifiers); positiveExamples.reserve(200); - Point2f center; - Size2f size; for(int i=0;i<(int)closest.size();i++){ for(int j=0;j<20;j++){ + Point2f center; + Size2f size; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); center.x=(float)(closest[i].x+closest[i].width*(0.5+rng.uniform(-0.01,0.01))); center.y=(float)(closest[i].y+closest[i].height*(0.5+rng.uniform(-0.01,0.01))); @@ -471,8 +464,8 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector intImgP,intImgP2; @@ -560,6 +554,7 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v dfprintf((stdout,"after NCC: nneg=%d npos=%d\n",nneg,npos)); #if !0 std::vector poss,negs; + for(int i=0;i<(int)patches.size();i++){ if(patches[i].isObject) poss.push_back(patches[i].rect); @@ -612,11 +607,10 @@ double TrackerTLDModel::ensembleClassifierNum(const uchar* data){ } double TrackerTLDModel::Sr(const Mat_& patch){ - double splus=0.0; + 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)); } - double sminus=0.0; for(int i=0;i<(int)negativeExamples.size();i++){ sminus=std::max(sminus,0.5*(NCC(negativeExamples[i],patch)+1.0)); } @@ -627,14 +621,13 @@ double TrackerTLDModel::Sr(const Mat_& patch){ } double TrackerTLDModel::Sc(const Mat_& patch){ - double splus=0.0; + 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)); } } - double sminus=0.0; for(int i=0;i<(int)negativeExamples.size();i++){ sminus=std::max(sminus,0.5*(NCC(negativeExamples[i],patch)+1.0)); } @@ -726,7 +719,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector >& eForM dfprintf((stdout,"\n")); } -int Pexpert::additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ +int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ examplesForModel.clear();examplesForEnsemble.clear(); examplesForModel.reserve(100);examplesForEnsemble.reserve(100); @@ -737,10 +730,10 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: 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); - Point2f center; - Size2f size; for(int i=0;i<(int)closest.size();i++){ for(int j=0;j<10;j++){ + Point2f center; + Size2f size; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(initSize_); center.x=(float)(closest[i].x+closest[i].width*(0.5+rng.uniform(-0.01,0.01))); center.y=(float)(closest[i].y+closest[i].height*(0.5+rng.uniform(-0.01,0.01))); @@ -767,7 +760,7 @@ int Pexpert::additionalExamples(std::vector >& examplesForModel,std: return 0; } -bool Nexpert::operator()(Rect2d box){ +bool TrackerTLDImpl::Nexpert::operator()(Rect2d box){ if(overlap(resultBox_,box)<0.2){ return false; } diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index 9ad377994..f26d1dc53 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -160,13 +160,16 @@ void getClosestN(std::vector& scanGrid,Rect2d bBox,int n,std::vector Date: Mon, 4 Aug 2014 22:17:32 +0300 Subject: [PATCH 16/26] coding style --- modules/tracking/src/tld_tracker.cpp | 643 +++++++++++++++------------ modules/tracking/src/tld_tracker.hpp | 29 +- modules/tracking/src/tld_utils.cpp | 256 +++++------ 3 files changed, 494 insertions(+), 434 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 011192fe8..38a400288 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -43,8 +43,8 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/imgproc.hpp" #include "time.h" -#include -#include +#include +#include #include "tld_tracker.hpp" #include "opencv2/highgui.hpp" @@ -57,6 +57,7 @@ #define SCALE_STEP 1.2 #define ENSEMBLE_THRESHOLD 0.5 #define VARIANCE_THRESHOLD 0.5 +#define NEXPERT_THRESHOLD 0.2 #define GRIDSIZE 15 #define DOWNSCALE_MODE INTER_LINEAR #define BLUR_AS_VADIM @@ -73,11 +74,11 @@ using namespace tld; * FIXME(issues) * THETA_NN 0.5<->0.6 dramatic change vs video 6 !! * TODO(features) - * benchmark: two streams of photos --> better video + * benchmark: two streams of photos -->better video * (try inter_area for resize) * TODO: - * fix pushbot ->pick commits -> compare_branches->all in 1->resubmit - * ||video(0.5<->0.6) --> debug if box size is less than 20 + * fix pushbot->pick commits->compare_branches->all in 1->resubmit + * || video(0.5<->0.6) -->debug if box size is less than 20 * perfect PN * * vadim: @@ -86,8 +87,19 @@ using namespace tld; * 6. comment logical sections * 11. group decls logically, order of statements * -* * ?10. all in one class +* todo: initializer lists +* +* format: if,while,for, , Assert +* format: methods +* --> compile +* ; , +* --> compile +* -->commit-push -->notify +* +* ?( ) +* +* ?vadim: for{1command} can omit {}; if( a != (b + c) ) vs ( a != ( b + c ) ) */ /* design decisions: @@ -103,7 +115,7 @@ public: static void onMouse( int event, int x, int y, int, void* obj){ ((MyMouseCallbackDEBUG*)obj)->onMouse(event,x,y); } - MyMouseCallbackDEBUG& operator= (const MyMouseCallbackDEBUG& /*other*/){return *this;} + MyMouseCallbackDEBUG& operator = (const MyMouseCallbackDEBUG& /*other*/){return *this;} private: void onMouse( int event, int x, int y); Mat& img_,imgBlurred_; @@ -118,7 +130,7 @@ public: bool confident; bool failedLastTime; int frameNum; - void printme(FILE* port=stdout); + void printme(FILE* port = stdout); private: double scale; Size minSize; @@ -126,9 +138,9 @@ private: class TLDDetector { public: - TLDDetector(const TrackerTLD::Params& params,Ptrmodel_in):model(model_in),params_(params){} + TLDDetector(const TrackerTLD::Params& params,Ptr model_in):model(model_in),params_(params){} ~TLDDetector(){} - static void generateScanGrid(int rows,int cols,Size initBox,std::vector& res,bool withScaling=false); + static void generateScanGrid(int rows,int cols,Size initBox,std::vector& res,bool withScaling = false); struct LabeledPatch{ Rect2d rect; bool isObject, shouldBeIntegrated; @@ -143,12 +155,12 @@ protected: }; -template +template class TrackerProxyImpl : public TrackerProxy{ public: - TrackerProxyImpl(Tparams params=Tparams()):params_(params){} + TrackerProxyImpl(Tparams params = Tparams()):params_(params){} bool init( const Mat& image, const Rect2d& boundingBox ){ - trackerPtr=T::createTracker(); + trackerPtr = T::createTracker(); return trackerPtr->init(image,boundingBox); } bool update( const Mat& image,Rect2d& boundingBox){ @@ -164,20 +176,20 @@ class TrackerTLDModel : public TrackerModel{ public: TrackerTLDModel(TrackerTLD::Params params,const Mat& image, const Rect2d& boundingBox,Size minSize); Rect2d getBoundingBox(){return boundingBox_;} - void setBoudingBox(Rect2d boundingBox){boundingBox_=boundingBox;} + void setBoudingBox(Rect2d boundingBox){boundingBox_ = boundingBox;} double getOriginalVariance(){return originalVariance_;} inline double ensembleClassifierNum(const uchar* data); - inline void prepareClassifiers(int rowstep){for(int i=0;i<(int)classifiers.size();i++)classifiers[i].prepareClassifier(rowstep);} + inline void prepareClassifiers(int rowstep){for(int i = 0;i < (int)classifiers.size();i++)classifiers[i].prepareClassifier(rowstep);} double Sr(const Mat_& patch); double Sc(const Mat_& patch); void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches); void integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive); Size getMinSize(){return minSize_;} - void printme(FILE* port=stdout); + void printme(FILE* port = stdout); protected: Size minSize_; - unsigned int timeStampPositiveNext,timeStampNegativeNext; + int timeStampPositiveNext,timeStampNegativeNext; TrackerTLD::Params params_; void pushIntoModel(const Mat_& example,bool positive); void modelEstimationImpl( const std::vector& /*responses*/ ){} @@ -185,7 +197,7 @@ class TrackerTLDModel : public TrackerModel{ Rect2d boundingBox_; double originalVariance_; std::vector > positiveExamples,negativeExamples; - std::vector timeStampsPositive,timeStampsNegative; + std::vector timeStampsPositive,timeStampsNegative; RNG rng; std::vector classifiers; }; @@ -217,7 +229,7 @@ class TrackerTLDImpl : public TrackerTLD class Nexpert : public Pexpert{ public: Nexpert(const Mat& img,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params){ - img_=img; resultBox_=resultBox; detector_=detector; params_=params;} + img_ = img; resultBox_ = resultBox; detector_ = detector; params_ = params;} bool operator()(Rect2d box); int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ examplesForModel.clear();examplesForEnsemble.clear();return 0;} @@ -246,11 +258,11 @@ Ptr TrackerTLD::createTracker(const TrackerTLD::Params ¶meters){ return Ptr(new TrackerTLDImpl(parameters)); } -TrackerTLDImpl::TrackerTLDImpl( const TrackerTLD::Params ¶meters) : +TrackerTLDImpl::TrackerTLDImpl(const TrackerTLD::Params ¶meters) : params( parameters ){ isInit = false; - trackerProxy=Ptr >( - new TrackerProxyImpl()); + trackerProxy = Ptr > + (new TrackerProxyImpl()); } void TrackerTLDImpl::read( const cv::FileNode& fn ) @@ -267,22 +279,23 @@ bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox ){ Mat image_gray; trackerProxy->init(image,boundingBox); cvtColor( image, image_gray, COLOR_BGR2GRAY ); - data=Ptr(new Data(boundingBox)); - double scale=data->getScale(); - Rect2d myBoundingBox=boundingBox; - if(scale>1.0){ + data = Ptr(new Data(boundingBox)); + double scale = data->getScale(); + Rect2d myBoundingBox = boundingBox; + if(scale > 1.0) + { Mat image_proxy; - resize(image_gray,image_proxy,Size(cvRound(image.cols*scale),cvRound(image.rows*scale)),0,0,DOWNSCALE_MODE); + resize(image_gray,image_proxy,Size(cvRound(image.cols * scale),cvRound(image.rows * scale)),0,0,DOWNSCALE_MODE); image_proxy.copyTo(image_gray); - myBoundingBox.x*=scale; - myBoundingBox.y*=scale; - myBoundingBox.width*=scale; - myBoundingBox.height*=scale; + myBoundingBox.x *= scale; + myBoundingBox.y *= scale; + myBoundingBox.width *= scale; + myBoundingBox.height *= scale; } - model=Ptr(new TrackerTLDModel(params,image_gray,myBoundingBox,data->getMinSize())); - detector=Ptr(new TLDDetector(params,model)); - data->confident=false; - data->failedLastTime=false; + model = Ptr(new TrackerTLDModel(params,image_gray,myBoundingBox,data->getMinSize())); + detector = Ptr(new TLDDetector(params,model)); + data->confident = false; + data->failedLastTime = false; return true; } @@ -290,14 +303,14 @@ bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox ){ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ Mat image_gray,image_blurred,imageForDetector; cvtColor( image, image_gray, COLOR_BGR2GRAY ); - double scale=data->getScale(); - if(scale>1.0){ + double scale = data->getScale(); + if(scale > 1.0){ resize(image_gray,imageForDetector,Size(cvRound(image.cols*scale),cvRound(image.rows*scale)),0,0,DOWNSCALE_MODE); }else{ - imageForDetector=image_gray; + imageForDetector = image_gray; } GaussianBlur(imageForDetector,image_blurred,GaussBlurKernelSize,0.0); - TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(model)); + TrackerTLDModel* tldModel = ((TrackerTLDModel*)static_cast(model)); data->frameNum++; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); std::vector detectorResults; @@ -305,57 +318,60 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ std::vector candidates; std::vector candidatesRes; - bool trackerNeedsReInit=false; - for(int i=0;i<2;i++){ - Rect2d tmpCandid=boundingBox; - if(((i==0)&&!(data->failedLastTime)&&trackerProxy->update(image,tmpCandid)) || - ((i==1)&&(detector->detect(imageForDetector,image_blurred,tmpCandid,detectorResults)))){ + bool trackerNeedsReInit = false; + for( int i = 0; i < 2; i++ ) + { + Rect2d tmpCandid = boundingBox; + if(((i == 0)&& !(data->failedLastTime)&& trackerProxy->update(image,tmpCandid)) || + ((i == 1)&& (detector->detect(imageForDetector,image_blurred,tmpCandid,detectorResults)))){ candidates.push_back(tmpCandid); - if(i==0){ + if(i == 0){ resample(image_gray,tmpCandid,standardPatch); }else{ resample(imageForDetector,tmpCandid,standardPatch); } candidatesRes.push_back(tldModel->Sc(standardPatch)); }else{ - if(i==0){ - trackerNeedsReInit=true; + if(i == 0){ + trackerNeedsReInit = true; } } } - std::vector::iterator it=std::max_element(candidatesRes.begin(),candidatesRes.end()); + std::vector::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])); + 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()){ - data->confident=false; - data->failedLastTime=true; + if(it == candidatesRes.end()){ + data->confident = false; + data->failedLastTime = true; return false; }else{ - boundingBox=candidates[it-candidatesRes.begin()]; - data->failedLastTime=false; - if(trackerNeedsReInit || it!=candidatesRes.begin()){ + boundingBox = candidates[it - candidatesRes.begin()]; + data->failedLastTime = false; + if(trackerNeedsReInit || it != candidatesRes.begin()){ trackerProxy->init(image,boundingBox); } } - if(!false && it!=candidatesRes.end()){ - resample(imageForDetector,candidates[it-candidatesRes.begin()],standardPatch); +#if 1 + if(it != candidatesRes.end()){ + 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)) + if(candidatesRes.size() == 2 && it == (candidatesRes.begin() + 1)) dfprintf((stderr,"detector WON\n")); }else{ dfprintf((stderr,"%d x x\n",data->frameNum)); } +#endif if(*it > CORE_THRESHOLD){ - data->confident=true; + data->confident = true; } if(data->confident){ @@ -363,18 +379,18 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ Nexpert nExpert(imageForDetector,boundingBox,detector,params); std::vector > examplesForModel,examplesForEnsemble; examplesForModel.reserve(100);examplesForEnsemble.reserve(100); - int negRelabeled=0; - for(int i=0;i<(int)detectorResults.size();i++){ + int negRelabeled = 0; + for(int i = 0;i < (int)detectorResults.size();i++){ bool expertResult; if(detectorResults[i].isObject){ - expertResult=nExpert(detectorResults[i].rect); - if(expertResult!=detectorResults[i].isObject){negRelabeled++;} + expertResult = nExpert(detectorResults[i].rect); + if(expertResult != detectorResults[i].isObject){negRelabeled++;} }else{ - expertResult=pExpert(detectorResults[i].rect); + expertResult = pExpert(detectorResults[i].rect); } - detectorResults[i].shouldBeIntegrated=detectorResults[i].shouldBeIntegrated || (detectorResults[i].isObject!=expertResult); - detectorResults[i].isObject=expertResult; + detectorResults[i].shouldBeIntegrated = detectorResults[i].shouldBeIntegrated || (detectorResults[i].isObject != expertResult); + detectorResults[i].isObject = expertResult; } tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults); dprintf(("%d relabeled by nExpert\n",negRelabeled)); @@ -394,35 +410,36 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ TrackerTLDModel::TrackerTLDModel(TrackerTLD::Params params,const Mat& image, const Rect2d& boundingBox,Size minSize):minSize_(minSize), timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params),boundingBox_(boundingBox){ - originalVariance_=variance(image(boundingBox)); + originalVariance_ = variance(image(boundingBox)); std::vector closest,scanGrid; Mat scaledImg,blurredImg,image_blurred; - double scale=scaleAndBlur(image,cvRound(log(1.0*boundingBox.width/(minSize.width))/log(SCALE_STEP)),scaledImg,blurredImg,GaussBlurKernelSize); + double scale = scaleAndBlur(image,cvRound(log(1.0 * boundingBox.width / (minSize.width)) / log(SCALE_STEP)), + scaledImg,blurredImg,GaussBlurKernelSize,SCALE_STEP); GaussianBlur(image,image_blurred,GaussBlurKernelSize,0.0); TLDDetector::generateScanGrid(image.rows,image.cols,minSize,scanGrid); - getClosestN(scanGrid,Rect2d(boundingBox.x/scale,boundingBox.y/scale,boundingBox.width/scale,boundingBox.height/scale),10,closest); + getClosestN(scanGrid,Rect2d(boundingBox.x / scale,boundingBox.y / scale,boundingBox.width / scale,boundingBox.height / scale),10,closest); Mat_ blurredPatch(minSize); TLDEnsembleClassifier::makeClassifiers(minSize,MEASURES_PER_CLASSIFIER,GRIDSIZE,classifiers); positiveExamples.reserve(200); - for(int i=0;i<(int)closest.size();i++){ - for(int j=0;j<20;j++){ + for(int i = 0;i < (int)closest.size();i++){ + for(int j = 0;j < 20;j++){ Point2f center; Size2f size; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); - center.x=(float)(closest[i].x+closest[i].width*(0.5+rng.uniform(-0.01,0.01))); - center.y=(float)(closest[i].y+closest[i].height*(0.5+rng.uniform(-0.01,0.01))); - size.width=(float)(closest[i].width*rng.uniform((double)0.99,(double)1.01)); - size.height=(float)(closest[i].height*rng.uniform((double)0.99,(double)1.01)); - float angle=(float)rng.uniform(-10.0,10.0); + center.x = (float)(closest[i].x + closest[i].width * (0.5 + rng.uniform(-0.01,0.01))); + center.y = (float)(closest[i].y + closest[i].height * (0.5 + rng.uniform(-0.01,0.01))); + size.width = (float)(closest[i].width * rng.uniform((double)0.99,(double)1.01)); + size.height = (float)(closest[i].height * rng.uniform((double)0.99,(double)1.01)); + float angle = (float)rng.uniform(-10.0,10.0); resample(scaledImg,RotatedRect(center,size,angle),standardPatch); - for(int y=0;y indices; indices.reserve(NEG_EXAMPLES_IN_INIT_MODEL); - while(negativeExamples.size() standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); resample(image,scanGrid[i],standardPatch); pushIntoModel(standardPatch,false); resample(image_blurred,scanGrid[i],blurredPatch); - for(int k=0;k<(int)classifiers.size();k++){ + for(int k = 0;k < (int)classifiers.size();k++){ classifiers[k].integrate(blurredPatch,false); } } @@ -463,23 +480,30 @@ timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params),boundingBox_(b void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector& res,bool withScaling){ res.clear(); //scales step: SCALE_STEP; hor step: 10% of width; verstep: 10% of height; minsize: 20pix - for(double h=initBox.height, w=initBox.width;hinitBox.height || w>initBox.width); + if( withScaling ) + { + if( h <= initBox.height ) + { + h /= SCALE_STEP; w /= SCALE_STEP; + if( h < 20 || w < 20 ) + { + h = initBox.height * SCALE_STEP; w = initBox.width * SCALE_STEP; + CV_Assert(h > initBox.height || w > initBox.width); } - }else{ - h*=SCALE_STEP; w*=SCALE_STEP; } - }else{ + else + { + h *= SCALE_STEP; w *= SCALE_STEP; + } + } + else + { break; } } @@ -487,46 +511,47 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector& patches){ - TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(model)); - Size initSize=tldModel->getMinSize(); + TrackerTLDModel* tldModel = ((TrackerTLDModel*)static_cast(model)); + Size initSize = tldModel->getMinSize(); patches.clear(); Mat resized_img,blurred_img; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); img.copyTo(resized_img); imgBlurred.copyTo(blurred_img); - double originalVariance=tldModel->getOriginalVariance();; - int dx=initSize.width/10,dy=initSize.height/10; - Size2d size=img.size(); - double scale=1.0; - int total=0,pass=0; - int npos=0,nneg=0; - double tmp=0,maxSc=-5.0; + double originalVariance = tldModel->getOriginalVariance();; + int dx = initSize.width / 10, dy = initSize.height / 10; + Size2d size = img.size(); + double scale = 1.0; + int total = 0,pass = 0; + int npos = 0,nneg = 0; + double tmp = 0,maxSc = -5.0; Rect2d maxScRect; START_TICK("detector"); - do{ + do + { Mat_ intImgP,intImgP2; computeIntegralImages(resized_img,intImgP,intImgP2); tldModel->prepareClassifiers((int)blurred_img.step[0]); - for(int i=0,imax=cvFloor((0.0+resized_img.cols-initSize.width)/dx);iensembleClassifierNum(&blurred_img.at(dy*j,dx*i))>ENSEMBLE_THRESHOLD)){ + if(!(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j,dx * i)) > ENSEMBLE_THRESHOLD)){ continue; } pass++; - labPatch.rect=Rect2d(dx*i*scale,dy*j*scale,initSize.width*scale,initSize.height*scale); - resample(resized_img,Rect2d(Point(dx*i,dy*j),initSize),standardPatch); - tmp=tldModel->Sr(standardPatch); - labPatch.isObject=tmp>THETA_NN; - labPatch.shouldBeIntegrated=abs(tmp-THETA_NN)<0.1; + labPatch.rect = Rect2d(dx * i * scale,dy * j * scale,initSize.width * scale,initSize.height * scale); + resample(resized_img,Rect2d(Point(dx * i,dy * j),initSize),standardPatch); + tmp = tldModel->Sr(standardPatch); + labPatch.isObject = tmp > THETA_NN; + labPatch.shouldBeIntegrated = abs(tmp - THETA_NN) < 0.1; patches.push_back(labPatch); if(!labPatch.isObject){ @@ -535,27 +560,28 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v }else{ npos++; } - tmp=tldModel->Sc(standardPatch); - if(tmp>maxSc){ - maxSc=tmp; - maxScRect=labPatch.rect; + tmp = tldModel->Sc(standardPatch); + if(tmp > maxSc){ + maxSc = tmp; + maxScRect = labPatch.rect; } } } - size.width/=SCALE_STEP; - size.height/=SCALE_STEP; - scale*=SCALE_STEP; + size.width /= SCALE_STEP; + size.height /= SCALE_STEP; + scale *= SCALE_STEP; resize(img,resized_img,size,0,0,DOWNSCALE_MODE); GaussianBlur(resized_img,blurred_img,GaussBlurKernelSize,0.0f); - }while(size.width>=initSize.width && size.height>=initSize.height); + } + while( size.width >= initSize.width && size.height >= initSize.height ); END_TICK("detector"); - dfprintf((stdout,"after NCC: nneg=%d npos=%d\n",nneg,npos)); + dfprintf((stdout,"after NCC: nneg = %d npos = %d\n",nneg,npos)); #if !0 std::vector poss,negs; - for(int i=0;i<(int)patches.size();i++){ + for(int i = 0;i < (int)patches.size();i++){ if(patches[i].isObject) poss.push_back(patches[i].rect); else @@ -566,184 +592,198 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v #endif dfprintf((stdout,"%d after ensemble\n",pass)); - if(maxSc<0){ + if(maxSc < 0){ return false; } - res=maxScRect; + res = maxScRect; return true; } /** Computes the variance of subimage given by box, with the help of two integral * images intImgP and intImgP2 (sum of squares), which should be also provided.*/ bool TLDDetector::patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size){ - int x=(pt.x),y=(pt.y),width=(size.width),height=(size.height); - CV_Assert(0<=x && (x+width)VARIANCE_THRESHOLD*originalVariance); + return ((p2 - p * p) > VARIANCE_THRESHOLD * originalVariance); } -double TrackerTLDModel::ensembleClassifierNum(const uchar* data){ - double p=0; - for(int k=0;k<(int)classifiers.size();k++){ - p+=classifiers[k].posteriorProbabilityFast(data); - } - p/=classifiers.size(); +double TrackerTLDModel::ensembleClassifierNum(const uchar* data) +{ + double p = 0; + for( int k = 0; k < (int)classifiers.size(); k++ ) + p += classifiers[k].posteriorProbabilityFast(data); + p /= classifiers.size(); return p; } -double TrackerTLDModel::Sr(const Mat_& patch){ - 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)); - } - if(splus+sminus==0.0){ +double TrackerTLDModel::Sr(const Mat_& patch) +{ + 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)); + if( splus + sminus == 0.0) return 0.0; - } - return splus/(sminus+splus); + return splus / (sminus + splus); } -double TrackerTLDModel::Sc(const Mat_& patch){ - 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)); +double TrackerTLDModel::Sc(const Mat_& patch) +{ + 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)); } - if(splus+sminus==0.0){ + for( int i = 0; i < (int)negativeExamples.size(); i++ ) + sminus = std::max(sminus, 0.5 * (NCC(negativeExamples[i],patch) + 1.0)); + if( splus + sminus == 0.0 ) return 0.0; - } - return splus/(sminus+splus); + return splus / (sminus + splus); } -void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches){ +void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches) +{ Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(minSize_); - int positiveIntoModel=0,negativeIntoModel=0,positiveIntoEnsemble=0,negativeIntoEnsemble=0; - for(int k=0;k<(int)patches.size();k++){ - if(patches[k].shouldBeIntegrated){ + int positiveIntoModel = 0,negativeIntoModel = 0,positiveIntoEnsemble = 0,negativeIntoEnsemble = 0; + for( int k = 0; k < (int)patches.size(); k++ ) + { + if( patches[k].shouldBeIntegrated ) + { resample(img,patches[k].rect,standardPatch); - if(patches[k].isObject){ + if( patches[k].isObject ) + { positiveIntoModel++; pushIntoModel(standardPatch,true); - }else{ + } + else + { negativeIntoModel++; pushIntoModel(standardPatch,false); } } #ifdef CLOSED_LOOP - if(patches[k].shouldBeIntegrated || (patches[k].isPositive==false)){ + if( patches[k].shouldBeIntegrated || ( patches[k].isPositive == false ) ) #else - if(patches[k].shouldBeIntegrated){ + if( patches[k].shouldBeIntegrated ) #endif + { resample(imgBlurred,patches[k].rect,blurredPatch); - if(patches[k].isObject){ + if( patches[k].isObject ) positiveIntoEnsemble++; - }else{ + else negativeIntoEnsemble++; - } - for(int i=0;i<(int)classifiers.size();i++){ + for( int i = 0; i < (int)classifiers.size(); i++ ) + { 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)); + 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::integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive){ - int positiveIntoModel=0,negativeIntoModel=0,positiveIntoEnsemble=0,negativeIntoEnsemble=0; - for(int k=0;k<(int)eForModel.size();k++){ - double sr=Sr(eForModel[k]); - if((sr>THETA_NN)!=isPositive){ - if(isPositive){ +void TrackerTLDModel::integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive) +{ + int positiveIntoModel = 0,negativeIntoModel = 0,positiveIntoEnsemble = 0,negativeIntoEnsemble = 0; + for( int k = 0; k < (int)eForModel.size(); k++ ) + { + double sr = Sr(eForModel[k]); + if( ( sr > THETA_NN ) != isPositive ) + { + if( isPositive ) + { positiveIntoModel++; pushIntoModel(eForModel[k],true); - }else{ + } + else + { negativeIntoModel++; pushIntoModel(eForModel[k],false); } } - double p=0; - for(int i=0;i<(int)classifiers.size();i++){ - p+=classifiers[i].posteriorProbability(eForEnsemble[k].data,(int)eForEnsemble[k].step[0]); - } - p/=classifiers.size(); - if((p>ENSEMBLE_THRESHOLD)!=isPositive){ - if(isPositive){ + double p = 0; + for( int i = 0; i < (int)classifiers.size(); i++ ) + p += classifiers[i].posteriorProbability(eForEnsemble[k].data,(int)eForEnsemble[k].step[0]); + p /= classifiers.size(); + if( (p > ENSEMBLE_THRESHOLD) != isPositive ) + { + if( isPositive ) positiveIntoEnsemble++; - }else{ + else negativeIntoEnsemble++; - } - for(int i=0;i<(int)classifiers.size();i++){ + for( int i = 0; i < (int)classifiers.size(); i++ ) classifiers[i].integrate(eForEnsemble[k],isPositive); - } } } - 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)); + 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")); } -int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ +int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble) +{ examplesForModel.clear();examplesForEnsemble.clear(); examplesForModel.reserve(100);examplesForEnsemble.reserve(100); std::vector closest,scanGrid; Mat scaledImg,blurredImg; - double scale=scaleAndBlur(img_,cvRound(log(1.0*resultBox_.width/(initSize_.width))/log(SCALE_STEP)),scaledImg,blurredImg,GaussBlurKernelSize); + 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); + getClosestN(scanGrid,Rect2d(resultBox_.x / scale,resultBox_.y / scale,resultBox_.width / scale,resultBox_.height / scale),10,closest); - for(int i=0;i<(int)closest.size();i++){ - for(int j=0;j<10;j++){ + for( int i = 0; i < (int)closest.size(); i++ ) + { + for( int j = 0; j < 10; j++ ) + { Point2f center; Size2f size; Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(initSize_); - center.x=(float)(closest[i].x+closest[i].width*(0.5+rng.uniform(-0.01,0.01))); - center.y=(float)(closest[i].y+closest[i].height*(0.5+rng.uniform(-0.01,0.01))); - size.width=(float)(closest[i].width*rng.uniform((double)0.99,(double)1.01)); - size.height=(float)(closest[i].height*rng.uniform((double)0.99,(double)1.01)); - float angle=(float)rng.uniform(-5.0,5.0); - - for(int y=0;y >& examp return 0; } -bool TrackerTLDImpl::Nexpert::operator()(Rect2d box){ - if(overlap(resultBox_,box)<0.2){ +bool TrackerTLDImpl::Nexpert::operator()(Rect2d box) +{ + if( overlap(resultBox_,box) < NEXPERT_THRESHOLD ) return false; - } - return true; + else + return true; } -Data::Data(Rect2d initBox){ - double minDim=std::min(initBox.width,initBox.height); - scale = 20.0/minDim; - minSize.width=(int)(initBox.width*20.0/minDim); - minSize.height=(int)(initBox.height*20.0/minDim); - frameNum=0; - dprintf(("minSize= %dx%d\n",minSize.width,minSize.height)); +Data::Data(Rect2d initBox) +{ + double minDim = std::min(initBox.width,initBox.height); + scale = 20.0 / minDim; + minSize.width = (int)(initBox.width * 20.0 / minDim); + minSize.height = (int)(initBox.height * 20.0 / minDim); + frameNum = 0; + dprintf(("minSize = %dx%d\n",minSize.width,minSize.height)); } -void Data::printme(FILE* port){ +void Data::printme(FILE* port) +{ dfprintf((port,"Data:\n")); - dfprintf((port,"\tframeNum=%d\n",frameNum)); - dfprintf((port,"\tconfident=%s\n",confident?"true":"false")); - dfprintf((port,"\tfailedLastTime=%s\n",failedLastTime?"true":"false")); - dfprintf((port,"\tminSize=%dx%d\n",minSize.width,minSize.height)); + dfprintf((port,"\tframeNum = %d\n",frameNum)); + dfprintf((port,"\tconfident = %s\n",confident?"true":"false")); + dfprintf((port,"\tfailedLastTime = %s\n",failedLastTime?"true":"false")); + dfprintf((port,"\tminSize = %dx%d\n",minSize.width,minSize.height)); } -void TrackerTLDModel::printme(FILE* port){ + +void TrackerTLDModel::printme(FILE* port) +{ dfprintf((port,"TrackerTLDModel:\n")); - dfprintf((port,"\tpositiveExamples.size()=%d\n",(int)positiveExamples.size())); - dfprintf((port,"\tnegativeExamples.size()=%d\n",(int)negativeExamples.size())); + dfprintf((port,"\tpositiveExamples.size() = %d\n",(int)positiveExamples.size())); + dfprintf((port,"\tnegativeExamples.size() = %d\n",(int)negativeExamples.size())); } -void MyMouseCallbackDEBUG::onMouse( int event, int x, int y){ - if(event== EVENT_LBUTTONDOWN){ + +void MyMouseCallbackDEBUG::onMouse( int event, int x, int y) +{ + if( event == EVENT_LBUTTONDOWN ) + { Mat imgCanvas; img_.copyTo(imgCanvas); - TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast(detector_->model)); - Size initSize=tldModel->getMinSize(); + TrackerTLDModel* tldModel = ((TrackerTLDModel*)static_cast(detector_->model)); + Size initSize = tldModel->getMinSize(); Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); - double originalVariance=tldModel->getOriginalVariance();; + double originalVariance = tldModel->getOriginalVariance();; double tmp; Mat resized_img,blurred_img; - double scale=SCALE_STEP; - //double scale=SCALE_STEP*SCALE_STEP*SCALE_STEP*SCALE_STEP; - Size2d size(img_.cols/scale,img_.rows/scale); + double scale = SCALE_STEP; + //double scale = SCALE_STEP * SCALE_STEP * SCALE_STEP * SCALE_STEP; + Size2d size(img_.cols / scale,img_.rows / scale); resize(img_,resized_img,size); resize(imgBlurred_,blurred_img,size); Mat_ intImgP,intImgP2; detector_->computeIntegralImages(resized_img,intImgP,intImgP2); - int dx=initSize.width/10, dy=initSize.height/10, - i=(int)(x/scale/dx), j=(int)(y/scale/dy); + int dx = initSize.width / 10, dy = initSize.height / 10, + i = (int)(x / scale / dx), j = (int)(y / scale / dy); - dfprintf((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")); tldModel->prepareClassifiers((int)blurred_img.step[0]); - dfprintf((stderr,"p=%f\n",(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i))))); - fprintf(stderr,"ensembleClassifier=%s\n", - (!(tldModel->ensembleClassifierNum(&blurred_img.at(dy*j,dx*i))>ENSEMBLE_THRESHOLD))?"true":"false"); - - resample(resized_img,Rect2d(Point(dx*i,dy*j),initSize),standardPatch); - tmp=tldModel->Sr(standardPatch); - dfprintf((stderr,"Sr=%f\n",tmp)); - dfprintf((stderr,"isObject=%s\n",(tmp>THETA_NN)?"true":"false")); - dfprintf((stderr,"shouldBeIntegrated=%s\n",(abs(tmp-THETA_NN)<0.1)?"true":"false")); - 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 ); + dfprintf((stderr,"p = %f\n",(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j,dx * i))))); + fprintf(stderr,"ensembleClassifier = %s\n", + (!(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j,dx * i)) > ENSEMBLE_THRESHOLD))?"true":"false"); + + resample(resized_img,Rect2d(Point(dx * i,dy * j),initSize),standardPatch); + tmp = tldModel->Sr(standardPatch); + dfprintf((stderr,"Sr = %f\n",tmp)); + dfprintf((stderr,"isObject = %s\n",(tmp > THETA_NN)?"true":"false")); + dfprintf((stderr,"shouldBeIntegrated = %s\n",(abs(tmp - THETA_NN) < 0.1)?"true":"false")); + 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 ); imshow("picker",imgCanvas); waitKey(); } } -void TrackerTLDModel::pushIntoModel(const Mat_& example,bool positive){ + +void TrackerTLDModel::pushIntoModel(const Mat_& example, bool positive) +{ std::vector >* proxyV; - unsigned int* proxyN; - std::vector* proxyT; - if(positive){ - proxyV=&positiveExamples; - proxyN=&timeStampPositiveNext; - proxyT=&timeStampsPositive; - }else{ - proxyV=&negativeExamples; - proxyN=&timeStampNegativeNext; - proxyT=&timeStampsNegative; + int* proxyN; + std::vector* proxyT; + if( positive ) + { + proxyV = &positiveExamples; + proxyN = &timeStampPositiveNext; + proxyT = &timeStampsPositive; } - if(proxyV->size()size() < MAX_EXAMPLES_IN_MODEL ) + { proxyV->push_back(example); proxyT->push_back(*proxyN); - }else{ - int index=rng.uniform((int)0,(int)proxyV->size()); - (*proxyV)[index]=example; - (*proxyT)[index]=(*proxyN); + } + else + { + int index = rng.uniform((int)0,(int)proxyV->size()); + (*proxyV)[index] = example; + (*proxyT)[index] = (*proxyN); } (*proxyN)++; } diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index 4acd81175..7215bbb39 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -42,8 +42,8 @@ #include "precomp.hpp" #include "opencv2/video/tracking.hpp" #include "opencv2/imgproc.hpp" -#include -#include +#include +#include namespace cv {namespace tld { @@ -58,22 +58,21 @@ namespace cv {namespace tld #define dprintf(x) #endif #define MEASURE_TIME(a) {\ - clock_t start;float milisec=0.0;\ - start=clock();{a} milisec=1000.0*(clock()-start)/CLOCKS_PER_SEC;\ + clock_t start;float milisec = 0.0;\ + start = clock();{a} milisec = 1000.0 * (clock() - start) / CLOCKS_PER_SEC;\ dprintf(("%-90s took %f milis\n",#a,milisec)); } #define HERE dprintf(("line %d\n",__LINE__));fflush(stderr); -#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 START_TICK(name) { clock_t start;double milisec = 0.0; start = clock(); +#define END_TICK(name) milisec = 1000.0 * (clock() - start) / CLOCKS_PER_SEC;\ dprintf(("%s took %f milis\n",name,milisec)); } extern Rect2d etalon; void myassert(const Mat& img); void printPatch(const Mat_& standardPatch); std::string type2str(const Mat& mat); -void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne=Rect2d(-1.0,-1.0,-1.0,-1.0)); -void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String fileName=""); +void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne = Rect2d(-1.0,-1.0,-1.0,-1.0)); +void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String fileName = ""); //aux functions and variables -//#define CLIP(x,a,b) std::min(std::max((x),(a)),(b)) template inline T CLIP(T x,T a,T b){return std::min(std::max(x,a),b);} /** Computes overlap between the two given rectangles. Overlap is computed as ratio of rectangles' intersection to that * of their union.*/ @@ -88,8 +87,8 @@ double variance(const Mat& img); * of the same size).*/ double NCC(const Mat_& patch1,const Mat_& patch2); void getClosestN(std::vector& scanGrid,Rect2d bBox,int n,std::vector& res); -double scaleAndBlur(const Mat& originalImg,int scale,Mat& scaledImg,Mat& blurredImg,Size GaussBlurKernelSize); -unsigned int getMedian(const std::vector& values, int size=-1); +double scaleAndBlur(const Mat& originalImg,int scale,Mat& scaledImg,Mat& blurredImg,Size GaussBlurKernelSize, double scaleStep); +int getMedian(const std::vector& values, int size = -1); class TLDEnsembleClassifier{ public: @@ -99,8 +98,8 @@ public: double posteriorProbabilityFast(const uchar* data)const; void prepareClassifier(int rowstep); private: - TLDEnsembleClassifier(std::vector meas,int beg,int end); - static void stepPrefSuff(std::vector& arr,int pos,int len,int gridSize); + TLDEnsembleClassifier(const std::vector& meas,int beg,int end); + static void stepPrefSuff(std::vector & arr,int pos,int len,int gridSize); int code(const uchar* data,int rowstep)const; int codeFast(const uchar* data)const; std::vector posAndNeg; @@ -111,8 +110,8 @@ private: class TrackerProxy{ public: - virtual bool init( const Mat& image, const Rect2d& boundingBox)=0; - virtual bool update(const Mat& image, Rect2d& boundingBox)=0; + virtual bool init( const Mat& image, const Rect2d& boundingBox) = 0; + virtual bool update(const Mat& image, Rect2d& boundingBox) = 0; virtual ~TrackerProxy(){} }; diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index f26d1dc53..1f9254622 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -43,10 +43,10 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/imgproc.hpp" #include "time.h" -#include -#include -#include -#include +#include +#include +#include +#include #include "tld_tracker.hpp" namespace cv {namespace tld @@ -57,26 +57,26 @@ Rect2d etalon(14.0,110.0,20.0,20.0); void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne){ Mat image; img.copyTo(image); - if(whiteOne.width>=0){ + if(whiteOne.width >= 0){ rectangle( image,whiteOne, 255, 1, 1 ); } - for(int i=0;i<(int)blackOnes.size();i++){ + for(int i = 0;i < (int)blackOnes.size();i++){ rectangle( image,blackOnes[i], 0, 1, 1 ); } imshow("img",image); } void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String filename){ Mat image; - static int frameCounter=1; + static int frameCounter = 1; img.copyTo(image); - for(int i=0;i<(int)whiteOnes.size();i++){ + for(int i = 0;i < (int)whiteOnes.size();i++){ rectangle( image,whiteOnes[i], 255, 1, 1 ); } - for(int i=0;i<(int)blackOnes.size();i++){ + for(int i = 0;i < (int)blackOnes.size();i++){ rectangle( image,blackOnes[i], 0, 1, 1 ); } imshow("img",image); - if(filename.length()>0){ + if(filename.length() > 0){ char inbuf[100]; sprintf(inbuf,"%s%d.jpg",filename.c_str(),frameCounter); imwrite(inbuf,image); @@ -84,20 +84,20 @@ void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector(i,j)==0){ + int count = 0; + for(int i = 0;i < img.rows;i++){ + for(int j = 0;j < img.cols;j++){ + if(img.at(i,j) == 0){ count++; } } } - dprintf(("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_& standardPatch){ - for(int i=0;i& standardPatch){ } std::string type2str(const Mat& mat){ - int type=mat.type(); + int type = mat.type(); std::string r; uchar depth = type & CV_MAT_DEPTH_MASK; - uchar chans =(uchar)( 1 + (type >> CV_CN_SHIFT)); + uchar chans = (uchar)(1 + (type >> CV_CN_SHIFT)); switch ( depth ) { case CV_8U: r = "8U"; break; @@ -123,31 +123,31 @@ std::string type2str(const Mat& mat){ } r += "C"; - r += (chans+'0'); + r += (chans + '0'); return r; } //generic functions -double scaleAndBlur(const Mat& originalImg,int scale,Mat& scaledImg,Mat& blurredImg,Size GaussBlurKernelSize){ - double dScale=1.0; - for(int i=0;i& scanGrid,Rect2d bBox,int n,std::vector& res){ - if(n>=(int)scanGrid.size()){ + if(n >= (int)scanGrid.size()){ res.assign(scanGrid.begin(),scanGrid.end()); return; } std::vector overlaps; overlaps.assign(n,0.0); - res.assign(scanGrid.begin(),scanGrid.begin()+n); - for(int i=0;i& scanGrid,Rect2d bBox,int n,std::vector(i,j); - p2+=img.at(i,j)*img.at(i,j); + double p = 0,p2 = 0; + for(int i = 0;i < img.rows;i++){ + for(int j = 0;j < img.cols;j++){ + p += img.at(i,j); + p2 += img.at(i,j) * img.at(i,j); } } - p/=(img.cols*img.rows); - p2/=(img.cols*img.rows); - return p2-p*p; + p /= (img.cols * img.rows); + p2 /= (img.cols * img.rows); + return p2 - p * p; } double NCC(const Mat_& patch1,const Mat_& patch2){ - CV_Assert(patch1.rows==patch2.rows); - CV_Assert(patch1.cols==patch2.cols); + CV_Assert(patch1.rows == patch2.rows); + CV_Assert(patch1.cols == patch2.cols); - int N=patch1.rows*patch1.cols; - int s1=0,s2=0,n1=0,n2=0,prod=0; - for(int i=0;i& values, int size){ - if(size==-1){ - size=(int)values.size(); +int getMedian(const std::vector& values, int size){ + if(size == -1){ + size = (int)values.size(); } - std::vector copy(values.begin(),values.begin()+size); + std::vector copy(values.begin(),values.begin() + size); std::sort(copy.begin(),copy.end()); - if(size%2==0){ - return (copy[size/2-1]+copy[size/2])/2; + if(size % 2 == 0){ + return (copy[size / 2 - 1] + copy[size / 2]) / 2; }else{ - return copy[(size-1)/2]; + return copy[(size - 1) / 2]; } } double overlap(const Rect2d& r1,const Rect2d& r2){ - double a1=r1.area(), a2=r2.area(), a0=(r1&r2).area(); - return a0/(a1+a2-a0); + double a1 = r1.area(), a2 = r2.area(), a0 = (r1&r2).area(); + return a0 / (a1 + a2 - a0); } void resample(const Mat& img,const RotatedRect& r2,Mat_& samples){ Mat_ M(2,3),R(2,2),Si(2,2),s(2,1),o(2,1); - R(0,0)=(float)cos(r2.angle*CV_PI/180);R(0,1)=(float)(-sin(r2.angle*CV_PI/180)); - R(1,0)=(float)sin(r2.angle*CV_PI/180);R(1,1)=(float)cos(r2.angle*CV_PI/180); - Si(0,0)=(float)(samples.cols/r2.size.width); Si(0,1)=0.0f; - Si(1,0)=0.0f; Si(1,1)=(float)(samples.rows/r2.size.height); - s(0,0)=(float)samples.cols; s(1,0)=(float)samples.rows; - o(0,0)=r2.center.x;o(1,0)=r2.center.y; + R(0,0) = (float)cos(r2.angle * CV_PI / 180);R(0,1) = (float)(-sin(r2.angle * CV_PI / 180)); + R(1,0) = (float)sin(r2.angle * CV_PI / 180);R(1,1) = (float)cos(r2.angle * CV_PI / 180); + Si(0,0) = (float)(samples.cols / r2.size.width); Si(0,1) = 0.0f; + Si(1,0) = 0.0f; Si(1,1) = (float)(samples.rows / r2.size.height); + s(0,0) = (float)samples.cols; s(1,0) = (float)samples.rows; + o(0,0) = r2.center.x;o(1,0) = r2.center.y; Mat_ A(2,2),b(2,1); - A=Si*R; - b=s/2.0-Si*R*o; + A = Si * R; + b = s / 2.0 - Si * R * o; A.copyTo(M.colRange(Range(0,2))); b.copyTo(M.colRange(Range(2,3))); warpAffine(img,samples,M,samples.size()); } void resample(const Mat& img,const Rect2d& r2,Mat_& samples){ Mat_ M(2,3); - M(0,0)=(float)(samples.cols/r2.width); M(0,1)=0.0f; M(0,2)=(float)(-r2.x*samples.cols/r2.width); - M(1,0)=0.0f; M(1,1)=(float)(samples.rows/r2.height); M(1,2)=(float)(-r2.y*samples.rows/r2.height); + M(0,0) = (float)(samples.cols / r2.width); M(0,1) = 0.0f; M(0,2) = (float)(-r2.x * samples.cols / r2.width); + M(1,0) = 0.0f; M(1,1) = (float)(samples.rows / r2.height); M(1,2) = (float)(-r2.y * samples.rows / r2.height); warpAffine(img,samples,M,samples.size()); } //other stuff void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int pos,int len,int gridSize){ #if 0 - int step=len/(gridSize-1), pref=(len-step*(gridSize-1))/2; - for(int i=0;i<(int)(sizeof(x1)/sizeof(x1[0]));i++){ - arr[i]=pref+arr[i]*step; + int step = len / (gridSize - 1), pref = (len - step * (gridSize - 1)) / 2; + for(int i = 0;i < (int)(sizeof(x1) / sizeof(x1[0]));i++){ + arr[i] = pref + arr[i] * step; } #else - int total=len-gridSize; - int quo=total/(gridSize-1),rem=total%(gridSize-1); - int smallStep=quo,bigStep=quo+1; - int bigOnes=rem,smallOnes=gridSize-bigOnes-1; - int bigOnes_front=bigOnes/2,bigOnes_back=bigOnes-bigOnes_front; - for(int i=0;i<(int)arr.size();i++){ - if(arr[i].val[pos] meas,int beg,int end):lastStep_(-1){ - int posSize=1,mpc=end-beg; - for(int i=0;i& meas,int beg,int end):lastStep_(-1){ + int posSize = 1, mpc = end - beg; + for( int i = 0; i < mpc; i++ ) + posSize *= 2; posAndNeg.assign(posSize,Point2i(0,0)); - measurements.assign(meas.begin()+beg,meas.begin()+end); + measurements.assign(meas.begin() + beg,meas.begin() + end); offset.assign(mpc,Point2i(0,0)); } void TLDEnsembleClassifier::integrate(const Mat_& patch,bool isPositive){ - int position=code(patch.data,(int)patch.step[0]); + int position = code(patch.data,(int)patch.step[0]); if(isPositive){ posAndNeg[position].x++; }else{ @@ -303,38 +305,40 @@ void TLDEnsembleClassifier::integrate(const Mat_& patch,bool isPositive){ } } double TLDEnsembleClassifier::posteriorProbability(const uchar* data,int rowstep)const{ - int position=code(data,rowstep); - double posNum=(double)posAndNeg[position].x, negNum=(double)posAndNeg[position].y; - if(posNum==0.0 && negNum==0.0){ + int position = code(data,rowstep); + double posNum = (double)posAndNeg[position].x, negNum = (double)posAndNeg[position].y; + if(posNum == 0.0 && negNum == 0.0){ return 0.0; }else{ - return posNum/(posNum+negNum); + return posNum / (posNum + negNum); } } double TLDEnsembleClassifier::posteriorProbabilityFast(const uchar* data)const{ - int position=codeFast(data); - double posNum=(double)posAndNeg[position].x, negNum=(double)posAndNeg[position].y; - if(posNum==0.0 && negNum==0.0){ + int position = codeFast(data); + double posNum = (double)posAndNeg[position].x, negNum = (double)posAndNeg[position].y; + if(posNum == 0.0 && negNum == 0.0){ return 0.0; }else{ - return posNum/(posNum+negNum); + return posNum / (posNum + negNum); } } int TLDEnsembleClassifier::codeFast(const uchar* data)const{ - int position=0; - for(int i=0;i<(int)measurements.size();i++){ - position=position<<1; - if(data[offset[i].x] measurements; - for(int i=0;i Date: Tue, 5 Aug 2014 17:45:38 +0300 Subject: [PATCH 17/26] coding style --- modules/tracking/src/tld_tracker.cpp | 664 ++++++++++++++------------- modules/tracking/src/tld_tracker.hpp | 63 +-- modules/tracking/src/tld_utils.cpp | 318 +++++++------ 3 files changed, 552 insertions(+), 493 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 38a400288..2508e326d 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -62,7 +62,7 @@ #define DOWNSCALE_MODE INTER_LINEAR #define BLUR_AS_VADIM #undef CLOSED_LOOP -static const cv::Size GaussBlurKernelSize(3,3); +static const cv::Size GaussBlurKernelSize(3, 3); using namespace cv; using namespace tld; @@ -88,18 +88,12 @@ using namespace tld; * 11. group decls logically, order of statements * * ?10. all in one class -* todo: initializer lists -* -* format: if,while,for, , Assert -* format: methods -* --> compile -* ; , -* --> compile -* -->commit-push -->notify +* todo: initializer lists; const methods * * ?( ) * -* ?vadim: for{1command} can omit {}; if( a != (b + c) ) vs ( a != ( b + c ) ) +* ?vadim: for{1command} can omit {}; if( a != (b + c) ) vs ( a != ( b + c ) ); if{} for{} method{} oneline:spaces, omit{}; +* 1-statement for/if without {} */ /* design decisions: @@ -109,24 +103,24 @@ namespace cv { class TLDDetector; -class MyMouseCallbackDEBUG{ +class MyMouseCallbackDEBUG +{ public: - MyMouseCallbackDEBUG( Mat& img, Mat& imgBlurred,TLDDetector* detector):img_(img),imgBlurred_(imgBlurred),detector_(detector){} - static void onMouse( int event, int x, int y, int, void* obj){ - ((MyMouseCallbackDEBUG*)obj)->onMouse(event,x,y); - } - MyMouseCallbackDEBUG& operator = (const MyMouseCallbackDEBUG& /*other*/){return *this;} + MyMouseCallbackDEBUG(Mat& img, Mat& imgBlurred, TLDDetector* detector):img_(img), imgBlurred_(imgBlurred), detector_(detector){} + static void onMouse(int event, int x, int y, int, void* obj){ ((MyMouseCallbackDEBUG*)obj)->onMouse(event, x, y); } + MyMouseCallbackDEBUG& operator = (const MyMouseCallbackDEBUG& /*other*/){ return *this; } private: - void onMouse( int event, int x, int y); - Mat& img_,imgBlurred_; + void onMouse(int event, int x, int y); + Mat& img_, imgBlurred_; TLDDetector* detector_; }; -class Data { +class Data +{ public: Data(Rect2d initBox); - Size getMinSize(){return minSize;} - double getScale(){return scale;} + Size getMinSize(){ return minSize; } + double getScale(){ return scale; } bool confident; bool failedLastTime; int frameNum; @@ -136,35 +130,39 @@ private: Size minSize; }; -class TLDDetector { +class TLDDetector +{ public: - TLDDetector(const TrackerTLD::Params& params,Ptr model_in):model(model_in),params_(params){} + TLDDetector(const TrackerTLD::Params& params, Ptr model_in):model(model_in), params_(params){} ~TLDDetector(){} - static void generateScanGrid(int rows,int cols,Size initBox,std::vector& res,bool withScaling = false); - struct LabeledPatch{ + static void generateScanGrid(int rows, int cols, Size initBox, std::vector& res, bool withScaling = false); + struct LabeledPatch + { Rect2d rect; bool isObject, shouldBeIntegrated; }; - bool detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::vector& patches); + bool detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector& patches); protected: friend class MyMouseCallbackDEBUG; Ptr model; - void computeIntegralImages(const Mat& img,Mat_& intImgP,Mat_& intImgP2){integral(img,intImgP,intImgP2,CV_64F);} - inline bool patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size); + void computeIntegralImages(const Mat& img, Mat_& intImgP, Mat_& intImgP2){ integral(img, intImgP, intImgP2, CV_64F); } + inline bool patchVariance(Mat_& intImgP, Mat_& intImgP2, double originalVariance, Point pt, Size size); TrackerTLD::Params params_; }; - template -class TrackerProxyImpl : public TrackerProxy{ +class TrackerProxyImpl : public TrackerProxy +{ public: TrackerProxyImpl(Tparams params = Tparams()):params_(params){} - bool init( const Mat& image, const Rect2d& boundingBox ){ + bool init(const Mat& image, const Rect2d& boundingBox) + { trackerPtr = T::createTracker(); - return trackerPtr->init(image,boundingBox); + return trackerPtr->init(image, boundingBox); } - bool update( const Mat& image,Rect2d& boundingBox){ - return trackerPtr->update(image,boundingBox); + bool update(const Mat& image, Rect2d& boundingBox) + { + return trackerPtr->update(image, boundingBox); } private: Ptr trackerPtr; @@ -172,53 +170,55 @@ private: Rect2d boundingBox_; }; -class TrackerTLDModel : public TrackerModel{ - public: - TrackerTLDModel(TrackerTLD::Params params,const Mat& image, const Rect2d& boundingBox,Size minSize); - Rect2d getBoundingBox(){return boundingBox_;} - void setBoudingBox(Rect2d boundingBox){boundingBox_ = boundingBox;} - double getOriginalVariance(){return originalVariance_;} +class TrackerTLDModel : public TrackerModel +{ +public: + TrackerTLDModel(TrackerTLD::Params params, const Mat& image, const Rect2d& boundingBox, Size minSize); + Rect2d getBoundingBox(){ return boundingBox_; } + void setBoudingBox(Rect2d boundingBox){ boundingBox_ = boundingBox; } + double getOriginalVariance(){ return originalVariance_; } inline double ensembleClassifierNum(const uchar* data); - inline void prepareClassifiers(int rowstep){for(int i = 0;i < (int)classifiers.size();i++)classifiers[i].prepareClassifier(rowstep);} + inline void prepareClassifiers(int rowstep){ for( int i = 0; i < (int)classifiers.size(); i++ ) classifiers[i].prepareClassifier(rowstep); } double Sr(const Mat_& patch); double Sc(const Mat_& patch); - void integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches); - void integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive); - Size getMinSize(){return minSize_;} - void printme(FILE* port = stdout); + void integrateRelabeled(Mat& img, Mat& imgBlurred, const std::vector& patches); + void integrateAdditional(const std::vector >& eForModel, const std::vector >& eForEnsemble, bool isPositive); + Size getMinSize(){ return minSize_; } + void printme(FILE* port = stdout); - protected: +protected: Size minSize_; - int timeStampPositiveNext,timeStampNegativeNext; + int timeStampPositiveNext, timeStampNegativeNext; TrackerTLD::Params params_; - void pushIntoModel(const Mat_& example,bool positive); + void pushIntoModel(const Mat_& example, bool positive); void modelEstimationImpl( const std::vector& /*responses*/ ){} void modelUpdateImpl(){} Rect2d boundingBox_; double originalVariance_; - std::vector > positiveExamples,negativeExamples; - std::vector timeStampsPositive,timeStampsNegative; + std::vector > positiveExamples, negativeExamples; + std::vector timeStampsPositive, timeStampsNegative; RNG rng; std::vector classifiers; }; class TrackerTLDImpl : public TrackerTLD { - public: - TrackerTLDImpl( const TrackerTLD::Params ¶meters = TrackerTLD::Params() ); - void read( const FileNode& fn ); - void write( FileStorage& fs ) const; +public: + TrackerTLDImpl(const TrackerTLD::Params ¶meters = TrackerTLD::Params()); + void read(const FileNode& fn); + void write(FileStorage& fs) const; - protected: - class Pexpert{ +protected: + class Pexpert + { public: - Pexpert(const Mat& img,const Mat& imgBlurred,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params,Size initSize): - img_(img),imgBlurred_(imgBlurred),resultBox_(resultBox),detector_(detector),params_(params),initSize_(initSize){} - bool operator()(Rect2d /*box*/){return false;} - int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble); + Pexpert(const Mat& img, const Mat& imgBlurred, Rect2d& resultBox, const TLDDetector* detector, TrackerTLD::Params params, Size initSize): + img_(img), imgBlurred_(imgBlurred), resultBox_(resultBox), detector_(detector), params_(params), initSize_(initSize){} + bool operator()(Rect2d /*box*/){ return false; } + int additionalExamples(std::vector >& examplesForModel, std::vector >& examplesForEnsemble); protected: Pexpert(){} - Mat img_,imgBlurred_; + Mat img_, imgBlurred_; Rect2d resultBox_; const TLDDetector* detector_; TrackerTLD::Params params_; @@ -226,17 +226,22 @@ class TrackerTLDImpl : public TrackerTLD Size initSize_; }; - class Nexpert : public Pexpert{ + class Nexpert : public Pexpert + { public: - Nexpert(const Mat& img,Rect2d& resultBox,const TLDDetector* detector,TrackerTLD::Params params){ - img_ = img; resultBox_ = resultBox; detector_ = detector; params_ = params;} + Nexpert(const Mat& img, Rect2d& resultBox, const TLDDetector* detector, TrackerTLD::Params params) + { + img_ = img; resultBox_ = resultBox; detector_ = detector; params_ = params; + } bool operator()(Rect2d box); - int additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble){ - examplesForModel.clear();examplesForEnsemble.clear();return 0;} + int additionalExamples(std::vector >& examplesForModel, std::vector >& examplesForEnsemble) + { + examplesForModel.clear(); examplesForEnsemble.clear(); return 0; + } }; - bool initImpl( const Mat& image, const Rect2d& boundingBox ); - bool updateImpl( const Mat& image, Rect2d& boundingBox ); + bool initImpl(const Mat& image, const Rect2d& boundingBox); + bool updateImpl(const Mat& image, Rect2d& boundingBox); TrackerTLD::Params params; Ptr data; @@ -244,75 +249,74 @@ class TrackerTLDImpl : public TrackerTLD Ptr detector; }; +TrackerTLD::Params::Params(){} -TrackerTLD::Params::Params(){ -} - -void TrackerTLD::Params::read( const cv::FileNode& /*fn*/ ){ -} +void TrackerTLD::Params::read(const cv::FileNode& /*fn*/){} -void TrackerTLD::Params::write( cv::FileStorage& /*fs*/ ) const{ -} +void TrackerTLD::Params::write(cv::FileStorage& /*fs*/) const {} -Ptr TrackerTLD::createTracker(const TrackerTLD::Params ¶meters){ +Ptr TrackerTLD::createTracker(const TrackerTLD::Params ¶meters) +{ return Ptr(new TrackerTLDImpl(parameters)); } TrackerTLDImpl::TrackerTLDImpl(const TrackerTLD::Params ¶meters) : - params( parameters ){ + params( parameters ) +{ isInit = false; - trackerProxy = Ptr > - (new TrackerProxyImpl()); + trackerProxy = Ptr > + (new TrackerProxyImpl()); } -void TrackerTLDImpl::read( const cv::FileNode& fn ) +void TrackerTLDImpl::read(const cv::FileNode& fn) { params.read( fn ); } -void TrackerTLDImpl::write( cv::FileStorage& fs ) const +void TrackerTLDImpl::write(cv::FileStorage& fs) const { params.write( fs ); } -bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox ){ +bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox) +{ Mat image_gray; - trackerProxy->init(image,boundingBox); + trackerProxy->init(image, boundingBox); cvtColor( image, image_gray, COLOR_BGR2GRAY ); data = Ptr(new Data(boundingBox)); double scale = data->getScale(); Rect2d myBoundingBox = boundingBox; - if(scale > 1.0) + if( scale > 1.0 ) { Mat image_proxy; - resize(image_gray,image_proxy,Size(cvRound(image.cols * scale),cvRound(image.rows * scale)),0,0,DOWNSCALE_MODE); + resize(image_gray, image_proxy, Size(cvRound(image.cols * scale), cvRound(image.rows * scale)), 0, 0, DOWNSCALE_MODE); image_proxy.copyTo(image_gray); myBoundingBox.x *= scale; myBoundingBox.y *= scale; myBoundingBox.width *= scale; myBoundingBox.height *= scale; } - model = Ptr(new TrackerTLDModel(params,image_gray,myBoundingBox,data->getMinSize())); - detector = Ptr(new TLDDetector(params,model)); + model = Ptr(new TrackerTLDModel(params, image_gray, myBoundingBox, data->getMinSize())); + detector = Ptr(new TLDDetector(params, model)); data->confident = false; data->failedLastTime = false; return true; } -bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ - Mat image_gray,image_blurred,imageForDetector; +bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) +{ + Mat image_gray, image_blurred, imageForDetector; cvtColor( image, image_gray, COLOR_BGR2GRAY ); double scale = data->getScale(); - if(scale > 1.0){ - resize(image_gray,imageForDetector,Size(cvRound(image.cols*scale),cvRound(image.rows*scale)),0,0,DOWNSCALE_MODE); - }else{ + if( scale > 1.0 ) + resize(image_gray, imageForDetector, Size(cvRound(image.cols*scale), cvRound(image.rows*scale)), 0, 0, DOWNSCALE_MODE); + else imageForDetector = image_gray; - } - GaussianBlur(imageForDetector,image_blurred,GaussBlurKernelSize,0.0); + GaussianBlur(imageForDetector, image_blurred, GaussBlurKernelSize, 0.0); TrackerTLDModel* tldModel = ((TrackerTLDModel*)static_cast(model)); data->frameNum++; - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); std::vector detectorResults; //best overlap around 92% @@ -322,169 +326,187 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){ for( int i = 0; i < 2; i++ ) { Rect2d tmpCandid = boundingBox; - if(((i == 0)&& !(data->failedLastTime)&& trackerProxy->update(image,tmpCandid)) || - ((i == 1)&& (detector->detect(imageForDetector,image_blurred,tmpCandid,detectorResults)))){ + if( ( (i == 0) && !(data->failedLastTime) && trackerProxy->update(image, tmpCandid) ) || + ( (i == 1) && detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults) ) ) + { candidates.push_back(tmpCandid); - if(i == 0){ - resample(image_gray,tmpCandid,standardPatch); - }else{ - resample(imageForDetector,tmpCandid,standardPatch); - } + if( i == 0 ) + resample(image_gray, tmpCandid, standardPatch); + else + resample(imageForDetector, tmpCandid, standardPatch); candidatesRes.push_back(tldModel->Sc(standardPatch)); - }else{ - if(i == 0){ + } + else + { + if( i == 0 ) trackerNeedsReInit = true; - } } } - std::vector::iterator it = std::max_element(candidatesRes.begin(),candidatesRes.end()); + std::vector::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])); - } + 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->failedLastTime = true; return false; - }else{ + } + else + { boundingBox = candidates[it - candidatesRes.begin()]; data->failedLastTime = false; - if(trackerNeedsReInit || it != candidatesRes.begin()){ - trackerProxy->init(image,boundingBox); - } + if( trackerNeedsReInit || it != candidatesRes.begin() ) + trackerProxy->init(image, boundingBox); } #if 1 - if(it != candidatesRes.end()){ - 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)); + if( it != candidatesRes.end() ) + { + 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 - if(*it > CORE_THRESHOLD){ + if( *it > CORE_THRESHOLD ) data->confident = true; - } - if(data->confident){ - Pexpert pExpert(imageForDetector,image_blurred,boundingBox,detector,params,data->getMinSize()); - Nexpert nExpert(imageForDetector,boundingBox,detector,params); - std::vector > examplesForModel,examplesForEnsemble; - examplesForModel.reserve(100);examplesForEnsemble.reserve(100); + if( data->confident ) + { + Pexpert pExpert(imageForDetector, image_blurred, boundingBox, detector, params, data->getMinSize()); + Nexpert nExpert(imageForDetector, boundingBox, detector, params); + std::vector > examplesForModel, examplesForEnsemble; + examplesForModel.reserve(100); examplesForEnsemble.reserve(100); int negRelabeled = 0; - for(int i = 0;i < (int)detectorResults.size();i++){ + for( int i = 0; i < (int)detectorResults.size(); i++ ) + { bool expertResult; - if(detectorResults[i].isObject){ + if( detectorResults[i].isObject ) + { expertResult = nExpert(detectorResults[i].rect); - if(expertResult != detectorResults[i].isObject){negRelabeled++;} - }else{ + if( expertResult != detectorResults[i].isObject ){ negRelabeled++; } + } + else + { expertResult = pExpert(detectorResults[i].rect); } detectorResults[i].shouldBeIntegrated = detectorResults[i].shouldBeIntegrated || (detectorResults[i].isObject != expertResult); detectorResults[i].isObject = expertResult; } - tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults); - dprintf(("%d relabeled by nExpert\n",negRelabeled)); - pExpert.additionalExamples(examplesForModel,examplesForEnsemble); - tldModel->integrateAdditional(examplesForModel,examplesForEnsemble,true); - examplesForModel.clear();examplesForEnsemble.clear(); - nExpert.additionalExamples(examplesForModel,examplesForEnsemble); - tldModel->integrateAdditional(examplesForModel,examplesForEnsemble,false); - }else{ + tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults); + dprintf(("%d relabeled by nExpert\n", negRelabeled)); + pExpert.additionalExamples(examplesForModel, examplesForEnsemble); + tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, true); + examplesForModel.clear(); examplesForEnsemble.clear(); + nExpert.additionalExamples(examplesForModel, examplesForEnsemble); + tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, false); + } + else + { #ifdef CLOSED_LOOP - tldModel->integrateRelabeled(imageForDetector,image_blurred,detectorResults); + tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults); #endif } return true; } -TrackerTLDModel::TrackerTLDModel(TrackerTLD::Params params,const Mat& image, const Rect2d& boundingBox,Size minSize):minSize_(minSize), -timeStampPositiveNext(0),timeStampNegativeNext(0),params_(params),boundingBox_(boundingBox){ +TrackerTLDModel::TrackerTLDModel(TrackerTLD::Params params, const Mat& image, const Rect2d& boundingBox, Size minSize):minSize_(minSize), +timeStampPositiveNext(0), timeStampNegativeNext(0), params_(params), boundingBox_(boundingBox) +{ originalVariance_ = variance(image(boundingBox)); - std::vector closest,scanGrid; - Mat scaledImg,blurredImg,image_blurred; + std::vector closest, scanGrid; + Mat scaledImg, blurredImg, image_blurred; - double scale = scaleAndBlur(image,cvRound(log(1.0 * boundingBox.width / (minSize.width)) / log(SCALE_STEP)), - scaledImg,blurredImg,GaussBlurKernelSize,SCALE_STEP); - GaussianBlur(image,image_blurred,GaussBlurKernelSize,0.0); - TLDDetector::generateScanGrid(image.rows,image.cols,minSize,scanGrid); - getClosestN(scanGrid,Rect2d(boundingBox.x / scale,boundingBox.y / scale,boundingBox.width / scale,boundingBox.height / scale),10,closest); + double scale = scaleAndBlur(image, cvRound(log(1.0 * boundingBox.width / (minSize.width)) / log(SCALE_STEP)), + scaledImg, blurredImg, GaussBlurKernelSize, SCALE_STEP); + GaussianBlur(image, image_blurred, GaussBlurKernelSize, 0.0); + TLDDetector::generateScanGrid(image.rows, image.cols, minSize, scanGrid); + getClosestN(scanGrid, Rect2d(boundingBox.x / scale, boundingBox.y / scale, boundingBox.width / scale, boundingBox.height / scale), 10, closest); Mat_ blurredPatch(minSize); - TLDEnsembleClassifier::makeClassifiers(minSize,MEASURES_PER_CLASSIFIER,GRIDSIZE,classifiers); + TLDEnsembleClassifier::makeClassifiers(minSize, MEASURES_PER_CLASSIFIER, GRIDSIZE, classifiers); positiveExamples.reserve(200); - for(int i = 0;i < (int)closest.size();i++){ - for(int j = 0;j < 20;j++){ + for( int i = 0; i < (int)closest.size(); i++ ) + { + for( int j = 0; j < 20; j++ ) + { Point2f center; Size2f size; - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); - center.x = (float)(closest[i].x + closest[i].width * (0.5 + rng.uniform(-0.01,0.01))); - center.y = (float)(closest[i].y + closest[i].height * (0.5 + rng.uniform(-0.01,0.01))); - size.width = (float)(closest[i].width * rng.uniform((double)0.99,(double)1.01)); - size.height = (float)(closest[i].height * rng.uniform((double)0.99,(double)1.01)); - float angle = (float)rng.uniform(-10.0,10.0); - - resample(scaledImg,RotatedRect(center,size,angle),standardPatch); + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); + center.x = (float)(closest[i].x + closest[i].width * (0.5 + rng.uniform(-0.01, 0.01))); + center.y = (float)(closest[i].y + closest[i].height * (0.5 + rng.uniform(-0.01, 0.01))); + size.width = (float)(closest[i].width * rng.uniform((double)0.99, (double)1.01)); + size.height = (float)(closest[i].height * rng.uniform((double)0.99, (double)1.01)); + float angle = (float)rng.uniform(-10.0, 10.0); + + resample(scaledImg, RotatedRect(center, size, angle), standardPatch); - for(int y = 0;y < standardPatch.rows;y++){ - for(int x = 0;x < standardPatch.cols;x++){ - standardPatch(x,y) += (uchar)rng.gaussian(5.0); + for( int y = 0; y < standardPatch.rows; y++ ) + { + for( int x = 0; x < standardPatch.cols; x++ ) + { + standardPatch(x, y) += (uchar)rng.gaussian(5.0); } } #ifdef BLUR_AS_VADIM - GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); - resize(blurredPatch,blurredPatch,minSize); + GaussianBlur(standardPatch, blurredPatch, GaussBlurKernelSize, 0.0); + resize(blurredPatch, blurredPatch, minSize); #else - resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); + resample(blurredImg, RotatedRect(center, size, angle), blurredPatch); #endif - pushIntoModel(standardPatch,true); - for(int k = 0;k < (int)classifiers.size();k++){ - classifiers[k].integrate(blurredPatch,true); - } + pushIntoModel(standardPatch, true); + for( int k = 0; k < (int)classifiers.size(); k++ ) + classifiers[k].integrate(blurredPatch, true); } } - TLDDetector::generateScanGrid(image.rows,image.cols,minSize,scanGrid,true); + TLDDetector::generateScanGrid(image.rows, image.cols, minSize, scanGrid, true); negativeExamples.clear(); negativeExamples.reserve(NEG_EXAMPLES_IN_INIT_MODEL); std::vector indices; indices.reserve(NEG_EXAMPLES_IN_INIT_MODEL); - while(negativeExamples.size() < NEG_EXAMPLES_IN_INIT_MODEL){ - int i = rng.uniform((int)0,(int)scanGrid.size()); - if(std::find(indices.begin(),indices.end(),i) == indices.end() && overlap(boundingBox,scanGrid[i]) < 0.2){ - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); - resample(image,scanGrid[i],standardPatch); - pushIntoModel(standardPatch,false); - - resample(image_blurred,scanGrid[i],blurredPatch); - for(int k = 0;k < (int)classifiers.size();k++){ - classifiers[k].integrate(blurredPatch,false); - } + while( negativeExamples.size() < NEG_EXAMPLES_IN_INIT_MODEL ) + { + int i = rng.uniform((int)0, (int)scanGrid.size()); + if( std::find(indices.begin(), indices.end(), i) == indices.end() && overlap(boundingBox, scanGrid[i]) < NEXPERT_THRESHOLD ) + { + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); + resample(image, scanGrid[i], standardPatch); + pushIntoModel(standardPatch, false); + + resample(image_blurred, scanGrid[i], blurredPatch); + for( int k = 0; k < (int)classifiers.size(); k++ ) + classifiers[k].integrate(blurredPatch, false); } } - dprintf(("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& res,bool withScaling){ +void TLDDetector::generateScanGrid(int rows, int cols, Size initBox, std::vector& res, bool withScaling) +{ res.clear(); //scales step: SCALE_STEP; hor step: 10% of width; verstep: 10% of height; minsize: 20pix - for(double h = initBox.height, w = initBox.width;h < cols && w < rows;){ - for( double x = 0; (x + w + 1.0) <= cols; x += (0.1 * w)) + for( double h = initBox.height, w = initBox.width; h < cols && w < rows; ) + { + for( double x = 0; (x + w + 1.0) <= cols; x += (0.1 * w) ) { - for(double y = 0; (y + h + 1.0) <= rows; y += (0.1 * h)) - res.push_back(Rect2d(x,y,w,h)); + for( double y = 0; (y + h + 1.0) <= rows; y += (0.1 * h) ) + res.push_back(Rect2d(x, y, w, h)); } if( withScaling ) { @@ -494,7 +516,7 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector initBox.height || w > initBox.width); + CV_Assert( h > initBox.height || w > initBox.width); } } else @@ -507,61 +529,66 @@ void TLDDetector::generateScanGrid(int rows,int cols,Size initBox,std::vector& patches){ +bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector& patches) +{ TrackerTLDModel* tldModel = ((TrackerTLDModel*)static_cast(model)); Size initSize = tldModel->getMinSize(); patches.clear(); - Mat resized_img,blurred_img; - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); + Mat resized_img, blurred_img; + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); img.copyTo(resized_img); imgBlurred.copyTo(blurred_img); - double originalVariance = tldModel->getOriginalVariance();; + double originalVariance = tldModel->getOriginalVariance(); ; int dx = initSize.width / 10, dy = initSize.height / 10; Size2d size = img.size(); double scale = 1.0; - int total = 0,pass = 0; - int npos = 0,nneg = 0; - double tmp = 0,maxSc = -5.0; + int total = 0, pass = 0; + int npos = 0, nneg = 0; + double tmp = 0, maxSc = -5.0; Rect2d maxScRect; START_TICK("detector"); do { - Mat_ intImgP,intImgP2; - computeIntegralImages(resized_img,intImgP,intImgP2); + Mat_ intImgP, intImgP2; + computeIntegralImages(resized_img, intImgP, intImgP2); tldModel->prepareClassifiers((int)blurred_img.step[0]); - for(int i = 0,imax = cvFloor((0.0 + resized_img.cols - initSize.width) / dx);i < imax;i++){ - for(int j = 0,jmax = cvFloor((0.0 + resized_img.rows - initSize.height) / dy);j < jmax;j++){ + for( int i = 0, imax = cvFloor((0.0 + resized_img.cols - initSize.width) / dx); i < imax; i++ ) + { + for( int j = 0, jmax = cvFloor((0.0 + resized_img.rows - initSize.height) / dy); j < jmax; j++ ) + { LabeledPatch labPatch; total++; - if(!patchVariance(intImgP,intImgP2,originalVariance,Point(dx * i,dy * j),initSize)){ + if( !patchVariance(intImgP, intImgP2, originalVariance, Point(dx * i, dy * j), initSize) ) continue; - } - if(!(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j,dx * i)) > ENSEMBLE_THRESHOLD)){ + if( tldModel->ensembleClassifierNum(&blurred_img.at(dy * j, dx * i)) <= ENSEMBLE_THRESHOLD ) continue; - } pass++; - labPatch.rect = Rect2d(dx * i * scale,dy * j * scale,initSize.width * scale,initSize.height * scale); - resample(resized_img,Rect2d(Point(dx * i,dy * j),initSize),standardPatch); + labPatch.rect = Rect2d(dx * i * scale, dy * j * scale, initSize.width * scale, initSize.height * scale); + resample(resized_img, Rect2d(Point(dx * i, dy * j), initSize), standardPatch); tmp = tldModel->Sr(standardPatch); labPatch.isObject = tmp > THETA_NN; labPatch.shouldBeIntegrated = abs(tmp - THETA_NN) < 0.1; patches.push_back(labPatch); - if(!labPatch.isObject){ + if( !labPatch.isObject ) + { nneg++; continue; - }else{ + } + else + { npos++; } tmp = tldModel->Sc(standardPatch); - if(tmp > maxSc){ + if( tmp > maxSc ) + { maxSc = tmp; maxScRect = labPatch.rect; } @@ -571,53 +598,54 @@ bool TLDDetector::detect(const Mat& img,const Mat& imgBlurred,Rect2d& res,std::v size.width /= SCALE_STEP; size.height /= SCALE_STEP; scale *= SCALE_STEP; - resize(img,resized_img,size,0,0,DOWNSCALE_MODE); - GaussianBlur(resized_img,blurred_img,GaussBlurKernelSize,0.0f); + resize(img, resized_img, size, 0, 0, DOWNSCALE_MODE); + GaussianBlur(resized_img, blurred_img, GaussBlurKernelSize, 0.0f); } while( size.width >= initSize.width && size.height >= initSize.height ); END_TICK("detector"); - dfprintf((stdout,"after NCC: nneg = %d npos = %d\n",nneg,npos)); + dfprintf((stdout, "after NCC: nneg = %d npos = %d\n", nneg, npos)); #if !0 - std::vector poss,negs; + std::vector poss, negs; - for(int i = 0;i < (int)patches.size();i++){ - if(patches[i].isObject) + for( int i = 0; i < (int)patches.size(); i++ ) + { + if( patches[i].isObject ) poss.push_back(patches[i].rect); else negs.push_back(patches[i].rect); } - dfprintf((stdout,"%d pos and %d neg\n",(int)poss.size(),(int)negs.size())); - drawWithRects(img,negs,poss,"tech"); + dfprintf((stdout, "%d pos and %d neg\n", (int)poss.size(), (int)negs.size())); + drawWithRects(img, negs, poss, "tech"); #endif - dfprintf((stdout,"%d after ensemble\n",pass)); - if(maxSc < 0){ + dfprintf((stdout, "%d after ensemble\n", pass)); + if( maxSc < 0 ) return false; - } res = maxScRect; return true; } /** Computes the variance of subimage given by box, with the help of two integral * images intImgP and intImgP2 (sum of squares), which should be also provided.*/ -bool TLDDetector::patchVariance(Mat_& intImgP,Mat_& intImgP2,double originalVariance,Point pt,Size size){ - int x = (pt.x),y = (pt.y),width = (size.width),height = (size.height); +bool TLDDetector::patchVariance(Mat_& intImgP, Mat_& intImgP2, double originalVariance, Point pt, Size size) +{ + int x = (pt.x), y = (pt.y), width = (size.width), height = (size.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 A,B,C,D; + double p = 0, p2 = 0; + double A, B, C, D; - A = intImgP(y,x); - B = intImgP(y,x + width); - C = intImgP(y + height,x); - D = intImgP(y + height,x + width); + A = intImgP(y, x); + B = intImgP(y, x + width); + C = intImgP(y + height, x); + D = intImgP(y + height, x + width); p = (A + D - B - C) / (width * height); - A = intImgP2(y,x); - B = intImgP2(y,x + width); - C = intImgP2(y + height,x); - D = intImgP2(y + height,x + width); + A = intImgP2(y, x); + B = intImgP2(y, x + width); + C = intImgP2(y + height, x); + D = intImgP2(y + height, x + width); p2 = (A + D - B - C) / (width * height); return ((p2 - p * p) > VARIANCE_THRESHOLD * originalVariance); @@ -636,9 +664,9 @@ double TrackerTLDModel::Sr(const Mat_& patch) { 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)); + 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)); + sminus = std::max(sminus, 0.5 * (NCC(negativeExamples[i], patch) + 1.0)); if( splus + sminus == 0.0) return 0.0; return splus / (sminus + splus); @@ -646,38 +674,38 @@ double TrackerTLDModel::Sr(const Mat_& patch) double TrackerTLDModel::Sc(const Mat_& patch) { - double splus = 0.0,sminus = 0.0; + 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)); + 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)); + sminus = std::max(sminus, 0.5 * (NCC(negativeExamples[i], patch) + 1.0)); if( splus + sminus == 0.0 ) return 0.0; return splus / (sminus + splus); } -void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vector& patches) +void TrackerTLDModel::integrateRelabeled(Mat& img, Mat& imgBlurred, const std::vector& patches) { - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(minSize_); - int positiveIntoModel = 0,negativeIntoModel = 0,positiveIntoEnsemble = 0,negativeIntoEnsemble = 0; + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE), blurredPatch(minSize_); + int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0; for( int k = 0; k < (int)patches.size(); k++ ) { if( patches[k].shouldBeIntegrated ) { - resample(img,patches[k].rect,standardPatch); + resample(img, patches[k].rect, standardPatch); if( patches[k].isObject ) { positiveIntoModel++; - pushIntoModel(standardPatch,true); + pushIntoModel(standardPatch, true); } else { negativeIntoModel++; - pushIntoModel(standardPatch,false); + pushIntoModel(standardPatch, false); } } @@ -687,31 +715,29 @@ void TrackerTLDModel::integrateRelabeled(Mat& img,Mat& imgBlurred,const std::vec if( patches[k].shouldBeIntegrated ) #endif { - resample(imgBlurred,patches[k].rect,blurredPatch); + resample(imgBlurred, patches[k].rect, blurredPatch); if( patches[k].isObject ) positiveIntoEnsemble++; else negativeIntoEnsemble++; for( int i = 0; i < (int)classifiers.size(); i++ ) - { - classifiers[i].integrate(blurredPatch,patches[k].isObject); - } + classifiers[i].integrate(blurredPatch, patches[k].isObject); } } if( negativeIntoModel > 0 ) - dfprintf((stdout,"negativeIntoModel = %d ",negativeIntoModel)); + dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel)); if( positiveIntoModel > 0) - dfprintf((stdout,"positiveIntoModel = %d ",positiveIntoModel)); + dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel)); if( negativeIntoEnsemble > 0 ) - dfprintf((stdout,"negativeIntoEnsemble = %d ",negativeIntoEnsemble)); + dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble)); if( positiveIntoEnsemble > 0 ) - dfprintf((stdout,"positiveIntoEnsemble = %d ",positiveIntoEnsemble)); - dfprintf((stdout,"\n")); + dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble)); + dfprintf((stdout, "\n")); } -void TrackerTLDModel::integrateAdditional(const std::vector >& eForModel,const std::vector >& eForEnsemble,bool isPositive) +void TrackerTLDModel::integrateAdditional(const std::vector >& eForModel, const std::vector >& eForEnsemble, bool isPositive) { - int positiveIntoModel = 0,negativeIntoModel = 0,positiveIntoEnsemble = 0,negativeIntoEnsemble = 0; + int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0; for( int k = 0; k < (int)eForModel.size(); k++ ) { double sr = Sr(eForModel[k]); @@ -720,17 +746,17 @@ void TrackerTLDModel::integrateAdditional(const std::vector >& eForM if( isPositive ) { positiveIntoModel++; - pushIntoModel(eForModel[k],true); + pushIntoModel(eForModel[k], true); } else { negativeIntoModel++; - pushIntoModel(eForModel[k],false); + pushIntoModel(eForModel[k], false); } } double p = 0; for( int i = 0; i < (int)classifiers.size(); i++ ) - p += classifiers[i].posteriorProbability(eForEnsemble[k].data,(int)eForEnsemble[k].step[0]); + p += classifiers[i].posteriorProbability(eForEnsemble[k].data, (int)eForEnsemble[k].step[0]); p /= classifiers.size(); if( (p > ENSEMBLE_THRESHOLD) != isPositive ) { @@ -739,32 +765,32 @@ void TrackerTLDModel::integrateAdditional(const std::vector >& eForM else negativeIntoEnsemble++; for( int i = 0; i < (int)classifiers.size(); i++ ) - classifiers[i].integrate(eForEnsemble[k],isPositive); + classifiers[i].integrate(eForEnsemble[k], isPositive); } } if( negativeIntoModel > 0 ) - dfprintf((stdout,"negativeIntoModel = %d ",negativeIntoModel)); + dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel)); if( positiveIntoModel > 0 ) - dfprintf((stdout,"positiveIntoModel = %d ",positiveIntoModel)); + dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel)); if( negativeIntoEnsemble > 0 ) - dfprintf((stdout,"negativeIntoEnsemble = %d ",negativeIntoEnsemble)); + dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble)); if( positiveIntoEnsemble > 0 ) - dfprintf((stdout,"positiveIntoEnsemble = %d ",positiveIntoEnsemble)); - dfprintf((stdout,"\n")); + dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble)); + dfprintf((stdout, "\n")); } -int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& examplesForModel,std::vector >& examplesForEnsemble) +int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& examplesForModel, std::vector >& examplesForEnsemble) { - examplesForModel.clear();examplesForEnsemble.clear(); - examplesForModel.reserve(100);examplesForEnsemble.reserve(100); + examplesForModel.clear(); examplesForEnsemble.clear(); + examplesForModel.reserve(100); examplesForEnsemble.reserve(100); - std::vector closest,scanGrid; - Mat scaledImg,blurredImg; + std::vector closest, scanGrid; + Mat scaledImg, blurredImg; - 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); + 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); for( int i = 0; i < (int)closest.size(); i++ ) { @@ -772,27 +798,27 @@ int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& exam { Point2f center; Size2f size; - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE),blurredPatch(initSize_); - center.x = (float)(closest[i].x + closest[i].width * (0.5 + rng.uniform(-0.01,0.01))); - center.y = (float)(closest[i].y + closest[i].height * (0.5 + rng.uniform(-0.01,0.01))); - size.width = (float)(closest[i].width * rng.uniform((double)0.99,(double)1.01)); - size.height = (float)(closest[i].height * rng.uniform((double)0.99,(double)1.01)); - float angle = (float)rng.uniform(-5.0,5.0); + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE), blurredPatch(initSize_); + center.x = (float)(closest[i].x + closest[i].width * (0.5 + rng.uniform(-0.01, 0.01))); + center.y = (float)(closest[i].y + closest[i].height * (0.5 + rng.uniform(-0.01, 0.01))); + size.width = (float)(closest[i].width * rng.uniform((double)0.99, (double)1.01)); + size.height = (float)(closest[i].height * rng.uniform((double)0.99, (double)1.01)); + float angle = (float)rng.uniform(-5.0, 5.0); for( int y = 0; y < standardPatch.rows; y++ ) { for( int x = 0; x < standardPatch.cols; x++ ) { - standardPatch(x,y) += (uchar)rng.gaussian(5.0); + standardPatch(x, y) += (uchar)rng.gaussian(5.0); } } #ifdef BLUR_AS_VADIM - GaussianBlur(standardPatch,blurredPatch,GaussBlurKernelSize,0.0); - resize(blurredPatch,blurredPatch,initSize_); + GaussianBlur(standardPatch, blurredPatch, GaussBlurKernelSize, 0.0); + resize(blurredPatch, blurredPatch, initSize_); #else - resample(blurredImg,RotatedRect(center,size,angle),blurredPatch); + resample(blurredImg, RotatedRect(center, size, angle), blurredPatch); #endif - resample(scaledImg,RotatedRect(center,size,angle),standardPatch); + resample(scaledImg, RotatedRect(center, size, angle), standardPatch); examplesForModel.push_back(standardPatch); examplesForEnsemble.push_back(blurredPatch); } @@ -802,7 +828,7 @@ int TrackerTLDImpl::Pexpert::additionalExamples(std::vector >& exam bool TrackerTLDImpl::Nexpert::operator()(Rect2d box) { - if( overlap(resultBox_,box) < NEXPERT_THRESHOLD ) + if( overlap(resultBox_, box) < NEXPERT_THRESHOLD ) return false; else return true; @@ -810,31 +836,31 @@ bool TrackerTLDImpl::Nexpert::operator()(Rect2d box) Data::Data(Rect2d initBox) { - double minDim = std::min(initBox.width,initBox.height); + double minDim = std::min(initBox.width, initBox.height); scale = 20.0 / minDim; minSize.width = (int)(initBox.width * 20.0 / minDim); minSize.height = (int)(initBox.height * 20.0 / minDim); frameNum = 0; - dprintf(("minSize = %dx%d\n",minSize.width,minSize.height)); + dprintf(("minSize = %dx%d\n", minSize.width, minSize.height)); } void Data::printme(FILE* port) { - dfprintf((port,"Data:\n")); - dfprintf((port,"\tframeNum = %d\n",frameNum)); - dfprintf((port,"\tconfident = %s\n",confident?"true":"false")); - dfprintf((port,"\tfailedLastTime = %s\n",failedLastTime?"true":"false")); - dfprintf((port,"\tminSize = %dx%d\n",minSize.width,minSize.height)); + dfprintf((port, "Data:\n")); + dfprintf((port, "\tframeNum = %d\n", frameNum)); + dfprintf((port, "\tconfident = %s\n", confident?"true":"false")); + dfprintf((port, "\tfailedLastTime = %s\n", failedLastTime?"true":"false")); + dfprintf((port, "\tminSize = %dx%d\n", minSize.width, minSize.height)); } void TrackerTLDModel::printme(FILE* port) { - dfprintf((port,"TrackerTLDModel:\n")); - dfprintf((port,"\tpositiveExamples.size() = %d\n",(int)positiveExamples.size())); - dfprintf((port,"\tnegativeExamples.size() = %d\n",(int)negativeExamples.size())); + dfprintf((port, "TrackerTLDModel:\n")); + dfprintf((port, "\tpositiveExamples.size() = %d\n", (int)positiveExamples.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 ) { @@ -842,39 +868,39 @@ void MyMouseCallbackDEBUG::onMouse( int event, int x, int y) img_.copyTo(imgCanvas); TrackerTLDModel* tldModel = ((TrackerTLDModel*)static_cast(detector_->model)); Size initSize = tldModel->getMinSize(); - Mat_ standardPatch(STANDARD_PATCH_SIZE,STANDARD_PATCH_SIZE); - double originalVariance = tldModel->getOriginalVariance();; + Mat_ standardPatch(STANDARD_PATCH_SIZE, STANDARD_PATCH_SIZE); + double originalVariance = tldModel->getOriginalVariance(); double tmp; - Mat resized_img,blurred_img; + Mat resized_img, blurred_img; double scale = SCALE_STEP; //double scale = SCALE_STEP * SCALE_STEP * SCALE_STEP * SCALE_STEP; - Size2d size(img_.cols / scale,img_.rows / scale); - resize(img_,resized_img,size); - resize(imgBlurred_,blurred_img,size); + Size2d size(img_.cols / scale, img_.rows / scale); + resize(img_, resized_img, size); + resize(imgBlurred_, blurred_img, size); - Mat_ intImgP,intImgP2; - detector_->computeIntegralImages(resized_img,intImgP,intImgP2); + Mat_ intImgP, intImgP2; + detector_->computeIntegralImages(resized_img, intImgP, intImgP2); int dx = initSize.width / 10, dy = initSize.height / 10, i = (int)(x / scale / dx), j = (int)(y / scale / dy); - dfprintf((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")); tldModel->prepareClassifiers((int)blurred_img.step[0]); - dfprintf((stderr,"p = %f\n",(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j,dx * i))))); - fprintf(stderr,"ensembleClassifier = %s\n", - (!(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j,dx * i)) > ENSEMBLE_THRESHOLD))?"true":"false"); + dfprintf((stderr, "p = %f\n", (tldModel->ensembleClassifierNum(&blurred_img.at(dy * j, dx * i))))); + fprintf(stderr, "ensembleClassifier = %s\n", + (!(tldModel->ensembleClassifierNum(&blurred_img.at(dy * j, dx * i)) > ENSEMBLE_THRESHOLD))?"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); - dfprintf((stderr,"Sr = %f\n",tmp)); - dfprintf((stderr,"isObject = %s\n",(tmp > THETA_NN)?"true":"false")); - dfprintf((stderr,"shouldBeIntegrated = %s\n",(abs(tmp - THETA_NN) < 0.1)?"true":"false")); - dfprintf((stderr,"Sc = %f\n",tldModel->Sc(standardPatch))); + dfprintf((stderr, "Sr = %f\n", tmp)); + dfprintf((stderr, "isObject = %s\n", (tmp > THETA_NN)?"true":"false")); + dfprintf((stderr, "shouldBeIntegrated = %s\n", (abs(tmp - THETA_NN) < 0.1)?"true":"false")); + 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 ); - imshow("picker",imgCanvas); + rectangle(imgCanvas, Rect2d(Point2d(scale * dx * i, scale * dy * j), Size2d(initSize.width * scale, initSize.height * scale)), 0, 2, 1 ); + imshow("picker", imgCanvas); waitKey(); } } @@ -903,7 +929,7 @@ void TrackerTLDModel::pushIntoModel(const Mat_& example, bool positive) } else { - int index = rng.uniform((int)0,(int)proxyV->size()); + int index = rng.uniform((int)0, (int)proxyV->size()); (*proxyV)[index] = example; (*proxyT)[index] = (*proxyN); } diff --git a/modules/tracking/src/tld_tracker.hpp b/modules/tracking/src/tld_tracker.hpp index 7215bbb39..39f983244 100644 --- a/modules/tracking/src/tld_tracker.hpp +++ b/modules/tracking/src/tld_tracker.hpp @@ -57,60 +57,67 @@ namespace cv {namespace tld #define dfprintf(x) #define dprintf(x) #endif -#define MEASURE_TIME(a) {\ - clock_t start;float milisec = 0.0;\ - start = clock();{a} milisec = 1000.0 * (clock() - start) / CLOCKS_PER_SEC;\ - dprintf(("%-90s took %f milis\n",#a,milisec)); } -#define HERE dprintf(("line %d\n",__LINE__));fflush(stderr); -#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;\ - dprintf(("%s took %f milis\n",name,milisec)); } +#define MEASURE_TIME(a)\ +{\ + clock_t start; float milisec = 0.0; \ + start = clock(); {a} milisec = 1000.0 * (clock() - start) / CLOCKS_PER_SEC; \ + dprintf(("%-90s took %f milis\n", #a, milisec));\ +} +#define HERE dprintf(("line %d\n", __LINE__)); fflush(stderr); +#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; \ + dprintf(("%s took %f milis\n", name, milisec)); \ +} extern Rect2d etalon; void myassert(const Mat& img); void printPatch(const Mat_& standardPatch); std::string type2str(const Mat& mat); -void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne = Rect2d(-1.0,-1.0,-1.0,-1.0)); -void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String fileName = ""); +void drawWithRects(const Mat& img, std::vector& blackOnes, Rect2d whiteOne = Rect2d(-1.0, -1.0, -1.0, -1.0)); +void drawWithRects(const Mat& img, std::vector& blackOnes, std::vector& whiteOnes, String fileName = ""); //aux functions and variables -template inline T CLIP(T x,T a,T b){return std::min(std::max(x,a),b);} +template inline T CLIP(T x, T a, T b){ return std::min(std::max(x, a), b); } /** Computes overlap between the two given rectangles. Overlap is computed as ratio of rectangles' intersection to that * of their union.*/ -double overlap(const Rect2d& r1,const Rect2d& r2); +double overlap(const Rect2d& r1, const Rect2d& r2); /** Resamples the area surrounded by r2 in img so it matches the size of samples, where it is written.*/ -void resample(const Mat& img,const RotatedRect& r2,Mat_& samples); +void resample(const Mat& img, const RotatedRect& r2, Mat_& samples); /** Specialization of resample() for rectangles without retation for better performance and simplicity.*/ -void resample(const Mat& img,const Rect2d& r2,Mat_& samples); +void resample(const Mat& img, const Rect2d& r2, Mat_& samples); /** Computes the variance of single given image.*/ double variance(const Mat& img); /** Computes normalized corellation coefficient between the two patches (they should be * of the same size).*/ -double NCC(const Mat_& patch1,const Mat_& patch2); -void getClosestN(std::vector& scanGrid,Rect2d bBox,int n,std::vector& res); -double scaleAndBlur(const Mat& originalImg,int scale,Mat& scaledImg,Mat& blurredImg,Size GaussBlurKernelSize, double scaleStep); +double NCC(const Mat_& patch1, const Mat_& patch2); +void getClosestN(std::vector& scanGrid, Rect2d bBox, int n, std::vector& res); +double scaleAndBlur(const Mat& originalImg, int scale, Mat& scaledImg, Mat& blurredImg, Size GaussBlurKernelSize, double scaleStep); int getMedian(const std::vector& values, int size = -1); -class TLDEnsembleClassifier{ +class TLDEnsembleClassifier +{ public: - static int makeClassifiers(Size size,int measurePerClassifier,int gridSize,std::vector& classifiers); - void integrate(const Mat_& patch,bool isPositive); - double posteriorProbability(const uchar* data,int rowstep)const; - double posteriorProbabilityFast(const uchar* data)const; + static int makeClassifiers(Size size, int measurePerClassifier, int gridSize, std::vector& classifiers); + void integrate(const Mat_& patch, bool isPositive); + double posteriorProbability(const uchar* data, int rowstep) const; + double posteriorProbabilityFast(const uchar* data) const; void prepareClassifier(int rowstep); private: - TLDEnsembleClassifier(const std::vector& meas,int beg,int end); - static void stepPrefSuff(std::vector & arr,int pos,int len,int gridSize); - int code(const uchar* data,int rowstep)const; - int codeFast(const uchar* data)const; + TLDEnsembleClassifier(const std::vector& meas, int beg, int end); + static void stepPrefSuff(std::vector & arr, int pos, int len, int gridSize); + int code(const uchar* data, int rowstep) const; + int codeFast(const uchar* data) const; std::vector posAndNeg; std::vector measurements; std::vector offset; int lastStep_; }; -class TrackerProxy{ +class TrackerProxy +{ public: - virtual bool init( const Mat& image, const Rect2d& boundingBox) = 0; + virtual bool init(const Mat& image, const Rect2d& boundingBox) = 0; virtual bool update(const Mat& image, Rect2d& boundingBox) = 0; virtual ~TrackerProxy(){} }; diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index 1f9254622..c85467fdc 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -53,58 +53,61 @@ namespace cv {namespace tld { //debug functions and variables -Rect2d etalon(14.0,110.0,20.0,20.0); -void drawWithRects(const Mat& img,std::vector& blackOnes,Rect2d whiteOne){ +Rect2d etalon(14.0, 110.0, 20.0, 20.0); +void drawWithRects(const Mat& img, std::vector& blackOnes, Rect2d whiteOne) +{ Mat image; img.copyTo(image); - if(whiteOne.width >= 0){ - rectangle( image,whiteOne, 255, 1, 1 ); - } - for(int i = 0;i < (int)blackOnes.size();i++){ - rectangle( image,blackOnes[i], 0, 1, 1 ); - } - imshow("img",image); + if( whiteOne.width >= 0 ) + rectangle( image, whiteOne, 255, 1, 1 ); + for( int i = 0; i < (int)blackOnes.size(); i++ ) + rectangle( image, blackOnes[i], 0, 1, 1 ); + imshow("img", image); } -void drawWithRects(const Mat& img,std::vector& blackOnes,std::vector& whiteOnes,String filename){ +void drawWithRects(const Mat& img, std::vector& blackOnes, std::vector& whiteOnes, String filename) +{ Mat image; static int frameCounter = 1; img.copyTo(image); - for(int i = 0;i < (int)whiteOnes.size();i++){ - rectangle( image,whiteOnes[i], 255, 1, 1 ); - } - for(int i = 0;i < (int)blackOnes.size();i++){ - rectangle( image,blackOnes[i], 0, 1, 1 ); - } - imshow("img",image); - if(filename.length() > 0){ + for( int i = 0; i < (int)whiteOnes.size(); i++ ) + rectangle( image, whiteOnes[i], 255, 1, 1 ); + for( int i = 0; i < (int)blackOnes.size(); i++ ) + rectangle( image, blackOnes[i], 0, 1, 1 ); + imshow("img", image); + if( filename.length() > 0 ) + { char inbuf[100]; - sprintf(inbuf,"%s%d.jpg",filename.c_str(),frameCounter); - imwrite(inbuf,image); + sprintf(inbuf, "%s%d.jpg", filename.c_str(), frameCounter); + imwrite(inbuf, image); frameCounter++; } } -void myassert(const Mat& img){ +void myassert(const Mat& img) +{ int count = 0; - for(int i = 0;i < img.rows;i++){ - for(int j = 0;j < img.cols;j++){ - if(img.at(i,j) == 0){ + for( int i = 0; i < img.rows; i++ ) + { + for( int j = 0; j < img.cols; j++ ) + { + if( img.at(i, j) == 0 ) count++; - } } } - dprintf(("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_& standardPatch){ - for(int i = 0;i < standardPatch.rows;i++){ - for(int j = 0;j < standardPatch.cols;j++){ - dprintf(("%5.2f, ",(double)standardPatch(i,j))); - } +void printPatch(const Mat_& standardPatch) +{ + for( int i = 0; i < standardPatch.rows; i++ ) + { + for( int j = 0; j < standardPatch.cols; j++ ) + dprintf(("%5.2f, ", (double)standardPatch(i, j))); dprintf(("\n")); } } -std::string type2str(const Mat& mat){ +std::string type2str(const Mat& mat) +{ int type = mat.type(); std::string r; @@ -129,59 +132,63 @@ std::string type2str(const Mat& mat){ } //generic functions -double scaleAndBlur(const Mat& originalImg,int scale,Mat& scaledImg,Mat& blurredImg,Size GaussBlurKernelSize, double scaleStep){ +double scaleAndBlur(const Mat& originalImg, int scale, Mat& scaledImg, Mat& blurredImg, Size GaussBlurKernelSize, double scaleStep) +{ double dScale = 1.0; - for(int i = 0; i < scale; i++, dScale *= scaleStep); + for( int i = 0; i < scale; i++, dScale *= scaleStep ); Size2d size = originalImg.size(); size.height /= dScale; size.width /= dScale; - resize(originalImg,scaledImg,size); - GaussianBlur(scaledImg,blurredImg,GaussBlurKernelSize,0.0); + resize(originalImg, scaledImg, size); + GaussianBlur(scaledImg, blurredImg, GaussBlurKernelSize, 0.0); return dScale; } -void getClosestN(std::vector& scanGrid,Rect2d bBox,int n,std::vector& res){ - if(n >= (int)scanGrid.size()){ - res.assign(scanGrid.begin(),scanGrid.end()); +void getClosestN(std::vector& scanGrid, Rect2d bBox, int n, std::vector& res) +{ + if( n >= (int)scanGrid.size() ) + { + res.assign(scanGrid.begin(), scanGrid.end()); return; } std::vector overlaps; - overlaps.assign(n,0.0); - res.assign(scanGrid.begin(),scanGrid.begin() + n); - for(int i = 0;i < n;i++){ - overlaps[i] = overlap(res[i],bBox); - } + overlaps.assign(n, 0.0); + res.assign(scanGrid.begin(), scanGrid.begin() + n); + for( int i = 0; i < n; i++ ) + overlaps[i] = overlap(res[i], bBox); double otmp; Rect2d rtmp; - for (int i = 1; i < n; i++){ + for (int i = 1; i < n; i++) + { int j = i; while (j > 0 && overlaps[j - 1] > overlaps[j]) { - otmp = overlaps[j];overlaps[j] = overlaps[j - 1];overlaps[j - 1] = otmp; - rtmp = res[j];res[j] = res[j - 1];res[j - 1] = rtmp; + otmp = overlaps[j]; overlaps[j] = overlaps[j - 1]; overlaps[j - 1] = otmp; + rtmp = res[j]; res[j] = res[j - 1]; res[j - 1] = rtmp; j--; } } - for(int i = n;i < (int)scanGrid.size();i++){ + for( int i = n; i < (int)scanGrid.size(); i++ ) + { double o = 0.0; - if((o = overlap(scanGrid[i],bBox)) <= overlaps[0]){ + if( (o = overlap(scanGrid[i], bBox)) <= overlaps[0] ) continue; - } int j = 0; while( j < n && overlaps[j] < o ) - { j++; - } j--; - for(int k = 0;k < j;overlaps[k] = overlaps[k + 1],res[k] = res[k + 1],k++); - overlaps[j] = o;res[j] = scanGrid[i]; + for( int k = 0; k < j; overlaps[k] = overlaps[k + 1], res[k] = res[k + 1], k++ ); + overlaps[j] = o; res[j] = scanGrid[i]; } } -double variance(const Mat& img){ - double p = 0,p2 = 0; - for(int i = 0;i < img.rows;i++){ - for(int j = 0;j < img.cols;j++){ - p += img.at(i,j); - p2 += img.at(i,j) * img.at(i,j); +double variance(const Mat& img) +{ + double p = 0, p2 = 0; + for( int i = 0; i < img.rows; i++ ) + { + for( int j = 0; j < img.cols; j++ ) + { + p += img.at(i, j); + p2 += img.at(i, j) * img.at(i, j); } } p /= (img.cols * img.rows); @@ -189,87 +196,96 @@ double variance(const Mat& img){ return p2 - p * p; } -double NCC(const Mat_& patch1,const Mat_& patch2){ - CV_Assert(patch1.rows == patch2.rows); - CV_Assert(patch1.cols == patch2.cols); +double NCC(const Mat_& patch1, const Mat_& patch2) +{ + CV_Assert( patch1.rows == patch2.rows ); + CV_Assert( patch1.cols == patch2.cols ); int N = patch1.rows * patch1.cols; - int s1 = 0,s2 = 0,n1 = 0,n2 = 0,prod = 0; - for(int i = 0;i < patch1.rows;i++){ - for(int j = 0;j < patch1.cols;j++){ - int p1 = patch1(i,j), p2 = patch2(i,j); + int s1 = 0, s2 = 0, n1 = 0, n2 = 0, prod = 0; + for( int i = 0; i < patch1.rows; i++ ) + { + for( int j = 0; j < patch1.cols; j++ ) + { + int p1 = patch1(i, j), p2 = patch2(i, j); s1 += p1; s2 += p2; n1 += (p1 * p1); n2 += (p2 * p2); prod += (p1 * p2); } } - double sq1 = sqrt(std::max(0.0,n1 - 1.0 * s1 * s1 / N)),sq2 = sqrt(std::max(0.0,n2 - 1.0 * s2 * s2 / N)); + double sq1 = sqrt(std::max(0.0, n1 - 1.0 * s1 * s1 / N)), sq2 = sqrt(std::max(0.0, n2 - 1.0 * s2 * s2 / N)); double ares = (sq2 == 0) ? sq1 / abs(sq1) : (prod - s1 * s2 / N) / sq1 / sq2; return ares; } -int getMedian(const std::vector& values, int size){ - if(size == -1){ +int getMedian(const std::vector& values, int size) +{ + if( size == -1 ) size = (int)values.size(); - } - std::vector copy(values.begin(),values.begin() + size); - std::sort(copy.begin(),copy.end()); - if(size % 2 == 0){ + std::vector copy(values.begin(), values.begin() + size); + std::sort(copy.begin(), copy.end()); + if( size % 2 == 0 ) return (copy[size / 2 - 1] + copy[size / 2]) / 2; - }else{ + else return copy[(size - 1) / 2]; - } } -double overlap(const Rect2d& r1,const Rect2d& r2){ +double overlap(const Rect2d& r1, const Rect2d& r2) +{ double a1 = r1.area(), a2 = r2.area(), a0 = (r1&r2).area(); return a0 / (a1 + a2 - a0); } -void resample(const Mat& img,const RotatedRect& r2,Mat_& samples){ - Mat_ M(2,3),R(2,2),Si(2,2),s(2,1),o(2,1); - R(0,0) = (float)cos(r2.angle * CV_PI / 180);R(0,1) = (float)(-sin(r2.angle * CV_PI / 180)); - R(1,0) = (float)sin(r2.angle * CV_PI / 180);R(1,1) = (float)cos(r2.angle * CV_PI / 180); - Si(0,0) = (float)(samples.cols / r2.size.width); Si(0,1) = 0.0f; - Si(1,0) = 0.0f; Si(1,1) = (float)(samples.rows / r2.size.height); - s(0,0) = (float)samples.cols; s(1,0) = (float)samples.rows; - o(0,0) = r2.center.x;o(1,0) = r2.center.y; - Mat_ A(2,2),b(2,1); +void resample(const Mat& img, const RotatedRect& r2, Mat_& samples) +{ + Mat_ M(2, 3), R(2, 2), Si(2, 2), s(2, 1), o(2, 1); + R(0, 0) = (float)cos(r2.angle * CV_PI / 180); R(0, 1) = (float)(-sin(r2.angle * CV_PI / 180)); + R(1, 0) = (float)sin(r2.angle * CV_PI / 180); R(1, 1) = (float)cos(r2.angle * CV_PI / 180); + Si(0, 0) = (float)(samples.cols / r2.size.width); Si(0, 1) = 0.0f; + Si(1, 0) = 0.0f; Si(1, 1) = (float)(samples.rows / r2.size.height); + s(0, 0) = (float)samples.cols; s(1, 0) = (float)samples.rows; + o(0, 0) = r2.center.x; o(1, 0) = r2.center.y; + Mat_ A(2, 2), b(2, 1); A = Si * R; b = s / 2.0 - Si * R * o; - A.copyTo(M.colRange(Range(0,2))); - b.copyTo(M.colRange(Range(2,3))); - warpAffine(img,samples,M,samples.size()); + A.copyTo(M.colRange(Range(0, 2))); + b.copyTo(M.colRange(Range(2, 3))); + warpAffine(img, samples, M, samples.size()); } -void resample(const Mat& img,const Rect2d& r2,Mat_& samples){ - Mat_ M(2,3); - M(0,0) = (float)(samples.cols / r2.width); M(0,1) = 0.0f; M(0,2) = (float)(-r2.x * samples.cols / r2.width); - M(1,0) = 0.0f; M(1,1) = (float)(samples.rows / r2.height); M(1,2) = (float)(-r2.y * samples.rows / r2.height); - warpAffine(img,samples,M,samples.size()); +void resample(const Mat& img, const Rect2d& r2, Mat_& samples) +{ + Mat_ M(2, 3); + M(0, 0) = (float)(samples.cols / r2.width); M(0, 1) = 0.0f; M(0, 2) = (float)(-r2.x * samples.cols / r2.width); + M(1, 0) = 0.0f; M(1, 1) = (float)(samples.rows / r2.height); M(1, 2) = (float)(-r2.y * samples.rows / r2.height); + warpAffine(img, samples, M, samples.size()); } //other stuff -void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int pos,int len,int gridSize){ +void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr, int pos, int len, int gridSize) +{ #if 0 int step = len / (gridSize - 1), pref = (len - step * (gridSize - 1)) / 2; - for(int i = 0;i < (int)(sizeof(x1) / sizeof(x1[0]));i++){ + for( int i = 0; i < (int)(sizeof(x1) / sizeof(x1[0])); i++ ) arr[i] = pref + arr[i] * step; - } #else int total = len - gridSize; - int quo = total / (gridSize - 1),rem = total % (gridSize - 1); - int smallStep = quo,bigStep = quo + 1; - int bigOnes = rem,smallOnes = gridSize - bigOnes - 1; + int quo = total / (gridSize - 1), rem = total % (gridSize - 1); + int smallStep = quo, bigStep = quo + 1; + int bigOnes = rem, smallOnes = gridSize - bigOnes - 1; int bigOnes_front = bigOnes / 2, bigOnes_back = bigOnes - bigOnes_front; - for(int i = 0;i < (int)arr.size();i++){ - if(arr[i].val[pos] < bigOnes_back){ + for( int i = 0; i < (int)arr.size(); i++ ) + { + if( arr[i].val[pos] < bigOnes_back ) + { arr[i].val[pos] = (uchar)(arr[i].val[pos] * bigStep + arr[i].val[pos]); continue; } - if(arr[i].val[pos] < (bigOnes_front + smallOnes)){ + if( arr[i].val[pos] < (bigOnes_front + smallOnes) ) + { arr[i].val[pos] = (uchar)(bigOnes_front * bigStep + (arr[i].val[pos] - bigOnes_front) * smallStep + arr[i].val[pos]); continue; } - if(arr[i].val[pos] < (bigOnes_front + smallOnes + bigOnes_back)){ + if( arr[i].val[pos] < (bigOnes_front + smallOnes + bigOnes_back) ) + { arr[i].val[pos] = (uchar)(bigOnes_front * bigStep + smallOnes * smallStep + (arr[i].val[pos] - (bigOnes_front + smallOnes)) * bigStep + arr[i].val[pos]); @@ -279,62 +295,69 @@ void TLDEnsembleClassifier::stepPrefSuff(std::vector& arr,int pos,int len } #endif } -void TLDEnsembleClassifier::prepareClassifier(int rowstep){ - if(lastStep_ != rowstep){ +void TLDEnsembleClassifier::prepareClassifier(int rowstep) +{ + if( lastStep_ != rowstep ) + { lastStep_ = rowstep; - for(int i = 0;i < (int)offset.size();i++){ + for( int i = 0; i < (int)offset.size(); i++ ) + { offset[i].x = rowstep * measurements[i].val[0] + measurements[i].val[1]; offset[i].y = rowstep * measurements[i].val[2] + measurements[i].val[3]; } } } -TLDEnsembleClassifier::TLDEnsembleClassifier(const std::vector& meas,int beg,int end):lastStep_(-1){ +TLDEnsembleClassifier::TLDEnsembleClassifier(const std::vector& meas, int beg, int end):lastStep_(-1) +{ int posSize = 1, mpc = end - beg; for( int i = 0; i < mpc; i++ ) posSize *= 2; - posAndNeg.assign(posSize,Point2i(0,0)); - measurements.assign(meas.begin() + beg,meas.begin() + end); - offset.assign(mpc,Point2i(0,0)); + posAndNeg.assign(posSize, Point2i(0, 0)); + measurements.assign(meas.begin() + beg, meas.begin() + end); + offset.assign(mpc, Point2i(0, 0)); } -void TLDEnsembleClassifier::integrate(const Mat_& patch,bool isPositive){ - int position = code(patch.data,(int)patch.step[0]); - if(isPositive){ +void TLDEnsembleClassifier::integrate(const Mat_& patch, bool isPositive) +{ + int position = code(patch.data, (int)patch.step[0]); + if( isPositive ) posAndNeg[position].x++; - }else{ + else posAndNeg[position].y++; - } } -double TLDEnsembleClassifier::posteriorProbability(const uchar* data,int rowstep)const{ - int position = code(data,rowstep); +double TLDEnsembleClassifier::posteriorProbability(const uchar* data, int rowstep) const +{ + int position = code(data, rowstep); double posNum = (double)posAndNeg[position].x, negNum = (double)posAndNeg[position].y; - if(posNum == 0.0 && negNum == 0.0){ + if( posNum == 0.0 && negNum == 0.0 ) return 0.0; - }else{ + else return posNum / (posNum + negNum); - } } -double TLDEnsembleClassifier::posteriorProbabilityFast(const uchar* data)const{ +double TLDEnsembleClassifier::posteriorProbabilityFast(const uchar* data) const +{ int position = codeFast(data); double posNum = (double)posAndNeg[position].x, negNum = (double)posAndNeg[position].y; - if(posNum == 0.0 && negNum == 0.0){ + if( posNum == 0.0 && negNum == 0.0 ) return 0.0; - }else{ + else return posNum / (posNum + negNum); - } } -int TLDEnsembleClassifier::codeFast(const uchar* data)const{ +int TLDEnsembleClassifier::codeFast(const uchar* data) const +{ int position = 0; - for(int i = 0;i < (int)measurements.size();i++){ + for( int i = 0; i < (int)measurements.size(); i++ ) + { position = position << 1; - if(data[offset[i].x] < data[offset[i].y]){ + if( data[offset[i].x] < data[offset[i].y] ) position++; - } } return position; } -int TLDEnsembleClassifier::code(const uchar* data,int rowstep)const{ +int TLDEnsembleClassifier::code(const uchar* data, int rowstep) const +{ int position = 0; - for(int i = 0;i < (int)measurements.size();i++){ + for( int i = 0; i < (int)measurements.size(); i++ ) + { position = position << 1; if( *(data + rowstep * measurements[i].val[0] + measurements[i].val[1]) < *(data + rowstep * measurements[i].val[2] + measurements[i].val[3]) ) @@ -344,34 +367,37 @@ int TLDEnsembleClassifier::code(const uchar* data,int rowstep)const{ } return position; } -int TLDEnsembleClassifier::makeClassifiers(Size size,int measurePerClassifier,int gridSize, - std::vector& classifiers){ +int TLDEnsembleClassifier::makeClassifiers(Size size, int measurePerClassifier, int gridSize, + std::vector& classifiers) +{ std::vector measurements; - for(int i = 0;i < gridSize;i++){ - for(int j = 0;j < gridSize;j++){ - for(int k = 0;k < j;k++){ + for( int i = 0; i < gridSize; i++ ) + { + for( int j = 0; j < gridSize; j++ ) + { + for( int k = 0; k < j; k++ ) + { Vec4b m; m.val[0] = m.val[2] = i; - m.val[1] = j;m.val[3] = k; + m.val[1] = j; m.val[3] = k; measurements.push_back(m); m.val[1] = m.val[3] = i; - m.val[0] = j;m.val[2] = k; + m.val[0] = j; m.val[2] = k; measurements.push_back(m); } } } - random_shuffle(measurements.begin(),measurements.end()); + random_shuffle(measurements.begin(), measurements.end()); - stepPrefSuff(measurements,0,size.width,gridSize); - stepPrefSuff(measurements,1,size.width,gridSize); - stepPrefSuff(measurements,2,size.height,gridSize); - stepPrefSuff(measurements,3,size.height,gridSize); + stepPrefSuff(measurements, 0, size.width, gridSize); + stepPrefSuff(measurements, 1, size.width, gridSize); + stepPrefSuff(measurements, 2, size.height, gridSize); + stepPrefSuff(measurements, 3, size.height, gridSize); - for(int i = 0,howMany = measurements.size() / measurePerClassifier;i < howMany;i++){ - classifiers.push_back(TLDEnsembleClassifier(measurements,i * measurePerClassifier, (i + 1) * measurePerClassifier)); - } + for( int i = 0, howMany = measurements.size() / measurePerClassifier; i < howMany; i++ ) + classifiers.push_back(TLDEnsembleClassifier(measurements, i * measurePerClassifier, (i + 1) * measurePerClassifier)); return (int)classifiers.size(); } From 01aa6593535c20fdac412fd26084fd8e9e0a4a9b Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Tue, 5 Aug 2014 20:39:53 +0300 Subject: [PATCH 18/26] coding style: vadim comments --- modules/tracking/src/tld_tracker.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 2508e326d..eb23e86bc 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -88,12 +88,11 @@ using namespace tld; * 11. group decls logically, order of statements * * ?10. all in one class -* todo: initializer lists; const methods +* todo: +* initializer lists; +* const methods * * ?( ) -* -* ?vadim: for{1command} can omit {}; if( a != (b + c) ) vs ( a != ( b + c ) ); if{} for{} method{} oneline:spaces, omit{}; -* 1-statement for/if without {} */ /* design decisions: @@ -178,7 +177,7 @@ public: void setBoudingBox(Rect2d boundingBox){ boundingBox_ = boundingBox; } double getOriginalVariance(){ return originalVariance_; } inline double ensembleClassifierNum(const uchar* data); - inline void prepareClassifiers(int rowstep){ for( int i = 0; i < (int)classifiers.size(); i++ ) classifiers[i].prepareClassifier(rowstep); } + inline void prepareClassifiers(int rowstep); double Sr(const Mat_& patch); double Sc(const Mat_& patch); void integrateRelabeled(Mat& img, Mat& imgBlurred, const std::vector& patches); @@ -326,7 +325,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) for( int i = 0; i < 2; i++ ) { Rect2d tmpCandid = boundingBox; - if( ( (i == 0) && !(data->failedLastTime) && trackerProxy->update(image, tmpCandid) ) || + if( ( (i == 0) && !data->failedLastTime && trackerProxy->update(image, tmpCandid) ) || ( (i == 1) && detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults) ) ) { candidates.push_back(tmpCandid); @@ -395,7 +394,8 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) if( detectorResults[i].isObject ) { expertResult = nExpert(detectorResults[i].rect); - if( expertResult != detectorResults[i].isObject ){ negRelabeled++; } + if( expertResult != detectorResults[i].isObject ) + negRelabeled++; } else { @@ -758,7 +758,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector >& eForM for( int i = 0; i < (int)classifiers.size(); i++ ) p += classifiers[i].posteriorProbability(eForEnsemble[k].data, (int)eForEnsemble[k].step[0]); p /= classifiers.size(); - if( (p > ENSEMBLE_THRESHOLD) != isPositive ) + if( ( p > ENSEMBLE_THRESHOLD ) != isPositive ) { if( isPositive ) positiveIntoEnsemble++; @@ -935,5 +935,10 @@ void TrackerTLDModel::pushIntoModel(const Mat_& example, bool positive) } (*proxyN)++; } +void TrackerTLDModel::prepareClassifiers(int rowstep) +{ + for( int i = 0; i < (int)classifiers.size(); i++ ) + classifiers[i].prepareClassifier(rowstep); +} } /* namespace cv */ From f05f8cfcf2ffdac08e784ca92364207de8dd87ab Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 11 Aug 2014 18:14:43 +0300 Subject: [PATCH 19/26] commit --- modules/tracking/src/tld_tracker.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index eb23e86bc..d8ac72f93 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -90,9 +90,6 @@ using namespace tld; * ?10. all in one class * todo: * initializer lists; -* const methods -* -* ?( ) */ /* design decisions: @@ -710,7 +707,7 @@ void TrackerTLDModel::integrateRelabeled(Mat& img, Mat& imgBlurred, const std::v } #ifdef CLOSED_LOOP - if( patches[k].shouldBeIntegrated || ( patches[k].isPositive == false ) ) + if( patches[k].shouldBeIntegrated || !patches[k].isPositive ) #else if( patches[k].shouldBeIntegrated ) #endif From 2328bc23e879807248095e3418bb10845e95dac9 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 11 Aug 2014 20:22:07 +0300 Subject: [PATCH 20/26] vadim --- modules/tracking/samples/benchmark.cpp | 8 ++++---- modules/tracking/src/tld_tracker.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/tracking/samples/benchmark.cpp b/modules/tracking/samples/benchmark.cpp index bf67afcbb..72c59caa2 100644 --- a/modules/tracking/samples/benchmark.cpp +++ b/modules/tracking/samples/benchmark.cpp @@ -7,9 +7,9 @@ #include #include -#define CMDLINEMAX 30 -#define ASSESS_TILL 100 -#define LINEMAX 40 +const int CMDLINEMAX = 30; +const int ASSESS_TILL = 100; +const int LINEMAX = 40; using namespace std; using namespace cv; @@ -368,7 +368,7 @@ int main( int argc, char** argv ){ for(int i=0;i indices; indices.reserve(NEG_EXAMPLES_IN_INIT_MODEL); - while( negativeExamples.size() < NEG_EXAMPLES_IN_INIT_MODEL ) + while( (int)negativeExamples.size() < NEG_EXAMPLES_IN_INIT_MODEL ) { int i = rng.uniform((int)0, (int)scanGrid.size()); if( std::find(indices.begin(), indices.end(), i) == indices.end() && overlap(boundingBox, scanGrid[i]) < NEXPERT_THRESHOLD ) @@ -919,7 +919,7 @@ void TrackerTLDModel::pushIntoModel(const Mat_& example, bool positive) proxyN = &timeStampNegativeNext; proxyT = &timeStampsNegative; } - if( proxyV->size() < MAX_EXAMPLES_IN_MODEL ) + if( (int)proxyV->size() < MAX_EXAMPLES_IN_MODEL ) { proxyV->push_back(example); proxyT->push_back(*proxyN); From f1d183acb1137f302afda883ba49c234ac559c6e Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 11 Aug 2014 20:24:29 +0300 Subject: [PATCH 21/26] vadim --- modules/tracking/src/tld_tracker.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 3c90c0369..171173e7f 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -48,18 +48,18 @@ #include "tld_tracker.hpp" #include "opencv2/highgui.hpp" -#define THETA_NN 0.50 const int STANDARD_PATCH_SIZE = 15; -#define CORE_THRESHOLD 0.5 const int NEG_EXAMPLES_IN_INIT_MODEL = 300; const int MAX_EXAMPLES_IN_MODEL = 500; const int MEASURES_PER_CLASSIFIER = 13; -#define SCALE_STEP 1.2 -#define ENSEMBLE_THRESHOLD 0.5 -#define VARIANCE_THRESHOLD 0.5 -#define NEXPERT_THRESHOLD 0.2 const int GRIDSIZE = 15; const int DOWNSCALE_MODE = cv::INTER_LINEAR; +const double THETA_NN = 0.50; +const double CORE_THRESHOLD = 0.5; +const double SCALE_STEP = 1.2; +const double ENSEMBLE_THRESHOLD = 0.5; +const double VARIANCE_THRESHOLD = 0.5; +const double NEXPERT_THRESHOLD = 0.2; #define BLUR_AS_VADIM #undef CLOSED_LOOP static const cv::Size GaussBlurKernelSize(3, 3); From 0b1754455bc2e2856e88e1599b2d42993159d547 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 11 Aug 2014 20:47:14 +0300 Subject: [PATCH 22/26] vadim pull req comments --- modules/tracking/src/tld_tracker.cpp | 47 ++++++++++++++++------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 171173e7f..88d7c11e2 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -48,25 +48,6 @@ #include "tld_tracker.hpp" #include "opencv2/highgui.hpp" -const int STANDARD_PATCH_SIZE = 15; -const int NEG_EXAMPLES_IN_INIT_MODEL = 300; -const int MAX_EXAMPLES_IN_MODEL = 500; -const int MEASURES_PER_CLASSIFIER = 13; -const int GRIDSIZE = 15; -const int DOWNSCALE_MODE = cv::INTER_LINEAR; -const double THETA_NN = 0.50; -const double CORE_THRESHOLD = 0.5; -const double SCALE_STEP = 1.2; -const double ENSEMBLE_THRESHOLD = 0.5; -const double VARIANCE_THRESHOLD = 0.5; -const double NEXPERT_THRESHOLD = 0.2; -#define BLUR_AS_VADIM -#undef CLOSED_LOOP -static const cv::Size GaussBlurKernelSize(3, 3); - -using namespace cv; -using namespace tld; - /* * FIXME(optimize): * no median @@ -98,6 +79,25 @@ using namespace tld; namespace cv { +namespace tld +{ + +const int STANDARD_PATCH_SIZE = 15; +const int NEG_EXAMPLES_IN_INIT_MODEL = 300; +const int MAX_EXAMPLES_IN_MODEL = 500; +const int MEASURES_PER_CLASSIFIER = 13; +const int GRIDSIZE = 15; +const int DOWNSCALE_MODE = cv::INTER_LINEAR; +const double THETA_NN = 0.50; +const double CORE_THRESHOLD = 0.5; +const double SCALE_STEP = 1.2; +const double ENSEMBLE_THRESHOLD = 0.5; +const double VARIANCE_THRESHOLD = 0.5; +const double NEXPERT_THRESHOLD = 0.2; +#define BLUR_AS_VADIM +#undef CLOSED_LOOP +static const cv::Size GaussBlurKernelSize(3, 3); + class TLDDetector; class MyMouseCallbackDEBUG { @@ -245,6 +245,8 @@ protected: Ptr detector; }; +} + TrackerTLD::Params::Params(){} void TrackerTLD::Params::read(const cv::FileNode& /*fn*/){} @@ -253,9 +255,12 @@ void TrackerTLD::Params::write(cv::FileStorage& /*fs*/) const {} Ptr TrackerTLD::createTracker(const TrackerTLD::Params ¶meters) { - return Ptr(new TrackerTLDImpl(parameters)); + return Ptr(new tld::TrackerTLDImpl(parameters)); } +namespace tld +{ + TrackerTLDImpl::TrackerTLDImpl(const TrackerTLD::Params ¶meters) : params( parameters ) { @@ -938,4 +943,6 @@ void TrackerTLDModel::prepareClassifiers(int rowstep) classifiers[i].prepareClassifier(rowstep); } +} /* namespace tld */ + } /* namespace cv */ From 73e1625acca4e77a1488c0f86afe475cf0794807 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 11 Aug 2014 22:10:45 +0300 Subject: [PATCH 23/26] docs --- modules/tracking/doc/tracker_algorithms.rst | 111 +++++++++++++++++- .../include/opencv2/tracking/tracker.hpp | 3 +- 2 files changed, 112 insertions(+), 2 deletions(-) diff --git a/modules/tracking/doc/tracker_algorithms.rst b/modules/tracking/doc/tracker_algorithms.rst index d20b10607..6ea96fd4d 100644 --- a/modules/tracking/doc/tracker_algorithms.rst +++ b/modules/tracking/doc/tracker_algorithms.rst @@ -9,6 +9,10 @@ The following algorithms are implemented at the moment. .. [OLB] H Grabner, M Grabner, and H Bischof, Real-time tracking via on-line boosting, In Proc. BMVC, volume 1, pages 47– 56, 2006 +.. [MedianFlow] Z. Kalal, K. Mikolajczyk, and J. Matas, “Forward-Backward Error: Automatic Detection of Tracking Failures,” International Conference on Pattern Recognition, 2010, pp. 23-26. + +.. [TLD] Z. Kalal, K. Mikolajczyk, and J. Matas, “Tracking-Learning-Detection,” Pattern Analysis and Machine Intelligence 2011. + TrackerBoosting --------------- @@ -63,7 +67,7 @@ Constructor :param parameters: BOOSTING parameters :ocv:struct:`TrackerBoosting::Params` TrackerMIL ----------- +---------------------- The MIL algorithm trains a classifier in an online manner to separate the object from the background. Multiple Instance Learning avoids the drift problem for a robust tracking. The implementation is based on [MIL]_. @@ -118,3 +122,108 @@ Constructor .. ocv:function:: Ptr TrackerMIL::createTracker(const trackerMIL::Params ¶meters=trackerMIL::Params()) :param parameters: MIL parameters :ocv:struct:`TrackerMIL::Params` + +TrackerMedianFlow +---------------------- + +Implementation of a paper "Forward-Backward Error: Automatic Detection of Tracking Failures" by Z. Kalal, K. Mikolajczyk +and Jiri Matas. The implementation is based on [MedianFlow]_. + +The tracker is suitable for very smooth and predictable movements when object is visible throughout the whole sequence. It's quite and +accurate for this type of problems (in particular, it was shown by authors to outperform MIL). During the implementation period the code at +http://www.aonsquared.co.uk/node/5, the courtesy of the author Arthur Amarra, was used for the reference purpose. + +.. ocv:class:: TrackerMedianFlow + +Implementation of TrackerMedianFlow from :ocv:class:`Tracker`:: + + class CV_EXPORTS_W TrackerMedianFlow : public Tracker + { + public: + void read( const FileNode& fn ); + void write( FileStorage& fs ) const; + static Ptr createTracker(const trackerMedianFlow::Params ¶meters=trackerMedianFlow::Params()); + virtual ~trackerMedianFlow(){}; + + protected: + bool initImpl( const Mat& image, const Rect2d& boundingBox ); + bool updateImpl( const Mat& image, Rect2d& boundingBox ); + }; + +TrackerMedianFlow::Params +------------------------------------ + +.. ocv:struct:: TrackerMedianFlow::Params + +List of MedianFlow parameters:: + + struct CV_EXPORTS Params + { + Params(); + int pointsInGrid; //square root of number of keypoints used; increase it to trade + //accurateness for speed; default value is sensible and recommended + + void read( const FileNode& fn ); + void write( FileStorage& fs ) const; + }; + +TrackerMedianFlow::createTracker +----------------------------------- + +Constructor + +.. ocv:function:: Ptr TrackerMedianFlow::createTracker(const trackerMedianFlow::Params ¶meters=trackerMedianFlow::Params()) + + :param parameters: Median Flow parameters :ocv:struct:`TrackerMedianFlow::Params` + +TrackerTLD +---------------------- + +TLD is a novel tracking framework that explicitly decomposes the long-term tracking task into tracking, learning + and detection. The tracker follows the object from frame to frame. The detector localizes all appearances that have been observed so + far and corrects the tracker if necessary. The learning estimates detector’s errors and updates it to avoid these errors in the future. +The implementation is based on [TLD]_. + +The Median Flow algorithm (see above) was chosen as a tracking component in this implementation, following authors. Tracker is supposed to be able +to handle rapid motions, partial occlusions, object absence etc. + +.. ocv:class:: TrackerTLD + +Implementation of TrackerTLD from :ocv:class:`Tracker`:: + + class CV_EXPORTS_W TrackerTLD : public Tracker + { + public: + void read( const FileNode& fn ); + void write( FileStorage& fs ) const; + static Ptr createTracker(const trackerTLD::Params ¶meters=trackerTLD::Params()); + virtual ~trackerTLD(){}; + + protected: + bool initImpl( const Mat& image, const Rect2d& boundingBox ); + bool updateImpl( const Mat& image, Rect2d& boundingBox ); + }; + +TrackerTLD::Params +------------------------ + +.. ocv:struct:: TrackerTLD::Params + +List of TLD parameters:: + + struct CV_EXPORTS Params + { + Params(); + + void read( const FileNode& fn ); + void write( FileStorage& fs ) const; + }; + +TrackerTLD::createTracker +------------------------------- + +Constructor + +.. ocv:function:: Ptr TrackerTLD::createTracker(const trackerTLD::Params ¶meters=trackerTLD::Params()) + + :param parameters: TLD parameters :ocv:struct:`TrackerTLD::Params` diff --git a/modules/tracking/include/opencv2/tracking/tracker.hpp b/modules/tracking/include/opencv2/tracking/tracker.hpp index 795753cc7..e043f53e2 100644 --- a/modules/tracking/include/opencv2/tracking/tracker.hpp +++ b/modules/tracking/include/opencv2/tracking/tracker.hpp @@ -1017,7 +1017,8 @@ class CV_EXPORTS_W TrackerMedianFlow : public Tracker struct CV_EXPORTS Params { Params(); - int pointsInGrid; + int pointsInGrid; //square root of number of keypoints used; increase it to trade + //accurateness for speed; default value is sensible and recommended void read( const FileNode& /*fn*/ ); void write( FileStorage& /*fs*/ ) const; }; From 1308ec659d74993fdaf35b542f86392e16080122 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Mon, 11 Aug 2014 22:26:52 +0300 Subject: [PATCH 24/26] buildbot --- modules/tracking/doc/tracker_algorithms.rst | 5 +---- modules/tracking/src/tld_tracker.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/tracking/doc/tracker_algorithms.rst b/modules/tracking/doc/tracker_algorithms.rst index 6ea96fd4d..dee541a26 100644 --- a/modules/tracking/doc/tracker_algorithms.rst +++ b/modules/tracking/doc/tracker_algorithms.rst @@ -179,10 +179,7 @@ Constructor TrackerTLD ---------------------- -TLD is a novel tracking framework that explicitly decomposes the long-term tracking task into tracking, learning - and detection. The tracker follows the object from frame to frame. The detector localizes all appearances that have been observed so - far and corrects the tracker if necessary. The learning estimates detector’s errors and updates it to avoid these errors in the future. -The implementation is based on [TLD]_. +TLD is a novel tracking framework that explicitly decomposes the long-term tracking task into tracking, learning and detection. The tracker follows the object from frame to frame. The detector localizes all appearances that have been observed so far and corrects the tracker if necessary. The learning estimates detector’s errors and updates it to avoid these errors in the future. The implementation is based on [TLD]_. The Median Flow algorithm (see above) was chosen as a tracking component in this implementation, following authors. Tracker is supposed to be able to handle rapid motions, partial occlusions, object absence etc. diff --git a/modules/tracking/src/tld_tracker.cpp b/modules/tracking/src/tld_tracker.cpp index 88d7c11e2..42e92f5f7 100644 --- a/modules/tracking/src/tld_tracker.cpp +++ b/modules/tracking/src/tld_tracker.cpp @@ -208,8 +208,9 @@ protected: class Pexpert { public: - Pexpert(const Mat& img, const Mat& imgBlurred, Rect2d& resultBox, const TLDDetector* detector, TrackerTLD::Params params, Size initSize): - img_(img), imgBlurred_(imgBlurred), resultBox_(resultBox), detector_(detector), params_(params), initSize_(initSize){} + Pexpert(const Mat& img_in, const Mat& imgBlurred_in, Rect2d& resultBox_in, + const TLDDetector* detector_in, TrackerTLD::Params params_in, Size initSize_in): + img_(img_in), imgBlurred_(imgBlurred_in), resultBox_(resultBox_in), detector_(detector_in), params_(params_in), initSize_(initSize_in){} bool operator()(Rect2d /*box*/){ return false; } int additionalExamples(std::vector >& examplesForModel, std::vector >& examplesForEnsemble); protected: @@ -225,9 +226,9 @@ protected: class Nexpert : public Pexpert { public: - Nexpert(const Mat& img, Rect2d& resultBox, const TLDDetector* detector, TrackerTLD::Params params) + Nexpert(const Mat& img_in, Rect2d& resultBox_in, const TLDDetector* detector_in, TrackerTLD::Params params_in) { - img_ = img; resultBox_ = resultBox; detector_ = detector; params_ = params; + img_ = img_in; resultBox_ = resultBox_in; detector_ = detector_in; params_ = params_in; } bool operator()(Rect2d box); int additionalExamples(std::vector >& examplesForModel, std::vector >& examplesForEnsemble) From 2e022117bacadd856fc3f1162e9b5ae6e158ae96 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Tue, 12 Aug 2014 11:30:11 +0300 Subject: [PATCH 25/26] buildbot --- modules/tracking/src/tld_utils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index c85467fdc..6fdccd035 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -380,11 +380,11 @@ int TLDEnsembleClassifier::makeClassifiers(Size size, int measurePerClassifier, for( int k = 0; k < j; k++ ) { Vec4b m; - m.val[0] = m.val[2] = i; - m.val[1] = j; m.val[3] = k; + m.val[0] = m.val[2] = (uchar)i; + m.val[1] = j; m.val[3] = (uchar)k; measurements.push_back(m); - m.val[1] = m.val[3] = i; - m.val[0] = j; m.val[2] = k; + m.val[1] = m.val[3] = (uchar)i; + m.val[0] = j; m.val[2] = (uchar)k; measurements.push_back(m); } } @@ -396,7 +396,7 @@ int TLDEnsembleClassifier::makeClassifiers(Size size, int measurePerClassifier, stepPrefSuff(measurements, 2, size.height, gridSize); stepPrefSuff(measurements, 3, size.height, gridSize); - for( int i = 0, howMany = measurements.size() / measurePerClassifier; i < howMany; i++ ) + for( int i = 0, howMany = (int)measurements.size() / measurePerClassifier; i < howMany; i++ ) classifiers.push_back(TLDEnsembleClassifier(measurements, i * measurePerClassifier, (i + 1) * measurePerClassifier)); return (int)classifiers.size(); } From eee3e0528c3e1e48adc11f46d3d05f8a84d12766 Mon Sep 17 00:00:00 2001 From: Alex Leontiev Date: Tue, 12 Aug 2014 16:49:24 +0300 Subject: [PATCH 26/26] buildbot --- modules/tracking/src/tld_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tracking/src/tld_utils.cpp b/modules/tracking/src/tld_utils.cpp index 6fdccd035..df9c9b709 100644 --- a/modules/tracking/src/tld_utils.cpp +++ b/modules/tracking/src/tld_utils.cpp @@ -381,10 +381,10 @@ int TLDEnsembleClassifier::makeClassifiers(Size size, int measurePerClassifier, { Vec4b m; m.val[0] = m.val[2] = (uchar)i; - m.val[1] = j; m.val[3] = (uchar)k; + m.val[1] = (uchar)j; m.val[3] = (uchar)k; measurements.push_back(m); m.val[1] = m.val[3] = (uchar)i; - m.val[0] = j; m.val[2] = (uchar)k; + m.val[0] = (uchar)j; m.val[2] = (uchar)k; measurements.push_back(m); } }