Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if there are no contours found, you cannot index the (empty) contours array.

check your largest_area value, and only execute the drawing code, if it's != 0

if there are no contours found, you cannot index the (empty) contours array.

check your largest_area value, and only execute the drawing code, if it's != 0

also make sure, you initialize those variables per image, like:

int largest_area = 0; int largest_contour_index = 0; Rect bounding_rect;

if there are no contours found, you cannot index the (empty) contours array.

check your largest_area value, and only execute the drawing code, if it's != 0

also make sure, you initialize those variables per image, like:

for (size_t i = 0; i < files.size(); i++) {
    int largest_area = 0;
 int largest_contour_index = 0;
 Rect bounding_rect;

bounding_rect; ...