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
This commit is contained in:
parent
5eabcf8e4f
commit
caa2c06e50
@ -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 @@
|
|||||||
|
|
||||||
#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
|
||||||
|
15
modules/java/generator/src/cpp/core_manual.cpp
Normal file
15
modules/java/generator/src/cpp/core_manual.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#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);
|
||||||
|
}
|
@ -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
|
||||||
|
@ -96,31 +96,33 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.loadLibrary("opencv_java");
|
System.loadLibrary("opencv_java");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
System.out.println(e.toString());
|
System.out.println(e.toString());
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
System.out.println(e.toString());
|
System.out.println(e.toString());
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String pwd;
|
Core.setErrorVerbosity(false);
|
||||||
try {
|
|
||||||
pwd = new File(".").getCanonicalPath() + File.separator;
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenCVTestRunner.LENA_PATH = pwd + "res/drawable/lena.jpg";
|
String pwd;
|
||||||
OpenCVTestRunner.CHESS_PATH = pwd + "res/drawable/chessboard.jpg";
|
try {
|
||||||
OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH = pwd + "res/raw/lbpcascade_frontalface.xml";
|
pwd = new File(".").getCanonicalPath() + File.separator;
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert(new File(OpenCVTestRunner.LENA_PATH).exists());
|
OpenCVTestRunner.LENA_PATH = pwd + "res/drawable/lena.jpg";
|
||||||
assert(new File(OpenCVTestRunner.CHESS_PATH).exists());
|
OpenCVTestRunner.CHESS_PATH = pwd + "res/drawable/chessboard.jpg";
|
||||||
assert(new File(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH).exists());
|
OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH = pwd + "res/raw/lbpcascade_frontalface.xml";
|
||||||
|
|
||||||
|
assert(new File(OpenCVTestRunner.LENA_PATH).exists());
|
||||||
|
assert(new File(OpenCVTestRunner.CHESS_PATH).exists());
|
||||||
|
assert(new File(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH).exists());
|
||||||
|
|
||||||
dst = new Mat();
|
dst = new Mat();
|
||||||
assertTrue(dst.empty());
|
assertTrue(dst.empty());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user