栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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()

参考资料:

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

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/968356.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号