Ask Your Question
0

Opencv 3.0 java fatal error

asked 2015-10-07 08:46:26 -0600

Retr gravatar image

updated 2015-10-08 08:24:46 -0600

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();

    }
edit retag flag offensive close merge delete

Comments

Please add some code. Otherwise:

  • The Java code works without the call detectMultiScale ?
  • The classifier has correctly loaded the classifier data ?
Eduardo gravatar imageEduardo ( 2015-10-07 09:45:05 -0600 )edit

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

berak gravatar imageberak ( 2015-10-08 08:37:13 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-10-21 06:11:45 -0600

attila gravatar image

I've also had this error a couple of times. I suspect it arises when the classifier is recreated at every iteration. Try placing CascadeClassifier faceDetector = new CascadeClassifier(CLASSIFIER_FACE); outside the for-loop and see if this solves the issue.

Let me know if it helped!

edit flag offensive delete link more
0

answered 2015-10-08 12:54:56 -0600

Steven P. Goldsmith gravatar image

I've seen this with building from master branch, Try source another day or try 3.0.0 release tag. Also, try another method signature and see if the same thing happens.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-07 08:46:26 -0600

Seen: 572 times

Last updated: Oct 08 '15