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

时间:2016-01-28 13:41:39

标签: 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.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

0 个答案:

没有答案