1 | initial version |
cv::Ptr is a smart pointer with reference counting. In JNI code it calls object destruction after on exit from function body. That's why you get invalid object and strange segfault. You need to reorganize JNI part in way like this:
JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_LBPFaceRecognizer_nativeCreateObject
(JNIEnv * jenv, jclass)
{
FaceRecognizer* model = createLBPHFaceRecognizer();
return (jlong)model;
}
Also you need to implement some release() method for native object destruction.