【问题标题】:What does `DescriptorMatcher` do when object is not in the scene in OpenCV?当对象不在 OpenCV 的场景中时,DescriptorMatcher 会做什么?
【发布时间】: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


    【解决方案1】:

    descriptorMatcher 将始终找到(或尝试找到)最佳匹配项(= 距离较小的匹配项),它无法告诉您匹配项是否真的正确。有一些方法可以猜测哪些匹配是正确的,哪些匹配是错误的。

    1. 查看比赛的距离。如果距离值太大,则匹配可能不正确(即使这是所有关键点中的最小距离)。

    2. 不仅要计算最佳匹配,还要尝试计算第二个最佳匹配。如果第二佳和最佳匹配几乎具有相同的质量(= 相同的距离),您可能会认为您无法确定其中一个是好的匹配。

    3. 使用 RANSAC 计算稳健的单应性。如果匹配中出现足够多的内点,则这些匹配可能非常可靠。

    4. 与 4 相同,但使用基本矩阵而不是单应矩阵

    没有检查,但也许看看这个:https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/RobustMatcher.h

    http://docs.opencv.org/3.1.0/dc/d2c/tutorial_real_time_pose.html

    【讨论】:

      猜你喜欢
      • 2017-10-13
      • 1970-01-01
      • 2018-09-08
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多