Why can be wrong in my code?

I copied the code show in the video. But i am getting the following errors:

Traceback (most recent call last):
File “face_data_collect.py”, line 32, in
faces = face_cascade.detectMultiScale(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’

[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

Please tell me what can be wrong in my code.

This is because there is error loading the haarcascade file, make sure ‘haarcascade_frontalface_alt.xml’ exists on your system, also it must be in the same directory as in your .py file you are working on. You can download the file from the following link,

Hope this cleared your doubt. :blush: