OpenCV(4.2.0)(-206:错误标志(参数或结构字段))函数'cvGetMat'中无法识别或不支持的数组类型

问题描述 投票:0回答:1

我正在尝试在8000x4000图像和8000x4000二进制蒙版上进行修补,但是出现以下错误。

错误回溯(最近通话最后)1 img = cv.imread('input / 200130_033344133.jpg')2 mask = cv.imread('resources / maskX.png',0)----> 3 dst = cv.inpaint(img,mask,3,cv.INPAINT_TELEA)4 cv.imshow('dst',dst)5 cv.waitKey(0)

错误:OpenCV(4.2.0)C:\ projects \ opencv-python \ opencv \ modules \ core \ src \ array.cpp:2492:错误:(-206:错误标志(参数或结构字段))无法识别或函数'cvGetMat'中不受支持的数组类型]

这是我的代码。我试图将图像和蒙版转换为numpy数组或cv2.UMat。但都是徒劳的

img = cv.imread('input/200130_033344133.jpg')
mask = cv.imread('resources/maskX.png',0)
dst = cv.inpaint(img,mask,3,cv.INPAINT_TELEA)
cv.imshow('dst',dst)
cv.waitKey(0)
cv.destroyAllWindows()

任何原因使其不起作用?我已检查图像是否正确加载。

python opencv image-processing
1个回答
0
投票

我不知道出什么问题了,因为它对我来说在Python 3.7和Mac OSX上的OpenCV 3.4上正常工作。

您导入简历吗?制作灰度后,蒙版是否超过1个通道?也许与OpenCV 4有关?

这对我有用。

带有刮痕的图像:

enter image description here

便笺簿:

enter image description here

import cv2

img = cv2.imread('zelda1_scratch.jpg')
mask = cv2.imread('zelda1_scratch_mask.png',0)
dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA)
cv2.imwrite('zelda1_scratch_inpainted.jpg', dst)
cv2.imshow('dst',dst)
cv2.waitKey(0)
cv2.destroyAllWindows()

结果:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.