简体   繁体   English

Python-OpenCv错误261

[英]Python-OpenCv error-261

I'm new to Python-OvenCV programming. 我是Python-OvenCV编程的新手。 I'm using python idle to load and display image from folder. 我正在使用python idle来加载和显示文件夹中的图像。 its showing the following error: 其显示以下错误:

**Traceback (most recent call last):   
File "C:\Python27\a.py", line 4, in <module>


cv2.imshow("abc",img)    
error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215)   size.width>0 && size.height>0 in function cv::imshow**    

my code is: 我的代码是:

import cv2    
import numpy as np    
img = cv2.imread("C:\Users\Mayur\Desktop\ab.bmp",0)    
cv2.imshow("abc",img)     
cv2.waitKey()    

I have searched for solutions but they are all for matlab and I'm using python IDLE. 我已经搜索了解决方案,但它们都是针对matlab的,并且我正在使用python IDLE。

You may have found the solution already, but ill give an answer anyways. 您可能已经找到了解决方案,但无论如何还是不能给出答案。

This is a common mistake when trying to read files in python. 尝试在python中读取文件时,这是一个常见错误。 in my experience python does not like the "\\" when you are naming the file location. 以我的经验,在命名文件位置时,python不喜欢“ \\”。 instead you should use a "/". 相反,您应该使用“ /”。 Here is what is should look like: 这是应该是什么样子:

img = cv2.imread("C:/Users/Mayur/Desktop/ab.bmp",0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM