neha01 / FaceRecognition

Face Recognition using OpenCV in Python
163 stars 146 forks source link

opencv error #5

Open IAmMarvel opened 5 years ago

IAmMarvel commented 5 years ago

File "tester.py", line 9, in faces_detected,gray_img=fr.faceDetection(test_img) File "C:\Users\sunil\Desktop\ml_project\me\face_recognition.py", line 6, in faceDetection gray_img=cv2.cvtColor(test_img,cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

this is the error i m getting.Can you tell me what to do in that

neha01 commented 5 years ago

Seems your test_img is not loaded properly. Try to => print(test_img.shape) and check if you get any valid dimensions or you receive an error stating "'NoneType' object has no attribute 'shape'"

frznna commented 3 years ago

PS C:\python39\try> & C:/Users/User/AppData/Local/Programs/Python/Python39/python.exe c:/python39/try/Face-Recognition-master/train_model.py <module 'faceRecognition' from 'c:\python39\try\Face-Recognition-master\faceRecognition.py'> Traceback (most recent call last): File "c:\python39\try\Face-Recognition-master\train_model.py", line 9, in faces_detected,gray_img=fr.faceDetection(test_img) File "c:\python39\try\Face-Recognition-master\faceRecognition.py", line 8, in faceDetection gray_img=cv2.cvtColor(test_img,cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-95hbg2jt\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

hi, please help me why i'm getting this error and it cannot read it