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)

问题解决

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值