I'm trying this sample face detection program using opencv in python.But there seems to be an error in the detectMultiscale function.The code is:
import cv2
import sys
imagePath = sys.argv[1]
cascPath = "haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascPath)
image = cv2.imread('face.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
 faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.1,
    minNeighbors=5,
    minSize=(30, 30)
)
print("Found {0} faces!".format(len(faces)))
for (x, y, w, h) in faces:
    cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.imshow("Faces found", image)
cv2.waitKey(0)
This is the code.The file name being main.py.I placed all of the resources under Myproject file.When i tried running it from prompt i got this error.
C:\Myproject>python main.py face.jpg
Traceback (most recent call last):
  File "main.py", line 21, in <module>
    minSize=(30, 30)
cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'
Thanks for reading and help me solve this problem.