断言失败:size.width> 0&&函数imshow中size.height> 0 [英] Assertion failure : size.width>0 && size.height>0 in function imshow

查看:89
本文介绍了断言失败:size.width> 0&&函数imshow中size.height> 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在树莓派上使用opencv2和python.我是python和opencv的新手.我试图读取一个jpeg图像并显示它显示以下错误的图像:

i am using opencv2 and python on raspberry pi. and i am new with python and opencv. i tried to read a jpeg image and display image it shows the following error:

/home/pi/opencv-2.4.9/modules/highgui/src/window.cpp:269: \
  error: (-215) size.width>0 &&  size.height>0 in function imshow.

,代码为:

import cv2
# windows to display image
cv2.namedWindow("Image")
# read image
image = cv2.imread('home/pi/bibek/book/test_set/bbb.jpeg')
# show image
cv2.imshow("Image", image)
# exit at closing of window
cv2.waitKey(0)
cv2.destroyAllWindows()

推荐答案

图像无法加载(可能是因为您忘记了路径中的前导/). imread然后返回无.将None传递给imshow会导致它尝试创建大小为0x0的窗口,该窗口将失败.

The image fails to load (probably because you forgot the leading / in the path). imread then returns None. Passing None to imshow causes it to try to create a window of size 0x0, which fails.

cv中差的错误处理可能是由于C ++实现上的包装层很薄(在错误中返回NULL是一种常见的做法).

The poor error handling in cv probably owes to its quite thin wrapper layer on the C++ implementation (where returning NULL on error is a common practice).

这篇关于断言失败:size.width> 0&&函数imshow中size.height> 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆