【问题标题】:Compute descriptor with Sift compute python使用 Sift 计算 python 计算描述符
【发布时间】:2021-02-19 17:06:00
【问题描述】:

我正在尝试计算给定一组 Keypoint 的描述符,我用cv2.KeyPoint 计算了这些描述符! 但是当我尝试像这样调用 sift.compute() 时,只是想看看它是否有效:

sift= cv2.SIFT()
sift.compute(img, Keypoint)

我收到以下我无法理解的错误: <method 'compute' of 'cv2.Feature2D' objects> returned NULL without setting an error

我正在使用 Opencv 4.4

【问题讨论】:

标签: python opencv sift


【解决方案1】:

如果你看documentation

您应该将SIFT 声明为:

sift = cv.SIFT_create()

因此正确的代码是:

sift = cv.SIFT_create()
kp, des = sift.detectAndCompute(gray,None)

更新

如果您已经计算了关键点 (kp),则将其绘制在当前图像上:

img=cv.drawKeypoints(gray,kp,img)
cv.imwrite('sift_keypoints.jpg',img)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    • 2017-01-08
    • 2016-03-16
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 2016-08-28
    相关资源
    最近更新 更多