Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

findContours and Mat(contours[i]) problems

std::vector<std::vector<cv:oint> > contours;
cv::findContours(gray_img->clone(), contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
int contour_num=contours.size();
for (int i = 0; i < contour_num; i++){
double area = cv::contourArea(contours[i]); //"area" is correct, such as 5000.

cv::Mat pointsf;
cv::Mat(contours[i]).convertTo(pointsf, CV_32F);
int W2=pointsf.rows;
int H2=pointsf.cols; //H2 is always 1, but why?
cout<<"W2="<

findContours and Mat(contours[i]) problems

std::vector<std::vector<cv:oint> > contours;
contours; cv::findContours(gray_img->clone(), contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
CV_CHAIN_APPROX_SIMPLE); int contour_num=contours.size();
contour_num=contours.size(); for (int i = 0; i < contour_num; i++){
i++){ double area = cv::contourArea(contours[i]); //"area" is correct, such as 5000. double area = cv::contourArea(contours[i]); //"area" is correct, such as 5000.

cv::Mat pointsf;
pointsf; cv::Mat(contours[i]).convertTo(pointsf, CV_32F);
CV_32F); int W2=pointsf.rows;
W2=pointsf.rows; int H2=pointsf.cols; //H2 is always 1, but why?
why? cout<<"W2="<cout<<"W2="<<W2<<", H2="<<H2<<endl; }

The value of H2 is always 1, what's the problem?

findContours and Mat(contours[i]) problems

std::vector<std::vector<cv:oint> std::vector<std::vector<cv:Point> > contours;
cv::findContours(gray_img->clone(), contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
int contour_num=contours.size();
for (int i = 0; i < contour_num; i++){
   double area = cv::contourArea(contours[i]); //"area" is correct, such as 5000.               
   cv::Mat pointsf;
   cv::Mat(contours[i]).convertTo(pointsf, CV_32F);
   int W2=pointsf.rows;
   int H2=pointsf.cols;  //H2 is always 1, but why?
   cout<<"W2="<<W2<<", H2="<<H2<<endl;
}

The value of H2 is always 1, what's the problem?