I'm currently suffering from some strange exceptions that are most probably due to me doing something incorrectly while interacting with opencv:
First-chance exception at 0x7580b9bc in xxx.exe: Microsoft C++ exception: cv::Exception at memory location 0x00c1c624..
I've already enabled the Thrown
field in the Debug -> Exceptions
menu, however I really can't figure out where in my code the exception is thrown.
How can I debug this?
EDIT the stack frame reads like this (my app won't even show up in the list!):
- KernelBase.dll!7580b8bc()
- [Frames below may be incorrect or missing ]
- KernelBase.dll!7580b8bc()
- opencv_core242d.dll!54eb60cc()
You could wrap your entire main in a try catch block which prints out the exception details. If the open CV API can throw exceptions, you will need to think about handling them anyway as part of your design:
OpenCV has this handy function called cv::setBreakOnError
If you put the following into your main before any opencv calls:
then your program will crash, because OpenCV will do an invalid operation (dereferencing a null pointer) just before it would throw cv::Exception normally. If you run your code in a debugger, it will stop at this illegal operation, and you can see the whole call stack with all of your codes and variables at the time of the error.
I´ve got this problem by using OpenCV with WebCam. The problem in my case is that the program is trying to read an image when the Cam hasn't been initialized.
my error code:
The solution
(sorry about my english) Thanks