SIGSEGV on Android with first use of OpenCV after restarting an Activity

asked 2016-06-24 06:51:05 -0500

przemulala gravatar image

I've run into weird problem. To keep things short: I've written an Android app that utilizes OpenCV with two Activities:

Activity1 previews front camera and on user click starts Activity2, sending current frame's address by Intent

Activity2 assigns to it's local field of type Mat clone of the frame under the given address and allows the user simple manipulations on it (namely to perform inRange method in HSV colorspace). Mat is converted to Bitmap an displayed in ImageView: this happens on Activity2 start (for original captured frame) and after each user manipulation of SeekBar.

Activity1 is a parent of Activity2, therefore clicking back button restarts Activity1. And now comes the weird part(s):

1) after some time (less than 1 minute) Activity1 crashes, with

libc: Fatal signal 11 (SIGSEGV)

as you can imagine, it does not happen when Activity2 is never started

2) if I restart Activity2 by simply returning to Activity1 and clicking again, OnCreate() and other methods from regular lifecycle are being called and the app crashes with the same fatal signal error in line when convertion from Mat to Bitmap is performed:

Utils.matToBitmap(mCapturedFrame, bm);

So, it's the first time OpenCV's function is being called after restarting an Activity. The best part is, mCapturedFrame exsists and the aformentioned method is called after sucesfully loading the OpenCV library. What's more, I release() locally created Mats, as well as field that contains captured frame Mat (when I return from Activity2). The error looks like memory leak in case of Activity1, but where?!

The last thing is, when the app crashes, I can see in Android Monitor:

OpenCV error: Cannot load info library for OpenCV

But how the heck is this even possible, if library is being loaded sucessfully? I really can't see what I'm doing wrong here and will be glad for any suggestions. Feel free to download my java code files from here:

edit retag flag offensive close merge delete