Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

segmentation fault extracting contour element in replacement statement

Hi I get a segmentation fault when I extract an element from a contour in a replace statement but not in cout.

The first line prints fine, but there is a segmentation fault with the second line.

std::cout << "inContour y: " << inContour[0].y << '\n';

Yold = inContour[0].y;

At the point in the above code, I have isolated the largest contour and sorted it by the y terms. All appears OK with the sorted contour.

Yold has been declared with int Yold;

and inContour has been declared as vector<point> inContour; several lines above this. Moving the declaration of Yold to this line did not help.

Point is supposed default as a 2 parameter integer. Specifically declaring it as Point2i did not help.

Any suggestions?