Commit caa2c06e authored by Andrey Kamaev's avatar Andrey Kamaev

Quiet output of cv::error in Java tests

Introduced new Java API
void org.opencv.core.Core.setErrorVerbosity(boolean verbose)
used to suppress output to stderr from OpenCV's asserts
parent 5eabcf8e
...@@ -439,7 +439,7 @@ void error( const Exception& exc ) ...@@ -439,7 +439,7 @@ void error( const Exception& exc )
exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line ); exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line );
fprintf( stderr, "%s\n", buf ); fprintf( stderr, "%s\n", buf );
fflush( stderr ); fflush( stderr );
# ifdef ANDROID # ifdef __ANDROID__
__android_log_print(ANDROID_LOG_ERROR, "cv::error()", "%s", buf); __android_log_print(ANDROID_LOG_ERROR, "cv::error()", "%s", buf);
# endif # endif
} }
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#include "converters.h" #include "converters.h"
#include "core_manual.hpp"
#include "features2d_manual.hpp"
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(disable:4800 4244) # pragma warning(disable:4800 4244)
#endif #endif
......
#define LOG_TAG "org.opencv.core.Core"
#include "common.h"
static int quietCallback( int, const char*, const char*, const char*, int, void* )
{
return 0;
}
void cv::setErrorVerbosity(bool verbose)
{
if(verbose)
cv::redirectError(0);
else
cv::redirectError((cv::ErrorCallback)quietCallback);
}
\ No newline at end of file
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
namespace cv
{
CV_EXPORTS_W void setErrorVerbosity(bool verbose);
}
#if 0 #if 0
namespace cv namespace cv
......
...@@ -106,6 +106,8 @@ public class OpenCVTestCase extends TestCase { ...@@ -106,6 +106,8 @@ public class OpenCVTestCase extends TestCase {
System.exit(-1); System.exit(-1);
} }
Core.setErrorVerbosity(false);
String pwd; String pwd;
try { try {
pwd = new File(".").getCanonicalPath() + File.separator; pwd = new File(".").getCanonicalPath() + File.separator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment