Error handling ============== .. highlight:: cpp The modern error handling mechanism in OpenCV uses exceptions, as opposite to the manual stack unrolling used in previous versions. If you to check some conditions in your code and raise an error if they are not satisfied, use () or (). :: CV_Assert(mymat.type() == CV_32FC1); ... if( scaleValue < 0 || scaleValue > 1000 ) CV_Error(CV_StsOutOfRange, "The scale value is out of range"); .. There is also that yields no code in the Release configuration. To handle the errors, use the standard exception handling mechanism: :: try { ... } catch( cv::Exception& e ) { const char* err_msg = e.what(); ... } .. instead of you can write ``std::exception`` , since the former is derived from the latter. Then, obviously, to make it all work and do not worry about the object destruction, try not to use ``IplImage*`` , ``CvMat*`` and plain pointers in general. Use , ``std::vector<>`` , etc.