Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

vector convert to mat rule

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

vector<cv::Point> contourA;
vector<vector<cv::Point>> contoursB;
.......
cv::findContours(Mat(contourA),contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can't work
cv::findContours(Mat(contourB),contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can work
double area=cv::contourArea(Mat(contourA)); can work
double area=cv::contourArea(Mat(contourB)); can work

is any rule to follow? thanks.

vector convert to mat rule

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

vector<cv::Point> contourA;
vector<vector<cv::Point>> contoursB;
.......
cv::findContours(Mat(contourA),contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can't work
cv::findContours(Mat(contourB),contours,hierarchy, cv::findContours(contourB,contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can work
double area=cv::contourArea(Mat(contourA)); can //can work
double area=cv::contourArea(Mat(contourB)); can area=cv::contourArea(contourB); //can work

is any rule to follow? thanks.

vector convert to mat rule

Hi all, I have a question about vector convert to mat for examole:example:

vector<cv::Point> contourA;
vector<vector<cv::Point>> contoursB;
.......
cv::findContours(Mat(contourA),contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can't work
cv::findContours(contourB,contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can work
double area=cv::contourArea(Mat(contourA)); //can work
double area=cv::contourArea(contourB); //can work

is any rule to follow? thanks.

vector convert to mat rule

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

vector<cv::Point> contourA;
vector<vector<cv::Point>> contoursB;
contourB;
.......
cv::findContours(Mat(contourA),contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can't work
cv::findContours(contourB,contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can work
double area=cv::contourArea(Mat(contourA)); //can work
double area=cv::contourArea(contourB); //can work

is any rule to follow? thanks.

vector convert to mat rule

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

for example:example: the code below from generalContours_demo2.cp

vector<cv::Point> contourA;
vector<vector<cv::Point>> contourB;
.......
cv::findContours(Mat(contourA),contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can't work
cv::findContours(contourB,contours,hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE); //can work
double area=cv::contourArea(Mat(contourA)); //can work
double area=cv::contourArea(contourB); //can work
  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? follow ?

thanks.