I am new to opencv and python. I tried with a sample code to extract the features of an image and I am getting this error:
TypeError: drawKeypoints() missing required argument 'outImage' (pos 3)
and my code goes like this
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)
Want to see the extracted features of an image.
Any suggestions on how to extract the features of an image to compare with webcam image will be helpful.
Thanks.
It seems to be a bug in drawKeypoints() function. Its possible to assign outImage = None to solve it as:
img2 = cv2.drawKeypoints(img, kp, outImage = None, color=(255,0,0))
or create img2 and modify it inplace as:
img2 = cv2.merge([img, img, img])
cv2.drawKeypoints(img, kp, outImage = img2, color = (255, 0, 0),
flags = cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG)
I had the same problem and found that the problem was already solved here:
OpenCV can't draw keypoints
I tried the suggestion from the previous solution, this code works:
cv2.drawKeypoints(img, kp, outImage=img2, color=(255,0,0))
For your reference, if you look at the output from help for this procedure
help(cv2.drawKeypoints)
drawKeypoints(...)
drawKeypoints(image, keypoints, outImage[, color[, flags]]) -> outImage
you will see that the output image (outImage) that is returned is contained in the parameters of the function call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With