Ask Your Question

mcwu0628's profile - activity

2016-12-06 03:58:34 -0600 commented question are there memory leaks in Java detectMultiScale()?

Hey I have already knew how to avoid the memory leak. in my case, I call detectMultiScale() a lot times so that occurs failed to allocate memory

here is my code:

patternCascadeClassifier.detectMultiScale(grayImage, patternRects, 1.06, 1,
        Objdetect.CASCADE_SCALE_IMAGE|Objdetect.CASCADE_DO_CANNY_PRUNING,
        new Size(10, 10), new Size(50, 50));

// in my opinion, its necessary to reload cascade xml to release the related resources
patternCascadeClassifier.load(file.getAbsolutePath());
2016-12-06 01:55:53 -0600 received badge  Enthusiast
2016-12-04 21:06:01 -0600 asked a question are there memory leaks in Java detectMultiScale()?

I'm trying to write a android app with face detection and I found memory leaks exist after calling detectMultiScale() can anyone tell me how to fix this problem?

I have searched solution related to the issue like calling System.gc() after detectMultiScale(). but it didn't work.

2016-11-29 19:48:15 -0600 received badge  Editor (source)
2016-11-29 07:49:13 -0600 asked a question OOM occurs when calling detectMutiScale on android

the error message was OpenCV Error: Insufficient memory (Failed to allocate 118180608 bytes) in void* cv::OutOfMemoryError(size_t),

Caused by: CvException [org.opencv.core.CvException: cv::Exception: /builds/master_pack-android/opencv/modules/core/src/matrix.cpp:411: error: (-215) u != 0 in function void cv::Mat::create(int, const int*, int)] at org.opencv.objdetect.CascadeClassifier.detectMultiScale_0(Native Method)

at org.opencv.objdetect.CascadeClassifier.detectMultiScale(CascadeClassifier.java:150)

How I call detectMultiScale() and the related parameters.

patternCascadeClassifier.detectMultiScale(grayImage, patternRects, 1.09, 1, Objdetect.CASCADE_SCALE_IMAGE|Objdetect.CASCADE_FIND_BIGGEST_OBJECT|Objdetect.CASCADE_DO_CANNY_PRUNING, new Size(10,10), new Size(50, 50));


in my program flow, I gotta call detectMultiScale() for several times. and the exception always occurs on the 7th calling.

I have released the related image data but this error still occurs. Does anyone can tell me how to call detectMultiScale() correctly or did I miss some usages of detectMultiScale()?