为什么cv2.imshow()在我的python编译器中导致错误? [英] why cv2.imshow() results in error in my python compiler?

查看:785
本文介绍了为什么cv2.imshow()在我的python编译器中导致错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我刚刚安装了opencv并检查了基本代码,但是会导致错误.代码是

Hi friends i just now installed opencv and checking the basic code but it results in error. The code is

import numpy as np
import cv2
img=cv2.imread('C:\Users\Pravin\Desktop\a.jpeg',1)
cv2.namedWindow('img',cv2.WINDOW_NORMAL)
cv2.Waitkey(10000)
cv2.imshow('cv2.WINDOW_NORMAL',img)
cv2.destoryAllWindows()

cv2.imshow()的错误是

The error for cv2.imshow() is

Traceback (most recent call last):
 File "<pyshell#3>", line 1, in <module>
cv2.imshow('image',img)
error: ..\..\..\src\opencv\modules\highgui\src\window.cpp:261: error: (-215)
size.width>0 && size.height>0

您的回答对我很有帮助. 预先感谢

It was very helpful to me with your answer. Thanks in advance

推荐答案

最有可能的是,未成功进行读取调用.确保图像"C:\ Users \ Pravin \ Desktop \ a.jpeg"存在. (扩展名.jpeg似乎很特殊,也许必须是.jpg?)

Most likely, the imread call didn't succeed. Make sure the image "C:\Users\Pravin\Desktop\a.jpeg" exists. (The extension .jpeg seems unusual, maybe it has to be .jpg?)

另外,如Hyperboreus所建议的,请尝试在文件名"C:/Users/Pravin/Desktop/a.jpg"中使用正斜杠,或转义反斜杠

Also, as Hyperboreus suggests, please, try using forward slashes in the filename "C:/Users/Pravin/Desktop/a.jpg", or escape backslashes

"C:\\Users\\Pravin\\Desktop\\a.jpg"

这篇关于为什么cv2.imshow()在我的python编译器中导致错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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