Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you're drawing your contours 2 x , the first time all of them, the next only the big ones.

just remove (or comment) the first loop:

// not needed:
for(int i = 0; i < contours.size(); i++)
{
    Scalar color = Scalar(255,255,255);
    drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
    fillPoly(drawing, contours, Scalar(255,0,0));
}

you're drawing your contours 2 x , the first time all of them, the next only the big ones.

just remove (or comment) the first loop:

// not needed:
for(int //for(int i = 0; i < contours.size(); i++)
{
 //{
//    Scalar color = Scalar(255,255,255);
 //    drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
 //    fillPoly(drawing, contours, Scalar(255,0,0));
}
//}

and draw the poly int the second loop:

you're drawing your contours 2 x , the first time all of them, the next only the big ones.

just remove (or comment) the first loop:

// not needed:
//for(int i = 0; i < contours.size(); i++)
//{
//    Scalar color = Scalar(255,255,255);
//    drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
//    fillPoly(drawing, contours, Scalar(255,0,0));
//}

and draw the poly int the second loop: