Opencv 3.0 java fatal error
Hi, I use openCv 3.0 from java. I am getting error when call detectMultiscale method.
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f42e9d096ba, pid=21964, tid=139918287292160
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libopencv_java300.so+0x8f56ba] cv::FeatureEvaluator::setImage(cv::_InputArray const&, std::vector<float, std::allocator<float> > const&)+0x40a
#
Stack: [0x00007f4143bfc000,0x00007f4143cfd000], sp=0x00007f4143cfa8a0, free space=1018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libopencv_java300.so+0x8f56ba] cv::FeatureEvaluator::setImage(cv::_InputArray const&, std::vector<float, std::allocator<float> > const&)+0x40a
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 2939 org.opencv.objdetect.CascadeClassifier.detectMultiScale_1(JJJ)V (0 bytes) @ 0x00007f43851cd407 [0x00007f43851cd3c0+0x47]
this code crashes jvm in 5 seconds
for (int i = 0; i < 500; ++i) {
Thread t = new Thread(new Runnable() {
public void run() {
CascadeClassifier faceDetector = new CascadeClassifier(CLASSIFIER_FACE);
MatOfRect faceDetections = new MatOfRect();
Mat uncroppedImage = Imgcodecs.imread(tmpFile.getAbsolutePath());
faceDetector.detectMultiScale(uncroppedImage,
faceDetections);
}
});
t.start();
}
Please add some code. Otherwise:
you're re-loading the classifier and the image 500 times ? i guess, you're just running out of memory this way.
try to release() anything at the end of your run() function. java's gc does not know about any memory allocated internally from native c++ functions