我是opencv
和python的新手。我尝试使用示例代码来提取图像的特征,但出现此错误:
TypeError:drawKeypoints()缺少必需的参数“ outImage”(位置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)
想要查看图像的提取特征。
有关如何提取图像特征以与网络摄像头图像进行比较的任何建议都会有所帮助。
谢谢。
答案 0 :(得分:0)
这似乎是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)