Ask Your Question
0

Android - Opencv - error: (-215) u != 0 in function void cv::Mat::create

asked 2016-04-13 04:26:58 -0600

2D3D gravatar image

My app keeps crashing with this error

FATAL EXCEPTION: Thread-22883
                                                             Process: com.aar.Cline, PID: 7270
                                                             CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/matrix.cpp:424: error: (-215) u != 0 in function void cv::Mat::create(int, const int*, int)
                                                             ]
                                                                 at org.opencv.imgproc.Imgproc.cvtColor_1(Native Method)
                                                                 at org.opencv.imgproc.Imgproc.cvtColor(Imgproc.java:1724)
                                                                 at com.aar.Cline.TrackBallActivity.detectBall(TrackBallActivity.java:592)
                                                                 at com.aar.Cline.TrackBallActivity.onCameraFrame(TrackBallActivity.java:190)
                                                                 at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391)
                                                                 at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350)
                                                                 at java.lang.Thread.run(Thread.java:818)

The app is running fine for about 3 min when suddenly in the middle this error shows up here is the line on which it keeps crashing

Mat grayImage1 = new Mat();
Imgproc.cvtColor(frame1, grayImage1, Imgproc.COLOR_BGR2GRAY);

Any suggestions?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-04-14 04:06:05 -0600

berak gravatar image

you're leaking memory, in the end it can't allocate another Mat.

if you use temporary Mat's created with new, you have to release() them manually, java's gc does not see natively, c++ allocated memory (for the pixels)

Mat grayImage1 = new Mat();
Imgproc.cvtColor(frame1, grayImage1, Imgproc.COLOR_BGR2GRAY);
// ... process grayImage1 
// ... later:
grayImage1.release()
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-13 04:26:58 -0600

Seen: 6,632 times

Last updated: Apr 14 '16