vector convert to mat rule

asked Jun 18 '13

wuling gravatar image

updated Sep 3 '17

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.

Preview: (hide)

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 (Jun 18 '13)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 (Jun 18 '13)edit

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

sturkmen gravatar imagesturkmen (Sep 3 '17)edit