Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is some code for using findContours:

using namespace cv;
using namespace std;

// ...

vector<vector<Point>> contours;
Mat imgGray, imgEdges;

// m is your input image

cvtColor(m, imgGray, CV_RGB2GRAY);
threshold(imgGray, imgEdges, threshold-value, 255, CV_THRESH_BINARY);

// erode, dilation, ...

findContours(imgEdges, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE );

You should try to make this work, because findContours is an elementary function which you will use often.