I am trying to run the squares.cpp example in the openCV 2.2. The code compiles and builds without errors in Visual Studio 2008. However when I run the executable (i.e., during run time) I am getting a error stating
Unhandled exception at 0x004ac363 in OpenCVRectangle.exe: 0xC0000005: Access violation reading location 0xcccccccc.
This occurs at the definition:
vector<vector<Point> > squares;
in the main function
Can somebody help, why this occurs?
I figured out that the value 0xcccccc usually is an uninitialized or bad variable, but do not understand why I get this exception at this line.
The full example code can be found at http://pastebin.com/MTaXVcQz
Your code runs fine on Mac OS X with OpenCV 2.3.0, but OpenCV is known to present different behaviors in different Operating Systems.
First, check if your code has this problem in both Release and Debug versions.
Upgrade to OpenCV 2.3.1 on Windows and see if the problem goes away.