Python 成功解决cv2.error:error: (-215:Assertion failed) !outImage.empty() in function ‘drawKeypoints‘

File "play.py", line 36, in main
    img_kpts3=cv2.drawKeypoints(img,src_kpts,img_kpts3, (255,0,0), cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG)
cv2.error: OpenCV(4.2.0) /io/opencv/modules/features2d/src/draw.cpp:115: error: (-215:Assertion failed) !outImage.empty() in function 'drawKeypoints'

DRAW_OVER_OUTIMG函数不创建输出的图像,而是直接在输出图像变量空间绘制,要求本身输出图像变量就是一个初始化好了的,size与type都是已经初始化好的变量

img_kpts3=cv2.drawKeypoints(img,src_kpts,img_kpts3, (255,0,0), cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG)

源代码第二个参数更改为原始图像即可

img_kpts3=cv2.drawKeypoints(img,src_kpts,img, (255,0,0), cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG)

猜你喜欢

转载自blog.csdn.net/weixin_44991673/article/details/111635266
今日推荐