TypeError: Required argument 'outImage' (pos 3) not found opencv

在使用Python OpenCV对图像进行SIFT特征提取过程中,按照https://docs.opencv.org/3.3.0/da/df5/tutorial_py_sift_intro.html给出的示例程序,会出现下面错误:

TypeError: Required argument 'outImage' (pos 3) not found opencv_第1张图片

即:TypeError: Required argument 'outImage' (pos 3) not found opencv(缺失了第3个参数)


根据这里的启发(在进行特征匹配时,也会遇到与上述错误类似的错误,下面的答案可以完美解决):

https://stackoverflow.com/questions/31631352/typeerror-required-argument-outimg-pos-6-not-found

查看出错的函数的文档:


少了输出图像,而在CV的官方文档中,输出的图像是以赋值的形式给出的,即:

import cv2
import numpy as np
img = cv2.imread('home.jpg')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(gray,None)
img=cv2.drawKeypoints(gray,kp,img)
cv2.imwrite('sift_keypoints.jpg',img)
而函数的文档介绍是,输出的图像是以参数的形式给出的,即:

import cv2
import numpy as np

img = cv2.imread('left01.jpg')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 

sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(gray,None)
 
cv2.drawKeypoints(gray,kp,img)

cv2.imwrite('sift_keypoints.jpg',img)

你可能感兴趣的:(图像处理,Python3,Opencv3)