Error in my code?

import cv2

cap=cv2.VideoCapture(0)
face_cascade=cv2.CascadeClassifier("")

while True:
ret,frame = cap.read()
gray_frame=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

if ret == False:
	continue

faces = face_cascade.detectMultiScale(gray_frame,1.3,5)

for(x,y,w,h) in faces:
	cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),2)

cv2.imshow("Video Frame",frame)


key_pressed = cv2.waitKey(1) & 0xFF	
if key_pressed == ord('q'):
	break

cap.release()
cv2.destroyAllWindows()

Error : File “new.py”, line 13, in
faces = face_cascade.detectMultiScale(gray_frame,1.3,5)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function ‘cv::CascadeClassifier::detectMultiScale’

Hey @mishraji_27, this line is incomplete, Add the name of the below haarcascade file here.

First You need to download this file as well, https://github.com/coding-blocks-archives/machine-learning-online-2018/blob/master/6.%20Project%20-%20Face%20Recognition/Face%20Recognition%20Project/haarcascade_frontalface_alt.xml
and keep in same folder as your .py file. Than copy paste its name and keep it in “” .

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush: