I'm using Opencv sdk for Android to develop a real time processing and matching.
The main Opencv traitment logic is in a JNI
function.
The problem is that sometimes (just sometimes) my app crashes without error, so I ignored the problem until I'm done developing the algorithm.
I started investigating the error and it's definetly in the JNI part.
Here is the error I get in the Log
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 27424 (Thread-8)
A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
I searched a lot in the internet and I found this solution
<activity
android:hardwareAccelerated="false" />
It worked for 2 days and now I'm getting the same error back.
What's the problem and how can I solve it?
Any help would be appreciated and thank you in advance.
EDIT
I should add that my application take a reference image from gallery and compare it using Opencv with a real time image feed.
If I choose an image from gallery and the app crashes, that image won't work again and if I take a new image or an image that worked before, the app works fine.
After some discussion it became clear that the problem was with interaction with memory:
extern "C"
jdouble
JNICALL Java_com_foo(JNIEnv *env, jclass type, jlong addrRgba, jlong addrGray) {
Mat &mRgb = *(Mat *) addrRgba;
Mat &mGray = *(Mat *) addrGray;
return (jdouble) toGray(mRgb, mGray);
}
As a quick fix double toGray(Mat& rgb, Mat& gray);
had to be changed to double toGray(Mat rgb, Mat gray)
Additional information can be found on topic CvMat deep copy