Ask Your Question
0

I am using this code to find contours how can I elemenate some contours depending on their size? and how can I use the biggest contour as a ROI?

asked 2013-05-21 08:13:10 -0500

Ali Tillawi gravatar image

updated 2013-05-21 08:15:30 -0500

I am using this code to find contours how can I elemenate some contours depending on their size? and how can I use the biggest contour as a ROI?

CvScalar(ext_color);

 CvSeq* contours; 
CvMemStorage* storage2 = cvCreateMemStorage(0); //contours' storage
int n = cvFindContours(out3, storage2, &contours, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE, cvPoint(0,0));

for ( ; contours != 0; contours = contours->h_next) {

ext_color = CV_RGB( 233&255, 00&255, 255&255 );

cvDrawContours(frame, contours, ext_color, CV_RGB(0,0,0), -1, CV_FILLED, 8, cvPoint(0,0));

}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-05-21 09:18:19 -0500

Contours have parameters that you can call which will do exacly what you want. For each contour element you can calculate an area parameter, which can then be thresholded.

You can then define a bounding box based on the contour that has the largest area value, and use that bounding box as region of interest.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2013-05-21 08:13:10 -0500

Seen: 502 times

Last updated: May 21 '13