error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘cv::imshow‘(已解决)

错误的原因是cv.imshow这个函数

搜这个问题的时候发现很多博客在胡扯,这个函数的第一个参数根本不是什么地址

cv2.imshow('显示窗口名称',图像数组)
def imshow(winname, mat): # real signature unknown; restored from __doc__
"""
    .   -   If the image is 8-bit unsigned, it is displayed as is.
    .   -   If the image is 16-bit unsigned, the pixels are divided by 256. That is, the
    .       value range [0,255\*256] is mapped to [0,255].
    .   -   If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the
    .       value range [0,1] is mapped to [0,255].
    .   -   32-bit integer images are not processed anymore due to ambiguouty of required transform.
"""

解决方案:

其中图像数组是numpy类型,如果是RGB三通道类型的,数组大小为:图像长*图像宽*3

 若出现报错,先检查是不是图像数组有问题,改成规定格式就能成功解决

注:

cv.show()函数测试

import cv2
img=cv2.imread('2007_000876.jpg')
cv2.imshow("img", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

参考资料:

下面这个错误原因是,变量名不能重复使用

python - error: (-215:Assertion failed) bmi && width >= 0 && height >= 0 && (bpp == 8 || bpp == 24 || bpp == 32) in function 'FillBitmapInfo - Stack Overflow

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坠金

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值