mexopencv  3.4.1
MEX interface for OpenCV library
redirectError.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace cv;
10 
11 //NOTE: MATLAB has some sort of try/catch to handle any C++ exceptions thrown
12 // in MEX-files, Octave on the other hand can sometimes crash if an exception
13 // is unhandled!
14 // So this function helps in that case (plus the pretty-printed errors).
15 
23 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
24 {
25  // Check the number of arguments
26  nargchk(nrhs==0 && nlhs==0);
27 
28  // Set a cutom error handler to be called by cv::error() and cousins,
29  // this replaces the default behavior which prints error info on stderr.
30  // Note that OpenCV will still throw a C++ exception after running the
31  // handler, but since we terminate with mexErrMsgIdAndTxt it wont matter.
33 }
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
int MexErrorHandler(int status, const char *func_name, const char *err_msg, const char *file_name, int line, void *userdata)
Cutom error callback to be invoked by cv::error(), CV_Assert, etc.
Definition: MxArray.cpp:86
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
ErrorCallback redirectError(ErrorCallback errCallback, void *userdata=0, void **prevUserdata=0)
Global constant definitions.