vector convert to mat rule

asked 2013-06-17 21:50:02 -0500

wuling gravatar image

updated 2017-09-03 11:42:37 -0500

Hi all, I have a question about vector convert to mat

for example: the code below from generalContours_demo2.cp

  for( size_t i = 0; i < contours.size(); i++ )
     { minRect[i] = minAreaRect( Mat(contours[i]) );
       if( contours[i].size() > 5 )
         { minEllipse[i] = fitEllipse( Mat(contours[i]) ); }
     }

it can be like

  for( size_t i = 0; i < contours.size(); i++ )
     { minRect[i] = minAreaRect( contours[i] );
       if( contours[i].size() > 5 )
         { minEllipse[i] = fitEllipse( contours[i] ); }
     }

is any rule to follow ?

thanks.

edit retag flag offensive close merge delete

Comments

findContours expects an 8bit binary img as 1st argument, so your first 2 lines won't work.

the last one won't work, too because of vector of vector.

please pick a better example!

berak gravatar imageberak ( 2013-06-18 02:12:45 -0500 )edit

hi berak,yes, the last contourArea(contourB) can't work,it should be contour(contourB[index]). I think i should try the other function.:)

wuling gravatar imagewuling ( 2013-06-18 07:50:32 -0500 )edit

i edited the question because i also want to get an answer.

sturkmen gravatar imagesturkmen ( 2017-09-03 11:43:46 -0500 )edit