findContours Problems with CV_RETR_CCOMP & CV_RETR_FLOODFILL
The contours are wrong:
problem1:
Mat arr(10,10,CV_8UC1,Scalar(0));
rectangle(arr,Point(2,0),Point(6,0),Scalar::all(1),-1);
cout << arr << endl;
vector<vector<Point>> contors;
findContours(arr,contors,CV_RETR_CCOMP,CV_CHAIN_APPROX_NONE);
for (size_t i=0;i < contors.size();i++)
cout << boundingRect(contors[i]) << endl;
Result1:
Problem2:
Mat arr(10,10,CV_32SC1,Scalar(0));
rectangle(arr,Point(2,1),Point(6,1),Scalar::all(1),-1);
cout << arr << endl;
vector<vector<Point>> contors;
findContours(arr,contors,CV_RETR_CCOMP,CV_CHAIN_APPROX_NONE);
for (size_t i=0;i < contors.size();i++)
cout << boundingRect(contors[i]) << endl;
Result2:
add a comment