diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index cb2f51d9a2..4088602b40 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -1990,7 +1990,8 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize, bool isFound = false; #define BE_QUIET 1 #if BE_QUIET - redirectError(quiet_error); + void* oldCbkData; + ErrorCallback oldCbk = redirectError(quiet_error, 0, &oldCbkData); #endif try { @@ -2001,7 +2002,7 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize, } #if BE_QUIET - redirectError(0); + redirectError(oldCbk, oldCbkData); #endif if (isFound) { diff --git a/modules/ts/src/ts.cpp b/modules/ts/src/ts.cpp index 77ede878cb..f9e784ecf3 100644 --- a/modules/ts/src/ts.cpp +++ b/modules/ts/src/ts.cpp @@ -316,9 +316,11 @@ int BaseTest::update_progress( int progress, int test_case_idx, int count, doubl BadArgTest::BadArgTest() { - progress = -1; - test_case_idx = -1; - freq = cv::getTickFrequency(); + progress = -1; + test_case_idx = -1; + freq = cv::getTickFrequency(); + // oldErrorCbk = 0; + // oldErrorCbkData = 0; } BadArgTest::~BadArgTest(void) @@ -378,7 +380,6 @@ int BadArgTest::run_test_case( int expected_code, const string& _descr ) return errcount; } - /*****************************************************************************************\ * Base Class for Test System * \*****************************************************************************************/ @@ -438,6 +439,12 @@ string TS::str_from_code( int code ) return "Generic/Unknown"; } +static int tsErrorCallback( int status, const char* func_name, const char* err_msg, const char* file_name, int line, TS* ts ) +{ + ts->printf(TS::LOG, "OpenCV Error: %s (%s) in %s, file %s, line %d\n", cvErrorStr(status), err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line); + return 0; +} + /************************************** Running tests **********************************/ void TS::init( const string& modulename ) @@ -453,10 +460,10 @@ void TS::init( const string& modulename ) data_path = string(buf); } + cv::redirectError((cv::ErrorCallback)tsErrorCallback, this); + if( ::testing::GTEST_FLAG(catch_exceptions) ) { - cvSetErrMode( CV_ErrModeParent ); - cvRedirectError( cvStdErrReport ); #if defined WIN32 || defined _WIN32 #ifdef _MSC_VER _set_se_translator( SEHTranslator ); @@ -468,8 +475,6 @@ void TS::init( const string& modulename ) } else { - cvSetErrMode( CV_ErrModeLeaf ); - cvRedirectError( cvGuiBoxReport ); #if defined WIN32 || defined _WIN32 #ifdef _MSC_VER _set_se_translator( 0 );