How to find out what causes "cv :: Exception at memory location"?

I am currently suffering from some strange exceptions, which are most likely due to the fact that I am doing something wrong when interacting with opencv:

First-chance exception at 0x7580b9bc in xxx.exe: Microsoft C++ exception: cv::Exception at memory location 0x00c1c624..

I have already enabled the Thrown field in the Debug -> Exceptions menu, however I really can't figure out where the exception is being thrown in my code.

How can I debug this?

EDIT the stack frame is read as follows (my application will not even appear in the list!):

  • KernelBase.dll! 7580b8bc ()
  • [Frames below may be incorrect or missing]
  • KernelBase.dll! 7580b8bc ()
  • opencv_core242d.dll! 54eb60cc ()
+8
c ++ visual-c ++ visual-studio-2010
source share
3 answers

You can wrap your entire main object in a catch try block that prints the details of the exception. If the open CV API can throw exceptions, you'll have to consider handling them anyway as part of your design:

 try { // ... Contents of your main } catch ( cv::Exception & e ) { cerr << e.msg << endl; // output exception message } 
+10
source share

I am having a problem using OpenCV with WebCam. The problem in my case is that the program is trying to read the image when the Cam was not initialized.

my error code is:

  // open camera capture.open(0); while (1){ //store image to matrix // here is the bug capture.read(cameraFeed); 

Decision

  // open camera capture.open(0); while (1){ //this line makes the program wait for an image while (!capture.read(cameraFeed)); //store image to matrix capture.read(cameraFeed); 

(sorry for my english) Thanks

+2
source share

OpenCV has this handy feature called cv :: setBreakOnError

If you put the following on your list before any opencv calls:

 cv::setBreakOnError(true); 

then your program will fail because OpenCV will perform an invalid operation (dereferencing the null pointer) just before cv :: Exception is thrown. If you run your code in the debugger, it will stop in this illegal operation, and you will be able to see the entire call stack with all your codes and variables during an error.

+1
source share

All Articles