// 找到所有轮廓
cvFindContours( dst, stor, &cont, sizeof(CvContour),
CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
// 如果轮廓不为NULL,则用多边形来拟合找到的轮廓,以减少轮郭的"点数".
if(cont)
{
// 绘制轮廓
cvDrawContours(dsta,cont,CV_RGB(255,255,0),CV_RGB(0,0,255),1,2,8,cvPoint(0,0));
mcont=cvApproxPoly(cont,sizeof(CvContour),mstor,CV_POLY_APPROX_DP,cvContourPerimeter(cont)*0.02,0);
cvDrawContours(dsta,mcont,CV_RGB(255,0,0),CV_RGB(0,0,100),1,2,8,cvPoint(0,0));
}
|