codingforentrepreneurs / OpenCV-Python-Series

An OpenCV & Python Tutorial Series and Reference.
399 stars 550 forks source link

python .\faces.py error #1

Closed ADBYITS closed 6 years ago

ADBYITS commented 6 years ago

Hi guys I just got all the code and thought i got all the way though the FR stuff but i keep getting a error when i run faces.py

PS C:\Users\ADBY\Desktop\Coding\OpenCV-Python-Series-master\src> python .\faces.py OpenCV Error: Unspecified error (File can't be opened for reading!) in cv::face::FaceRecognizer::read, file C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp, line 61 Traceback (most recent call last): File ".\faces.py", line 11, in recognizer.read("trainner.yml") cv2.error: C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2) File can't be opened for reading! in function cv::face::FaceRecognizer::read

jakuta-tech commented 6 years ago

check that traiiner.yml exists. It was moved to the folder "recognizers" and renamed face-trainner.yml in the repo

ADBYITS commented 6 years ago

Hi mate got it working well sort off my faces don't see eyes or anything just get a square around the face and also doesn't matter how many images I put of myself it never finds me

On Tue., 15 May 2018, 4:38 pm jakuta-tech, notifications@github.com wrote:

check that traiiner.yml exists. It was moved to the folder "recognizers" and renamed face-trainner.yml in the repo

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/1#issuecomment-389059327, or mute the thread https://github.com/notifications/unsubscribe-auth/AWLYKCQ5L5bb4JSDFpdBBcqHJKLJasjxks5tynf3gaJpZM4T9o1q .

jakuta-tech commented 6 years ago

you need to make sure in the images folder that there's a subdirectory. That subdirectory should have images of you in it. Run face-trainer.py and then run faces.py. It will find the directory and then the label will be put onto the image.

ADBYITS commented 6 years ago

Yep done a that and ran the output and can see it seeing my folder and same deal

On Tue., 15 May 2018, 6:28 pm jakuta-tech, notifications@github.com wrote:

you need to make sure in the images folder that there's a subdirectory. That subdirectory should have images of you in it. Run face-trainer.py and then run faces.py. It will find the directory and then the label will be put onto the image.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/1#issuecomment-389086465, or mute the thread https://github.com/notifications/unsubscribe-auth/AWLYKCGFZ0TDv9Gri11AOQX06n9xh5ICks5typGigaJpZM4T9o1q .

Mathanesh-Ramasamy commented 6 years ago

File "face-train.py", line 21 if label in label_ids: ^ SyntaxError: invalid syntax PS C:\Users\RAVI\desktop\dev> line 21- if not label in label_ids:

how to solve this error?

nandkumar1996 commented 6 years ago

OpenCV Error: Unspecified error (File can't be opened for reading!) in cv::face::FaceRecognizer::read, file C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp, line 61 Traceback (most recent call last): File "faces.py", line 11, in recognizer.read("trainner.yml") cv2.error: C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2) File can't be opened for reading! in function cv::face::FaceRecognizer::read

codingforentrepreneurs commented 6 years ago

Trainer was moved and code has been updated.

bgnelson commented 6 years ago

No worries. Glad to help out, you provided a great starting point. Are you still experiencing issues?

Get Outlook for Androidhttps://aka.ms/ghei36


From: Coding For Entrepreneurs notifications@github.com Sent: Friday, September 7, 2018 12:40:37 PM To: codingforentrepreneurs/OpenCV-Python-Series Cc: Subscribed Subject: Re: [codingforentrepreneurs/OpenCV-Python-Series] python .\faces.py error (#1)

Closed #1https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/1.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/1#event-1833393467, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUJub50uqx4KrQRFb5H4XiCHoT0jYuAxks5uYq-VgaJpZM4T9o1q.

ankithendre commented 5 years ago

File ".\faces.py", line 11, in recognizer.read("./recognizors/face-trainner.yml") cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read' what shoul i do?

bgnelson commented 5 years ago

Make sure the code is referencing the file name.

Get Outlook for Androidhttps://aka.ms/ghei36


From: ankithendre notifications@github.com Sent: Tuesday, October 16, 2018 2:47:01 AM To: codingforentrepreneurs/OpenCV-Python-Series Cc: bgnelson; Comment Subject: Re: [codingforentrepreneurs/OpenCV-Python-Series] python .\faces.py error (#1)

File ".\faces.py", line 11, in recognizer.read("./recognizors/face-trainner.yml") cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read' what shoul i do?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/1#issuecomment-430135867, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUJub5GcbveCqJsDrT-RzdeRZac-vzOJks5ulY71gaJpZM4T9o1q.

ankithendre commented 5 years ago

thank you @bgnelson just had to rename folder

Yanchobasil commented 5 years ago

hi guys i got the code but when i run it i keep on getting error: OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\opencv_contrib-3.4.1\modules\face\src\facerec.cpp:61: error: (-2) File can't be opened for reading! in function cv::face::FaceRecognizer::read

SparshMaheshwari commented 5 years ago

Should the trainer.yml be empty ? If not then what must be there in it ?

hirenkhatri commented 5 years ago

In OpenCV 3.3

load() is replaced by read()

save() is replaced by write()

vijaychand118 commented 5 years ago

error: OpenCV(4.1.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read' will u please check it error then tell me the solution

hirenkhatri commented 5 years ago

In OpenCV 3.3

load() is replaced by read()

save() is replaced by write()

Change your method acoding to your respected version of opencv

On Tue, 23 Jul 2019, 12:38 p.m. vijaychand118, notifications@github.com wrote:

error: OpenCV(4.1.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read' will u please check it error then tell me the solution

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/codingforentrepreneurs/OpenCV-Python-Series/issues/1?email_source=notifications&email_token=AJRYRY3HYZAC4MWJXHHOJV3QA2U6XA5CNFSM4E7WRVVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2SEQUQ#issuecomment-514082898, or mute the thread https://github.com/notifications/unsubscribe-auth/AJRYRY7PWGNG2FZCAWT2PF3QA2U6XANCNFSM4E7WRVVA .

samii-ullah commented 4 years ago

Can any one tell me i am facing this issue. how to resolve this bug?

recognizer.read('trainer/trainer.yml') cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read'

DeepaDev69 commented 4 years ago

I have the same problem but for writing in file. and i am using cv2.face.LBPHFaceRecognizer_create().write('trainer/trainer.yml') it is still throwing error please help!!!

AlbandryNasser commented 4 years ago

I still have the same issue recognizer.read("recognizers/face-trainner.yml") cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv_contrib\modules\face\src\facerec.cpp:61: error: (-2:Unspecified error) File can't be opened for reading! in function 'cv::face::FaceRecognizer::read'

Please help!

patelrinkesh24 commented 4 years ago

Just copy the folder given below in your main folder of Face-Recognition-Based-Attendance-System-master

TrainingImageLabel.zip

vanetoj commented 4 years ago

patel when i use the face_recognizer.train(faces_pca, ids) it tells me "Expected 4, but was 2. in function 'train'" any ideas? thanks

vanetoj commented 4 years ago

Just copy the folder given below in your main folder of Face-Recognition-Based-Attendance-System-master

TrainingImageLabel.zip patel when i use the face_recognizer.train(faces_pca, ids) it tells me "Expected 4, but was 2. in function 'train'" any ideas? thanks

salmonnella99 commented 4 years ago

Traceback (most recent call last): File "D:\face\faces.py", line 20, in faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5) cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-rwld3ghi\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'

anybody can tell me how i fixing this kind of error? at my first laptop it running well but when i move the code to my second laptop i got this error (sorry for my bad english)

Ainsyafi commented 3 years ago

line 6, in recognizer.read('trainer/trainer.yml') #load trained model cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-zeowd5_m/opencv_contrib/modules/face/src/facerec.cpp:61: error: (-2:Unspecified error) File can't be opene

anybody can tell me how i fixing this kind of error? i used os ubuntu

MUHAMMAD-USAMA-ASHRAF commented 3 years ago

Traceback (most recent call last): File "C:/Users/HP LAPTOPS/Desktop/AI project/Training.py", line 21, in model.train(np.asarray(Training_Data), np.asarray(Labels)) cv2.error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\opencv_contrib-4.0.1\modules\face\src\lbph_faces.cpp:362: error: (-210:Unsupported format or combination of formats) Empty training data was given. You'll need more than one sample to learn a model. in function 'cv::face::LBPH::train'

Process finished with exit code 1