int main5 (int argc, char** argv) { char* filename; int c; // create memory storage that will contain all the dynamic data gStorage = cvCreateMemStorage(0); if(argc == 2 ) { filename = argv[1]; } else { printf("Usage:\t%s image_file\n", argv[0]); printf("\timage_file: image that maybe contains rectangle\n\n"); return 0; } gImg0 = cvLoadImage(filename, 1); if (!gImg0) { printf("Couldn't load %s\n", filename); return 0; } gImg = cvCloneImage(gImg0); // create window and a trackbar (slider) with parent "image" and set callback // (the slider regulates upper threshold, passed to Canny edge detector) cvNamedWindow(wndname, 1); if (gImg) { CvSeq* squares = findSquares4(gImg, gStorage); drawSquares(gImg, squares); } // cvCreateTrackbar("canny thresh", wndname, &thresh, 1000, on_trackbar); // // // force the image processing // on_trackbar(0); // release both images cvReleaseImage(&gImg); cvReleaseImage(&gImg0); // clear memory storage - reset free space position cvClearMemStorage(gStorage); for(;;) { // wait for key. // Also the function cvWaitKey takes care of event processing c = cvWaitKey(0); if (c == 27) break; } cvDestroyWindow(wndname); return 0; }
void on_trackbar(CvPoint& centre, IplImage* img,CvMemStorage* &storage1) { if( img ) { drawSquares( img, findSquares4( img, storage1,true ) , centre); cvReleaseMemStorage(&storage1 ); } else cout<<"error in trackbar"<<endl; }
int main(int argc, char* argv[]) { int i=0, c; bPreviewFilter=false; // create memory storage that will contain all the dynamic data storage = cvCreateMemStorage(0); if (argc>1 && !strcmp(argv[1],"f")) bPreviewFilter=true; char names[255]; while(1) { sprintf(names, "pic%d.png", i+1); // load i-th image img0 = cvLoadImage( names, 1 ); if( !img0 ) { printf("Couldn't load %s\n", names ); break; } img = cvCloneImage( img0 ); // create window and a trackbar (slider) with parent "image" and set callback // (the slider regulates upper threshold, passed to Canny edge detector) cvNamedWindow( wndname, 1 ); // find and draw the squares IplImage* imgFilter = GetImageFilteredForSquareDetect(img); IplImage* imgShow; if (bPreviewFilter) imgShow = imgFilter; else imgShow = img; drawSquaresAndCrop(names, imgShow, img, findSquares4( imgFilter, storage ) ); //drawCircleAndCrop(names, img); cvReleaseImage(&imgFilter); // wait for key. // Also the function cvWaitKey takes care of event processing c = cvWaitKey(0); // release both images cvReleaseImage( &img ); cvReleaseImage( &img0 ); // clear memory storage - reset free space position cvClearMemStorage( storage ); if( (char)c == 27 ) break; i++; } cvDestroyWindow( wndname ); return 0; }
int main(int argc, char** argv) { int i, c; // create memory storage that will contain all the dynamic data storage = cvCreateMemStorage(0); for( i = 0; names[i] != 0; i++ ) { // load i-th image img0 = cvLoadImage( names[i], 1 ); if( !img0 ) { printf("Couldn't load %s\n", names[i] ); continue; } img = cvCloneImage( img0 ); // create window and a trackbar (slider) with parent "image" and set callback // (the slider regulates upper threshold, passed to Canny edge detector) cvNamedWindow( wndname, 1 ); // find and draw the squares drawSquares( img, findSquares4( img, storage ) ); // wait for key. // Also the function cvWaitKey takes care of event processing c = cvWaitKey(0); // release both images cvReleaseImage( &img ); cvReleaseImage( &img0 ); // clear memory storage - reset free space position cvClearMemStorage( storage ); if( (char)c == 27 ) break; } cvDestroyWindow( wndname ); return 0; }
void on_trackbar( int a ) { if( img ) drawSquares( img, findSquares4( img, storage ) ); }