【发布时间】:2017-05-23 06:18:30
【问题描述】:
我正在尝试通过将视频中的当前帧与预先存储的特征描述符进行比较来检测已知对象。我的想法是将当前帧的特征与预先存储的特征进行匹配,并在良好特征的数量高于某个阈值时报告阳性检测。
然而,这似乎不起作用,因为DescriptorMatcher 将始终报告某个固定数量的匹配,无论对象是否实际在场景中。尽管我使用了一种非常传统的过滤方法来保留前 x 个好的匹配,但它仍然是一个相对于当前帧的度量。
有没有像 DescriptorMatcher 的匹配度这样的东西我可以用作硬阈值?有更好的方法吗?我以前使用过 Bag of Words,但对于手头的问题来说似乎有点矫枉过正,而且对于我的需求来说,它的计算量也有点过于详尽。任何建议/提示/指针将不胜感激。
ImageDescriptor imageDescriptor = null;
imageDescriptor = ImageDescriptor.fromJson(jsonMetadata);
Mat storedDescriptors = imageDescriptor.getFeatureDescriptors(); // prestored features
FeatureDetector featureDetector = FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
DescriptorMatcher descriptorMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
MatOfKeyPoint keyPoints = new MatOfKeyPoint();
featureDetector.detect(rgba, keyPoints); // rgba is the image from current video frame
MatOfDMatch matches = new MatOfDMatch();
Mat currDescriptors = new Mat();
descriptorExtractor.compute(rgba, keyPoints, currDescriptors);
descriptorMatcher.match(descriptors_scene, storedDescriptors, matches);
MatOfDMatch good_matches = filterMatches(matches); // filterMatches return the matches that have a distance measure of < 2.5*min_distance
if(good_matches.rows()>threshold)
return true;
return false;
【问题讨论】:
标签: java android opencv feature-detection opencv4android