Reputation: 121
My problem is I do not know how to access vector <vector <Point>>
contour (this is 2D like matrix on OpenCV)
I want to do this. If Mat element does not consists in contours area I want to suppress that matrix elements. In order to do this I need to know contours element too.
Upvotes: 3
Views: 20192
Reputation: 22245
You need a for loop for both the first and the second vector. Something Like this:
vector< vector<Point> > contours;
for(int i= 0; i < contours.size(); i++)
{
for(int j= 0; j < contours[i].size();j++) // run until j < contours[i].size();
{
cout << contours[i][j] << endl; //do whatever
}
}
Upvotes: 11
Reputation: 550
If you need all points rather than just the edge points, you can use drawContours(....,thickness=CV_FILLED)
to dump this contour on a dummy Mat, then you can obtain those points by scanning the dummy Mat.
Upvotes: 0
Reputation: 20633
If my situation was so urgent, I would ask my question more carefully.
If I try hard to understand your question, you basically want to consider a contour in pixel level. In order to do that, you should draw the contour into a blank matrix with drawContour. And then compare two matrices or match a pixel in that matrix in case you want pixel by pixel.
Upvotes: 1