Ask Your Question

Revision history [back]

Could you change it so that it draw a line along moving contour

No we can not. This forum is a forum where you get suggestions on what to do, but we will not code your problem for you.

As to how to tackle this, when looping over your contours, you can retrieve the center of mass of the contour, by using this partial code.

Moments mu = moments(contour[i]);
Point centroid = cv::Point (mu.m10/mu.m00 , mu.m01/mu.m00);

Do this for each contour and push all the points retrieve into a vector<Point>. Now just draw a line between each subsequent point using the line function.