2

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

Ayyala
  • 159
  • 4
  • 7
  • 0xCCCCCCCC is uninitialized memory [When and why will an OS initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete?](http://stackoverflow.com/q/370195/995714) – phuclv Apr 28 '15 at 15:44

3 Answers3

1

namedWindow in the code you linked to is a function which doesn't look defined in this scope. It might be that it's trying to interpret as a variable which has not been defined, rather than a function. I would say it's missing some sort of library perhaps? It's difficult to say without further context, but vector<vector<Point> > squares; should not be a violation.

Neil
  • 5,762
  • 24
  • 36
1

Press Ctrl + Alt + E in VS, enable all exceptions checking, run it in debug mode and see the place where the exception is rised. This should be enough for understanding.

fogbit
  • 1,961
  • 6
  • 27
  • 41
1

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.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426