【问题标题】:Python/OpenCV how to deal with large number of SIFT feaure in .yml file?Python/OpenCV 如何处理 .yml 文件中的大量 SIFT 特征?
【发布时间】:2018-06-27 22:41:13
【问题描述】:

我正在使用 OpenCv,我使用 yaml 来存储 SIFT 关键点和描述符。 我有一个包含 1659 张图片的数据库(.jpg,每张图片大约 95 KB)。对于每个图像,我创建了一个带有关键点和描述符的 .yml 文件。现在,对于单个图像,我最终得到了 700 个关键点和描述符,从而生成了一个 ca. 4MB,我想避免使用二进制文件。
我的问题是:

  • 如何知道特征数量是否足以满足图像的需求?
  • 有什么方法可以控制特征的数量?例如,为 SIFT 设置阈值?
  • 现在使用 cv2.FileStorage.write 将 numpy 矩阵存储到 yamil 文件中,OpenCv 用 16 位有效数字写入每个数字(例如 1.9705572128295898e+00)。如果我减少有效数字会有问题吗?例如到 4?

【问题讨论】:

    标签: python numpy opencv yaml sift


    【解决方案1】:
    1. 我如何知道特征数量是否足以满足图像的需求?

    这必须取决于你的形象,你的任务要求。你应该比别人更了解,或者做实验来弄清楚。

    1. 有什么方法可以控制特征的数量?

    当然。创建时,只需传递必要的参数即可。

    cv2.xfeatures2d.SIFT_create([, nfeatures[, nOctaveLayers[, contrastThreshold[, edgeThreshold[, sigma]]]]]) -> retval
     | . @param nfeatures The number of best features to retain. The features are ranked by their scores
     | . (measured in SIFT algorithm as the local contrast)
     | .
     | . @param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. 
     | . The number of octaves is computed automatically from the image resolution.
     | .
     | . @param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform
     | . (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
     | .
     | . @param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning
     | . is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
     | . filtered out (more features are retained).
     | .
     | . @param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
     | . is captured with a weak camera with soft lenses, you might want to reduce the number.
     |
    

    例如,我创建了一个具有 50 个关键点和 3 层的筛选检测器:

    sift = cv2.xfeatures2d.SIFT_create(nfeatures = 50, nOctaveLayers=3)
    

    这是检测结果:

    1. 太长了。我知道您在 OpenCV-Python 中将大量关键点和描述符存储为 .yml 格式。

    好的,当您需要存储大量数据时,.yml 真的有帮助吗?真的合理吗?你真的需要keypoint (points2f, size, response, octave, class_id) 的每一个元素吗?至于描述符,它是一个直方图,或者一个 int 数组。所以即使你把它保存为int,这个值也是可以的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-08
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 2015-07-02
      • 2023-03-21
      • 2018-03-10
      • 2016-01-12
      相关资源
      最近更新 更多