我正在尝试使用 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