Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is here:

float radius;
cv::Point2f center;
cv::minEnclosingCircle(cv::Mat(contours[1]),center,radius);

cv::findContours(                                       
        fg,                                                 
        contours,                                           
        hierarchy,
        CV_RETR_CCOMP,                                      
        CV_CHAIN_APPROX_SIMPLE);

You use contours in minEnclosingCircle function before it will be computed in findContours. Swap minEnclosingCircle and findContours calls.