【问题标题】:Compute Dense SIFT features in OpenCV 3.0在 OpenCV 3.0 中计算密集 SIFT 特征
【发布时间】:2016-01-12 06:47:38
【问题描述】:

自 3.0 版起,DenseFeatureDetector 不再可用。谁能告诉我如何在 OpenCV 3.0 中计算 Dense SIFT 特征?我在文档中找不到它。

非常感谢您!

【问题讨论】:

  • 您的意思是像 DAISY 功能?它在 opencv 3.0 中,但在外部 contrib 包中。你必须自己编译它
  • @DawidPi:我已经安装了 opencv_contrib 并将 xfeature2d 包含到项目中,但仍然找不到像 DenseFeatureDetector 这样的东西。密集 SIFT 只是在不同尺度的网格上计算的 SIFT 特征。
  • DenseFeatureDetector detectImpl的实现是这样的。我想你可以自己做这件事,但我想我不能帮助你更多,因为我不是数学家也不是 CV 专家。 github.com/Itseez/opencv/blob/2.4/modules/features2d/src/…
  • 谢谢@DawidPi。我在 opencv_contrib 和 /features2d 中搜索了“Dense”,但看起来该功能已被删除。看来我必须按照你的建议自己实现它。
  • DenseFeatureDetector 在 OpenCV 3.0 中被移除 answers.opencv.org/question/61225/dense-features-in-opencv-3

标签: c++ opencv computer-science sift


【解决方案1】:

您可以将cv2.KeyPoints 的列表传递给sift.compute。这个例子是用 Python 编写的,但它显示了原理。我通过扫描图像的像素位置来创建cv2.KeyPoints 列表:

import skimage.data as skid
import cv2
import pylab as plt

img = skid.lena()
gray= cv2.cvtColor(img ,cv2.COLOR_BGR2GRAY)

sift = cv2.xfeatures2d.SIFT_create()

step_size = 5
kp = [cv2.KeyPoint(x, y, step_size) for y in range(0, gray.shape[0], step_size) 
                                    for x in range(0, gray.shape[1], step_size)]

img=cv2.drawKeypoints(gray,kp, img)

plt.figure(figsize=(20,10))
plt.imshow(img)
plt.show()

dense_feat = sift.compute(gray, kp)

【讨论】:

  • 您好,您知道在这种情况下如何应用对比度阈值吗?我试图在 SIFT_create() 中添加 contrastThreshold 参数,但它被忽略了。
  • 我不是 100% 确定,但看起来你必须自己实现它。答案足够复杂,可以将其作为一个单独的问题发布。不过这里好像是计算对比的github.com/opencv/opencv_contrib/blob/…
【解决方案2】:

这是我在 OpenCV 3 C++ 中使用密集 SIFT 的方法:

SiftDescriptorExtractor sift;

vector<KeyPoint> keypoints; // keypoint storage
Mat descriptors; // descriptor storage

// manual keypoint grid

int step = 10; // 10 pixels spacing between kp's

for (int y=step; y<img.rows-step; y+=step){
    for (int x=step; x<img.cols-step; x+=step){

        // x,y,radius
        keypoints.push_back(KeyPoint(float(x), float(y), float(step)));
    }
}

// compute descriptors

sift.compute(img, keypoints, descriptors);

复制自: http://answers.opencv.org/question/73165/compute-dense-sift-features-in-opencv-30/?answer=73178#post-id-73178

看起来效果不错

【讨论】:

  • 如果我想从多张图像中提取特征..​​.我应该先将所有图像调整为通用尺寸吗?
  • 非常感谢。 (抱歉耽搁了)
猜你喜欢
  • 2011-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-21
  • 2018-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多