0
我已經從圖像中找到了輪廓,現在我想將矩形邊界框應用於輪廓線我也希望計數應該在這裏着色是我正在使用的代碼opencv將矩形邊界框添加到輪廓
int main()
{
CvSeq*contours=0;
CvSeq* canny_contours = 0;
CvMemStorage*storage=cvCreateMemStorage(0);
CvMemStorage* canny_storage = cvCreateMemStorage(0);
IplImage*a=cvLoadImage("lisc.jpg");
IplImage*b(cvCreateImage(cvGetSize(a),IPL_DEPTH_8U,1));
IplImage*c(cvCreateImage(cvGetSize(b),IPL_DEPTH_8U,1));
IplImage*d(cvCreateImage(cvGetSize(c),IPL_DEPTH_8U,1));
cvCvtColor(a,b,CV_RGB2GRAY);
cvThreshold(b,c,128,255,CV_THRESH_BINARY);
cvCanny(c,d,50,150,3);
cvFindContours(c,storage,&contours,sizeof(CvContour),
CV_RETR_EXTERNAL, CV_CHAIN_CODE);
cvFindContours(d, canny_storage, &canny_contours, sizeof(CvContour),
CV_RETR_EXTERNAL, CV_CHAIN_CODE);
cvDrawContours(c,contours,cvScalar(255,255,255), cvScalarAll(255), 100);
//for(; canny_contours != 0; canny_contours = canny_contours->h_next)
//{
// CvScalar color = CV_RGB(rand()&200, rand()&200, rand()&200);
/* replace CV_FILLED with 1 to see the outlines */
cvDrawContours(d, canny_contours, cvScalar(rand()&200,rand()&200,rand()&200),
cvScalarAll(rand()&200),1);
//}
cvNamedWindow("rola",CV_GUI_NORMAL);
cvNamedWindow("meaow0",CV_GUI_NORMAL);
cvShowImage("rola",c);
cvShowImage("meaow0",d);
cvWaitKey(0);
cvReleaseImage(&c);
cvReleaseImage(&d);
}
我無法找到合適的了Syntex爲它在我的代碼實現它們 –