Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Closed
Labels
Milestone
Description
System information (version)
- OpenCV => 3.4.1-dev (master)
- Operating System / Platform => Windows 64 Bit
- Compiler => ming64
Detailed description
bothFlannBasedMatcher andBFMatcher have a public constructor and a create() method, the 1st constructs a new FlannBasedMatcher , the 2nd anew Ptr<Ptr<FlannbasedMatcher>>.
since the internal wrapper code expects the latter, using an instance created from a constructor will segfault
when being deferenced like this:
Ptr<cv::DescriptorMatcher>* me = (Ptr<cv::DescriptorMatcher>*) self;a similar problem occurs in theBOWKMeansTrainer class, which can only be invoked from a constructor, but the internal code uses dereferencedPtr
java example code:
FlannbasedMatcher matcher = new FlannbasedMatcher();matcher.match(descriptor1, descriptor2, matches); // segfaultsBOWKMeansTrainer trainer = new BOWKMeansTrainer(100);Mat vocab = trainer.cluster(descriptors); // segfaultsgenerated jni code:
JNIEXPORT jlong JNICALL Java_org_opencv_features2d_FlannBasedMatcher_FlannBasedMatcher_10 (JNIEnv* env, jclass ){ static const char method_name[] = "features2d::FlannBasedMatcher_10()"; try { LOGD("%s", method_name); cv::FlannBasedMatcher* _retval_ = new cv::FlannBasedMatcher( makePtr<flann::KDTreeIndexParams>(), makePtr<flann::SearchParams>() ); return (jlong) _retval_; } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { throwJavaException(env, 0, method_name); } return 0;}JNIEXPORT void JNICALL Java_org_opencv_features2d_DescriptorMatcher_knnMatch_11 (JNIEnv* env, jclass , jlong self, jlong queryDescriptors_nativeObj, jlong trainDescriptors_nativeObj, jlong matches_mat_nativeObj, jint k){ static const char method_name[] = "features2d::knnMatch_11()"; try { LOGD("%s", method_name); std::vector< std::vector<DMatch> > matches; Mat& matches_mat = *((Mat*)matches_mat_nativeObj); Ptr<cv::DescriptorMatcher>* me = (Ptr<cv::DescriptorMatcher>*) self; //TODO: check for NULL Mat& queryDescriptors = *((Mat*)queryDescriptors_nativeObj); Mat& trainDescriptors = *((Mat*)trainDescriptors_nativeObj); (*me)->knnMatch( queryDescriptors, trainDescriptors, matches, (int)k ); vector_vector_DMatch_to_Mat( matches, matches_mat ); return; } catch(const std::exception &e) { throwJavaException(env, &e, method_name); } catch (...) { throwJavaException(env, 0, method_name); } return;}