《提取二值图像中的最大轮廓OpenCV.docx》由会员分享,可在线阅读,更多相关《提取二值图像中的最大轮廓OpenCV.docx(1页珍藏版)》请在三一办公上搜索。
提取二值图像中的最大轮廓OpenCVCvPoint* points = NULL; CvMemStorage* storage = cvCreateMemStorage(0); int method = CV_CHAIN_APPROX_SIMPLE; int mode = CV_RETR_EXTERNAL; CvSeq* contours = NULL; int Nc = 0; int n_mMax = -1; Nc = cvFindContours( pImg, storage, &contours, sizeof(CvContour),mode, method); for(; contours; contours=contours-h_next) if(contours-total n_mMax) free(points); points = NULL; n_mMax = contours-total; points = (CvPoint*)malloc(contours-total * sizeof(CvPoint); for(i=0; itotal; i+) CvPoint* pt = (CvPoint*)cvGetSeqElem(contours,i); pointsi.x = pt-x; pointsi.y = pt-y; else continue;