Hey guys, I'm using OpenCV4Android v.2.4.9 on Nexus 5 with android 4.4.4 stock rom.
I use this piece of code for running haar cascade face detection:
public Rect getFaceFromCascade(){
// cascade! woohoo
if (mFrontCascade != null) {
int height = mWorkingFrame.rows();
int faceSize = Math.round(height * mMinFaceSize);
mFrontCascade.detectMultiScale(mWorkingFrame, mFaceList,
1.1, 2, 2 , new Size(faceSize, faceSize), new Size());
}
Rect[] facesArray = mFaceList.toArray();
if (facesArray.length == 0){
//cascade couldn't find any face
return null;
}
return facesArray[0];
}
mFaceList is a MatOfRect i'm creating once when the class is initialized.
When the class dies, I don't do anything with mFaceList (although i've also tried releasing it and that didn't help), and leave it to the garbage collector, but when the GC comes along later on, i get a SIGSEGV. After deep investigation i found the the problem is when release is called in the MatOfRect (Mat) finalizer.
When my class dies the mFaceList has the following header:
Mat [ 1*1*CV_32SC4, isCont=true, isSubmat=false, nativeObj=0x713cdad8, dataAddr=0x751badf0 ]
and in the finalize method of mFaceList it has the following header:
Mat [ 1964813884*1*CV_32SC(455), isCont=false, isSubmat=true, nativeObj=0x751ad8bc, dataAddr=0x751cae60 ]
That's when the SIGSEGV is occurring. any idea what can mess with the header like that? or why is this happening? I don't have any other references of this MatOfRect anywhere in the code.
Any help would be appreciated. Vlad