Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python中opencv的imread()不适用于任何图像_Python_Opencv_Imread - Fatal编程技术网

python中opencv的imread()不适用于任何图像

python中opencv的imread()不适用于任何图像,python,opencv,imread,Python,Opencv,Imread,我尝试使用opencv的imread()函数读取图像,从而尝试显示我所读取的内容。但是它什么都看不懂 import cv import sys # Get user supplied values imagePath = sys.argv[1] cascPath = sys.argv[2] # Create the haar cascade faceCascade = cv2.CascadeClassifier(cascPath) # Read the image image = cv2.

我尝试使用opencv的imread()函数读取图像,从而尝试显示我所读取的内容。但是它什么都看不懂

import cv
import sys

# Get user supplied values
imagePath = sys.argv[1]
cascPath = sys.argv[2]

# Create the haar cascade
faceCascade = cv2.CascadeClassifier(cascPath)

# Read the image
image = cv2.imread(imagePath)
cv2.imshow("Image read", image)
这是我在python中的代码,我使用命令提示符执行,因此:

C:\> C:\Python27\python.exe C:\Users\Divy\Desktop\FaceDetectmaster\face_detect.py C:\\Users\\Divy\\Deskop\\FaceDetect-master\\abba.png C:\\Users\\Divy\\Desktop\
\FaceDetect-master\\haarcascade_frontalface_default.xml

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\highgui\src\window.cpp, line 271
Traceback (most recent call last):
  File "C:\Users\Divy\Desktop\FaceDetect-master\face_detect.py", line 13, in <mo
dule>
    cv2.imshow("Images read", image)
cv2.error: C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\high
gui\src\window.cpp:271: error: (-215) size.width>0 && size.height>0 in function
cv::imshow
C:\>C:\Python27\python.exe C:\Users\Divy\Desktop\FaceDetectmaster\face\u detect.py C:\\Users\\Divy\\Deskop\\FaceDetect master\\abba.png C:\\Users\\Divy\\Desktop\
\FaceDetect主机\\haarcascade\u frontalface\u default.xml
OpenCV错误:cv::imshow文件C:\builds\master\u PackSlaveAddon-win32-vc12-static\OpenCV\modules\highgui\src\window.cpp第271行中的断言失败(size.width>0&&size.height>0)
回溯(最近一次呼叫最后一次):
文件“C:\Users\Divy\Desktop\FaceDetect master\face\u detect.py”,第13行,在
cv2.imshow(“图像读取”,图像)
cv2.0错误:C:\builds\master\u PackSlaveAddon-win32-vc12-static\opencv\modules\high
gui\src\window.cpp:271:错误:(-215)函数中的size.width>0&&size.height>0
cv::imshow

是否确保imagePath指向现有图像?尝试
print imagePath
并检查文件夹和文件是否存在。尝试
print(image)
以检查图像是否为
None
对于.png或.xml文件,您不需要在命令行参数中使用双“\\”。