OUTDATED - Error modes for OpenCV

I use OpenCV 1 to process some images and am confused by the cvSetErrMode function (which is part of CxCore).

OpenCV has three error modes.

  • List: the program terminates after calling the error handler.
  • Parent: the program is not completed, but an error handler is called.
  • No sound: similar to parent mode, but no error handler called

At the beginning of my code, I call cvSetErrMode (CV_ErrModeParent) to switch from the default "sheet" mode to "parent" so that my application does not exit with an exception / statement. Unfortunately, the "parent" mode does not seem to work. I still get a message box and my application is still ending.

If I call cvSetErrMode (CV_ErrModeSilent), it actually disconnects and no longer leaves the application or does not call a dialog ... but this also means that I do not know that an error has occurred. In this case, I think the mode is set correctly.

Does anyone else seem to have this behavior before and can recommend a solution?

Literature:

+3
source share
2 answers

I am going to answer my question, because after some messing around I found out what was going on.

"" , , cvGuiBoxReport(). cvGuiBoxReport() . , cvGuiBoxReport() ! .

, , .

:

int MyErrorHandler(int status, const char* func_name, const char* err_msg, const char* file_name, int line, void*)
{
    std::cerr << "Woohoo, my own custom error handler" << std::endl;
    return 0;
} 

:

cvSetErrMode(CV_ErrModeParent);
cvRedirectError(MyErrorHandler);
+5

, , OpenCV. V2.2 ++.

cv::imread() cv::imdecode(), ( ). OpenCV , , , .

https://code.ros.org/trac/opencv/browser/trunk/opencv/modules/core/include/opencv2/core/core.hpp cv::setBreakOnError() , :

cv::setBreakOnError(true); // Can be set globally
...
...
cv::Mat srcImage = cv::imread(filename, 1);
if (!srcImage.data) throw std::exception("bad image");

cv::imread() , , , .

.

+1

Source: https://habr.com/ru/post/1730973/


All Articles