# Include <cv. h>
# Include <cxcore. h>
# Include # Include <cvaux. h>
# Include <iostream>
Using namespace STD;
Int main ()
{
Iplimage * src = cvloadimage ("G: \ Users \ movingobjectdetector \ Result \ resultfor [g_85_flv] \ mask16.jpg", cv_load_image_grayscale );
Iplimage * DST = cvcreateimage (cvgetsize (SRC), 8, 3); cvzero (DST );
Cvmemstorage * storage = cvcreatememstorage ();
Cvseq * contour = NULL, * hull = NULL;
Cv1_1_1_= cvstartfindcontours (SRC, storage );
While (contour = cvfindnextcontour (timeout ))! = NULL ){
Cvdrawcontours (DST, contour, cv_rgb (255,0, 0), cv_rgb (0,255, 0), 0 );
Cout <cvcheck1_convexity (contour) <Endl;
Hull = cvconvexhull2 (contour, 0, cv_clockwise, 0);/* simple * // * Convex Hull for calculating known contours */
Cvpoint pt0 = ** (cvpoint **) cvgetseqelem (Hull, hull-> total-1 );
For (INT I = 0; I Cvpoint pt1 = ** (cvpoint **) cvgetseqelem (Hull, I );
Cvline (DST, pt0, pt1, cv_rgb (0, 0, 255 ));
Pt0 = pt1;
}
Cvseq * defect = cvconvexitydefects (contour, hull); // detect contour convex Defects
For (INT I = 0; I <defect-> total; ++ I ){
Cvconvexitydefect df = * (cvconvexitydefect *) cvgetseqelem (defect, I );
Cvcircle (DST, * DF. start, 2, cv_rgb (255,255, 0),-1); // corresponding to the convex points, link these points to form a multi-deformation, convex bag is
Cvcircle (DST, * DF. End, 2, cv_rgb (255, 0, 255),-1 );
Cvcircle (DST, * DF. depth_point, 2, cv_rgb (0,255,255),-1); // corresponding to the concave points
Cvline (DST, * DF. Start, * DF. depth_point, cv_rgb (0,255,255 ));
}
Cvshowimage ("DST", DST );
Cvwaitkey ();
}
Cvendfindcontours (& region );
}