opencv(cv2)处理图片时报错cv2.error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\m

参考:
https://stackoverflow.com/questions/7385465/resize-an-image-and-changing-its-depth
原因:
回答评论1
resize输入输出数值类型或插值类型缺失
because OpenCV resize is missing support for certain combinations of input and output depths (numeric types), and interpolation types
解决方案:
回答评论


转化类型
the image dtype was int64 (in Python). It worked as soon as I used uint8

我的情况是由于原本图片类型为int32 img.astype(‘uint8’)解决
 

img = cv2.imread("images/coffe.jpg")  # 读取图像
dst1 = cv2.resize(img, (500, 500))  # 按照宽500像素、高500像素的大小进行缩放
image=dst1.astype('uint8')
print(image,image.shape)

问题解决

opencv(cv2)处理图片时报错cv2.error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\m_第1张图片

 

你可能感兴趣的:(python,opencv,计算机视觉)