C++ – how to find out what is causing “cv::Exception at memory location”

cvisual c++visual studio 2010

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()

Best Answer

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:

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