From: Vadim Pisarevsky Date: Mon, 29 Nov 2010 13:34:32 +0000 (+0000) Subject: removed duplicated data for samples (it is now in samples/cpp) X-Git-Tag: accepted/2.0/20130307.220821~4040 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d990b7f69bd6f2695d918a8b1c8bd0b88f8b748;p=profile%2Fivi%2Fopencv.git removed duplicated data for samples (it is now in samples/cpp) --- diff --git a/samples/c/left01.jpg b/samples/c/left01.jpg deleted file mode 100644 index 6ade320..0000000 Binary files a/samples/c/left01.jpg and /dev/null differ diff --git a/samples/c/left02.jpg b/samples/c/left02.jpg deleted file mode 100644 index 457820e..0000000 Binary files a/samples/c/left02.jpg and /dev/null differ diff --git a/samples/c/left03.jpg b/samples/c/left03.jpg deleted file mode 100644 index 7f3990f..0000000 Binary files a/samples/c/left03.jpg and /dev/null differ diff --git a/samples/c/left04.jpg b/samples/c/left04.jpg deleted file mode 100644 index 3144a18..0000000 Binary files a/samples/c/left04.jpg and /dev/null differ diff --git a/samples/c/left05.jpg b/samples/c/left05.jpg deleted file mode 100644 index 7b57131..0000000 Binary files a/samples/c/left05.jpg and /dev/null differ diff --git a/samples/c/left06.jpg b/samples/c/left06.jpg deleted file mode 100644 index 1c6a217..0000000 Binary files a/samples/c/left06.jpg and /dev/null differ diff --git a/samples/c/left07.jpg b/samples/c/left07.jpg deleted file mode 100644 index 46acbb9..0000000 Binary files a/samples/c/left07.jpg and /dev/null differ diff --git a/samples/c/left08.jpg b/samples/c/left08.jpg deleted file mode 100644 index 0fe7646..0000000 Binary files a/samples/c/left08.jpg and /dev/null differ diff --git a/samples/c/left09.jpg b/samples/c/left09.jpg deleted file mode 100644 index 5d17e95..0000000 Binary files a/samples/c/left09.jpg and /dev/null differ diff --git a/samples/c/left11.jpg b/samples/c/left11.jpg deleted file mode 100644 index 7ca2a14..0000000 Binary files a/samples/c/left11.jpg and /dev/null differ diff --git a/samples/c/left12.jpg b/samples/c/left12.jpg deleted file mode 100644 index 897955d..0000000 Binary files a/samples/c/left12.jpg and /dev/null differ diff --git a/samples/c/left13.jpg b/samples/c/left13.jpg deleted file mode 100644 index e2f060f..0000000 Binary files a/samples/c/left13.jpg and /dev/null differ diff --git a/samples/c/left14.jpg b/samples/c/left14.jpg deleted file mode 100644 index 1dec7c6..0000000 Binary files a/samples/c/left14.jpg and /dev/null differ diff --git a/samples/c/pic1.png b/samples/c/pic1.png deleted file mode 100644 index 3e48aa4..0000000 Binary files a/samples/c/pic1.png and /dev/null differ diff --git a/samples/c/pic2.png b/samples/c/pic2.png deleted file mode 100644 index 068213f..0000000 Binary files a/samples/c/pic2.png and /dev/null differ diff --git a/samples/c/pic3.png b/samples/c/pic3.png deleted file mode 100644 index fe214f0..0000000 Binary files a/samples/c/pic3.png and /dev/null differ diff --git a/samples/c/pic4.png b/samples/c/pic4.png deleted file mode 100644 index 57b7a0d..0000000 Binary files a/samples/c/pic4.png and /dev/null differ diff --git a/samples/c/pic5.png b/samples/c/pic5.png deleted file mode 100644 index 2e6bfa7..0000000 Binary files a/samples/c/pic5.png and /dev/null differ diff --git a/samples/c/pic6.png b/samples/c/pic6.png deleted file mode 100644 index 5cd6ab0..0000000 Binary files a/samples/c/pic6.png and /dev/null differ diff --git a/samples/c/right01.jpg b/samples/c/right01.jpg deleted file mode 100644 index 4d6071b..0000000 Binary files a/samples/c/right01.jpg and /dev/null differ diff --git a/samples/c/right02.jpg b/samples/c/right02.jpg deleted file mode 100644 index 6c0fab0..0000000 Binary files a/samples/c/right02.jpg and /dev/null differ diff --git a/samples/c/right03.jpg b/samples/c/right03.jpg deleted file mode 100644 index 7502761..0000000 Binary files a/samples/c/right03.jpg and /dev/null differ diff --git a/samples/c/right04.jpg b/samples/c/right04.jpg deleted file mode 100644 index 958973b..0000000 Binary files a/samples/c/right04.jpg and /dev/null differ diff --git a/samples/c/right05.jpg b/samples/c/right05.jpg deleted file mode 100644 index 926c825..0000000 Binary files a/samples/c/right05.jpg and /dev/null differ diff --git a/samples/c/right06.jpg b/samples/c/right06.jpg deleted file mode 100644 index 69a7994..0000000 Binary files a/samples/c/right06.jpg and /dev/null differ diff --git a/samples/c/right07.jpg b/samples/c/right07.jpg deleted file mode 100644 index 9aff92b..0000000 Binary files a/samples/c/right07.jpg and /dev/null differ diff --git a/samples/c/right08.jpg b/samples/c/right08.jpg deleted file mode 100644 index abb794a..0000000 Binary files a/samples/c/right08.jpg and /dev/null differ diff --git a/samples/c/right09.jpg b/samples/c/right09.jpg deleted file mode 100644 index a6dd6f9..0000000 Binary files a/samples/c/right09.jpg and /dev/null differ diff --git a/samples/c/right11.jpg b/samples/c/right11.jpg deleted file mode 100644 index 29b99be..0000000 Binary files a/samples/c/right11.jpg and /dev/null differ diff --git a/samples/c/right12.jpg b/samples/c/right12.jpg deleted file mode 100644 index 35b2d07..0000000 Binary files a/samples/c/right12.jpg and /dev/null differ diff --git a/samples/c/right13.jpg b/samples/c/right13.jpg deleted file mode 100644 index d504a46..0000000 Binary files a/samples/c/right13.jpg and /dev/null differ diff --git a/samples/c/right14.jpg b/samples/c/right14.jpg deleted file mode 100644 index 2decf1e..0000000 Binary files a/samples/c/right14.jpg and /dev/null differ diff --git a/samples/c/squares.c b/samples/c/squares.c deleted file mode 100644 index 61aa09b..0000000 --- a/samples/c/squares.c +++ /dev/null @@ -1,221 +0,0 @@ -// -// The full "Square Detector" program. -// It loads several images subsequentally and tries to find squares in -// each image -// -#include "opencv2/imgproc/imgproc_c.h" -#include "opencv2/highgui/highgui.hpp" -#include -#include -#include - -int thresh = 50; -IplImage* img = 0; -IplImage* img0 = 0; -CvMemStorage* storage = 0; -const char* wndname = "Square Detection Demo"; - -// helper function: -// finds a cosine of angle between vectors -// from pt0->pt1 and from pt0->pt2 -double angle( CvPoint* pt1, CvPoint* pt2, CvPoint* pt0 ) -{ - double dx1 = pt1->x - pt0->x; - double dy1 = pt1->y - pt0->y; - double dx2 = pt2->x - pt0->x; - double dy2 = pt2->y - pt0->y; - return (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10); -} - -// returns sequence of squares detected on the image. -// the sequence is stored in the specified memory storage -CvSeq* findSquares4( IplImage* img, CvMemStorage* storage ) -{ - CvSeq* contours; - int i, c, l, N = 11; - CvSize sz = cvSize( img->width & -2, img->height & -2 ); - IplImage* timg = cvCloneImage( img ); // make a copy of input image - IplImage* gray = cvCreateImage( sz, 8, 1 ); - IplImage* pyr = cvCreateImage( cvSize(sz.width/2, sz.height/2), 8, 3 ); - IplImage* tgray; - CvSeq* result; - double s, t; - // create empty sequence that will contain points - - // 4 points per square (the square's vertices) - CvSeq* squares = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvPoint), storage ); - // select the maximum ROI in the image - // with the width and height divisible by 2 - cvSetImageROI( timg, cvRect( 0, 0, sz.width, sz.height )); - - // down-scale and upscale the image to filter out the noise - cvPyrDown( timg, pyr, 7 ); - cvPyrUp( pyr, timg, 7 ); - tgray = cvCreateImage( sz, 8, 1 ); - - // find squares in every color plane of the image - for( c = 0; c < 3; c++ ) - { - // extract the c-th color plane - cvSetImageCOI( timg, c+1 ); - cvCopy( timg, tgray, 0 ); - - // try several threshold levels - for( l = 0; l < N; l++ ) - { - // hack: use Canny instead of zero threshold level. - // Canny helps to catch squares with gradient shading - if( l == 0 ) - { - // apply Canny. Take the upper threshold from slider - // and set the lower to 0 (which forces edges merging) - cvCanny( tgray, gray, 0, thresh, 5 ); - // dilate canny output to remove potential - // holes between edge segments - cvDilate( gray, gray, 0, 1 ); - } - else - { - // apply threshold if l!=0: - // tgray(x,y) = gray(x,y) < (l+1)*255/N ? 255 : 0 - cvThreshold( tgray, gray, (l+1)*255/N, 255, CV_THRESH_BINARY ); - } - - // find contours and store them all as a list - cvFindContours( gray, storage, &contours, sizeof(CvContour), - CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) ); - - // test each contour - while( contours ) - { - // approximate contour with accuracy proportional - // to the contour perimeter - result = cvApproxPoly( contours, sizeof(CvContour), storage, - CV_POLY_APPROX_DP, cvContourPerimeter(contours)*0.02, 0 ); - // square contours should have 4 vertices after approximation - // relatively large area (to filter out noisy contours) - // and be convex. - // Note: absolute value of an area is used because - // area may be positive or negative - in accordance with the - // contour orientation - if( result->total == 4 && - cvContourArea(result,CV_WHOLE_SEQ,0) > 1000 && - cvCheckContourConvexity(result) ) - { - s = 0; - - for( i = 0; i < 5; i++ ) - { - // find minimum angle between joint - // edges (maximum of cosine) - if( i >= 2 ) - { - t = fabs(angle( - (CvPoint*)cvGetSeqElem( result, i ), - (CvPoint*)cvGetSeqElem( result, i-2 ), - (CvPoint*)cvGetSeqElem( result, i-1 ))); - s = s > t ? s : t; - } - } - - // if cosines of all angles are small - // (all angles are ~90 degree) then write quandrange - // vertices to resultant sequence - if( s < 0.3 ) - for( i = 0; i < 4; i++ ) - cvSeqPush( squares, - (CvPoint*)cvGetSeqElem( result, i )); - } - - // take the next contour - contours = contours->h_next; - } - } - } - - // release all the temporary images - cvReleaseImage( &gray ); - cvReleaseImage( &pyr ); - cvReleaseImage( &tgray ); - cvReleaseImage( &timg ); - - return squares; -} - - -// the function draws all the squares in the image -void drawSquares( IplImage* img, CvSeq* squares ) -{ - CvSeqReader reader; - IplImage* cpy = cvCloneImage( img ); - int i; - - // initialize reader of the sequence - cvStartReadSeq( squares, &reader, 0 ); - - // read 4 sequence elements at a time (all vertices of a square) - for( i = 0; i < squares->total; i += 4 ) - { - CvPoint pt[4], *rect = pt; - int count = 4; - - // read 4 vertices - CV_READ_SEQ_ELEM( pt[0], reader ); - CV_READ_SEQ_ELEM( pt[1], reader ); - CV_READ_SEQ_ELEM( pt[2], reader ); - CV_READ_SEQ_ELEM( pt[3], reader ); - - // draw the square as a closed polyline - cvPolyLine( cpy, &rect, &count, 1, 1, CV_RGB(0,255,0), 3, CV_AA, 0 ); - } - - // show the resultant image - cvShowImage( wndname, cpy ); - cvReleaseImage( &cpy ); -} - - -char* names[] = { "pic1.png", "pic2.png", "pic3.png", - "pic4.png", "pic5.png", "pic6.png", 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 ); - - cvReleaseMemStorage(&storage); - - return 0; -}