gpt4 book ai didi

opencv - 缺少必需的参数 'outImage'(位置 3)

转载 作者:行者123 更新时间:2023-12-02 16:07:21 24 4
gpt4 key购买 nike

我是 opencv 和 python 的新手。我尝试使用示例代码来提取图像的特征,但出现此错误:

TypeError: drawKeypoints() missing required argument 'outImage' (pos 3)

我的代码是这样的

import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('1.png',0)

fast = cv2.FastFeatureDetector_create()

kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, kp, color=(255,0,0))

print ("Threshold: ", fast.getInt('threshold'))
print ("nonmaxSuppression: ", fast.getBool('nonmaxSuppression'))
print ("neighborhood: ", fast.getInt('type'))
print ("Total Keypoints with nonmaxSuppression: ", len(kp))
cv2.imwrite('fast_true.png',img2)

fast.setBool('nonmaxSuppression',0)
kp = fast.detect(img,None)
print ("Total Keypoints without nonmaxSuppression: ", len(kp))
img3 = cv2.drawKeypoints(img, kp, color=(255,0,0))
cv2.imwrite('fast_false.png',img3)

想要查看图像的提取特征。

关于如何提取图像特征以与网络摄像头图像进行比较的任何建议都会有所帮助。

谢谢。

最佳答案

这似乎是 drawKeypoints() 函数中的错误。可以分配 outImage = None 来解决它:

img2 = cv2.drawKeypoints(img, kp, outImage = None, color=(255,0,0))

或创建 img2 并将其修改为:

img2 = cv2.merge([img, img, img])
cv2.drawKeypoints(img, kp, outImage = img2, color = (255, 0, 0),
flags = cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG)

关于opencv - 缺少必需的参数 'outImage'(位置 3),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57169489/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com