OpenCV Python TUTORIAL #4 for Face Recognition and Identification
HTML-код
- Опубликовано: 20 июн 2024
- OpenCV with Python Series #4 : How to use OpenCV in Python for Face Recognition and Identification
Sections
Welcome (0:00:00)
Copy Haar Cascades (0:04:27)
Haar Cascades Classifier (0:07:11)
Using the Face Classifier (0:09:36)
Draw a Rectangle in OpenCV (0:16:15)
Recognizer (0:20:13)
os.walk for image finding (0:23:25)
Labels from directories (0:27:45)
Training image into a numpy array (0:31:04)
Region of Interest in Training Data (0:34:06)
Creating Training Labels (0:37:06)
Using Pickle to Save Label IDs (0:40:38)
Train the OpenCV Recognizer (0:42:20)
Implement Recognizer (0:44:28)
Load Label Names from Pickle(0:47:46)
OpenCV PutText (0:53:02)
Resize Images for Training (0:54:35)
Eyes and Smile (0:58:01)
Live Tests (1:00:46)
Final thoughts (1:02:23)
Subscribe: kirr.co/7l2sv4/
Code on Github: github.com/codingforentrepren...
New to OpenCV? Try this: • OpenCV TUTORIAL with P...
Learn OpenCV & Python Playlist: • OpenCV & Python
Install OpenCV for Python on your system:
Mac: • How to Install OpenCV ...
Windows: • How to Install OpenCV ...
Linux with Pi Awesome: kirr.co/sx77b7
It's 2022 -- who wants a new version of this one? Please comment!
can u send me this project please i am studying deep learning ?
That'll be great actually!
Yes please
Me either! I want to classify known/unknown person! and if unknown person, mark them 'unknown' ! I got trouble please help
Are you really asking? Everyone! :P
I have never been so blessed with this kind of tutorial!! I was about to give up to do opencv but you came out with this! Thank youu!! It's really helpful!
you're building one of the most understandable and efficient tutorials in this platform.
thanks a lot for your efforts, my friend!
I can't thank you enough for these tutorials. Your explanations are clear and concise and the auxiliary blog posts are super solid. Thank you!
Thank you!
Man. 4 years ago when I was teenager I met processing and openCV for the first time and I get crazy because it was SUPER cool to make art and crazy stuffs with it but it was too hard and don't know anything about programming. Now you gave me this tutorial (I'm kind late for this video actually) but I should thank you so much because (now I know python) you make everything much easier to understand and get me into it again.
Thank you so much.
My next object is to make machine learning with some graphical interfaces to see how and what computer doing in the process of learning just for like a game. If you have some tips (not tutorial, I want to learn it by my own) I appreciate.
Hey Justin, this is an amazing tutorial, thanks!
I do want to share that the "conf" of CV2's predict are actually losses. So the higher it is, the more uncertain the prediction is!
Wow, this has to be the most useful tutorial I've followed, not only did you make it work accordingly, you explained concisely what each part of the code does step by step, without assuming that whoever was watching already knew what it does, thank you for making this! And as a side note, I really can't blame the classifier for recognizing you as Nikolaj!
Face Classifier: "Bro, it's the same guy!"
Awesome tutorial. What helped me most is your line by line explanation of the code that you wrote. Thank you a ton teacher.
Thanks for the great content and lessons! BTW, it's recorded in BGR and not (RGB) because when the developers originally made OpenCV, webcams and other cameras used the BGR method as the standard color definitions. That made the conversion process from numerical values for HEX much easier.
Fun. I'm going to have to play with this.
The issues with what you faced (no pun), and some things I was working on gives me a few ideas. It's nice to feed my brain. :-)
Oh Yeah!
Thank you for this tutorial! Everything that I needed to know in just one hour!
I couldn't thank you more for building this tutorial, you have my respect and all the well wishes, thanks a lot justin, god bless you. Love from India..!!!!!
Nice tutorial sir! this is the first app, I created on python, Thank you sir
hey man, you are a very good teacher.
Thank you!
@@CodingEntrepreneurs ... Congratulations +1 signed !! ... Jones, please elucida me in a doubt? .... I can make an app that instead of picking up faces through the camera of the device I can get images on the screen of my cell phone, like arrows and numbers that are displayed in real time by another application? ... Ex: my 'app_X' running in the background, however, reading another app_Y's screen in the foreground and collecting data from this second app_Y to app_X in second plane in the background? .. If yes, can you show me the way? Thank you very much !! .... hugs !! (for the Android platform) ......
@@CodingEntrepreneurs It shows an error like this what can i do? pls reply
recognizer.train(x_train, np.array(y_labels))
TypeError: src is not a numpy array, neither a scalar
In face-train.py file i am getting error at line 11, saying that "recognizer = cv2.face.LBPHFaceRecognizer_create()
AttributeError: module 'cv2.cv2' has no attribute 'face'". please help me to solve this.
@@siddhartharenikuntla9624 Hi, try using pip install --user opencv-contrib-python. It works on me.
Thank you for a quick kick start with training a model to recognize people
Absolutely amazing tutorial, blows my mind!
Thank you for the great tutorial! I would love to see a tutorial on integrating deep learning
An awesome tutorial it is! I also appreciate the panacea approach...all in one🙌
i forget to thank you for the tutorial
so amazing
Thank you! 🙌
@Maryam Ashraf Just do cv2.imwrite
I'm new to comp vision recognition and this tutorial really make it easy, great tutorial Justin
First of all thank you for the great tutorial. I've rarely encountered such a great introduction. From what I can figure out, one potential cause for the poor quality of identifying the right person is the fact that faces will not be detected in all the photos. At least in my instance, no face is recognized in the pictures with Peter Dinklage whereas for Kit Harington 5 / 6 pictures were recognized as having faces in them. So yeah, there is still some room for improvement and experimenting around. Great video!
I think the fastest way to get image data for maybe members of your family is asking the to stand in front of the webcam and using opencv take the region of interest per frame and saving them... this would generate hundreds of images and in a short time...
For CNNs,the more the data the better....
How to solve this error ?
recognizer = cv2.face.LBPHFaceRecognizer_create()
AttributeError: 'module' object has no attribute 'face'
pip uninstall opencv-contrib-python
pip uninstall opencv-contrib-python
it worked for me
pip install opencv-contrib-python
@@robsonjunior2483 thanks it worked
@@taimoorneutron2940 That's great.
great material! an awesome introduction for truly begginers!
Great video and down to earth, real usable stuff, presented really well and understandable . Thanks!
Great video, works perfectly on Raspberry PI3, just needed to change.. recognizer.save to .write
Good to know thanks!
hey man I have question he writes import cv2. Right now I am using OpenCV 4. So; does that mean I gotta import cv4 ?
hey man, im really looking forward if you could help me with raspberry pi3, everything is fine in pycharm but it getting error when i run it on raspberry.
To make better identification parameters you can add cv2.equalizeHist() function in main program before roi_gray , it improve recognition confidence abut 2% in my program.
hello, since you have worked on such programs would u mind helping me with one issue ... my face trainer isnt working. even when i delete all the pictures and place my own pictures , the face recognition would just give me (kit harington) even after i deleted it and used face trainer. any help ?
hands down the best tutorial thus far!
Hey Man thats a very usefull Tutorial! Thanks i searched a tutorial for FR and the other videos are never so good as yours! You can teach very good, and I like to listen to you.
make a facial expression detection project.[smile,sad detection] waiting for this from you
This LBPH model is not computed yet. Did you call the train method? in function cv::face::LBPH::predict
i had this error
what would i do ???
me too, can u fix that
the same error
You speech is very clear, every word every sentence. I think the speed is very good.
Because I'm Chinese, but I can understand what you say from the subtitle. It's very good for me.
Thanks
Thank you, sir. I learned a lot from this tutorial and got a good knowledge of how openCV works.
this guy is f*ing amazing *subscribed
First of all, thank you for this amazing tutorial! But I have issues with the detection. The problem is that the program detects all persons as the same. Does anyone have a solution for that?
I have the same problem, please I need help🙏🏾🙏🏾🙏🏾
This tutorial is rich in info. Thanks, Justin!
Your tutorial is very helpful, Mr. Justin, thanks
54:05 funny typo xD muscle memory i guess :P
lol Or because the S key is right beside the A key
"import cv2" is correct if I have opencv on 4.2 version?
Yup
Sure
I love this tutorial thank you so much! Helped me alot with a project
man you save my live, you're a lifesaver, thank you so much
how can i add one more file with my pictures?
Meaning...
You can use the following script
for (x, y, w, h) in faces:
i = i +1
crop_img = img[y: y + h, x: x + h]
cv2. Imwrite( "face" + str(i) +"png",crop_img)
'i' must be declared somewhrre globally
could someone fix this error?
in
id_, conf = recognizer.predict(roi_gray)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv_contrib\modules\face\src\lbph_faces.cpp:406: error: (-5:Bad argument) This LBPH model is not computed yet. Did you call the train method? in function 'cv::face::LBPH::predict'
i had the same issue... i copied his faces-train code from github... it had some extra code implemented... i removed them and changed it to the way it was at 43:40
I wish I could give more than a thumbs up, THANK YOU!
Thank u too much for this great and so useful video. I write my thesis project
with this video. You're very good at this. Good luck
Accuracy is not that good , please provide a video for same using siamese networks.
thankyou!
Confidence 0 is exact match, a higher number is a lesser match. Looks like you are looking for lesser matches. Maybe search for confidence < 50 or 25
this should definitely be higher. i noticed this too where the wrong results had more than 100 confidence. what a confusing name tho.
From Colombia I just want to thank you, it works perfectly, excellent tutorial, you saved my ass.
really amazing man !
thank you so much for this video.. this was a great tutorial.. i learnt a lot !
the way you explained this stuff step by step is really awesome !
thank you once again man!
AttributeError: module 'cv2.cv2' has no attribute 'face'
i'm getting this error while training can you give any tip to overcome this error
pip install opencv-contrib-python
run this in terminal and then run this
pip install opencv-contrib-python --upgrade
hope this works
it worked for me
@@jagadishb14 Same problem here in WIN10. Reboot doen't help
im getting this error
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'
could you help me
Me too!
I had the same, just make sure if your name file is the same like in faces-train.py
Great video. You make it look very easy to get this started.
One suggestion: Maybe print out the confidence number so you can see if it's just too low of a threshold. It might not really think you are anyone from the training, but you're closer to the other people. I would imagine trusting this at a 75% confidence should be realistically attainable.
Great tutorial Justin. Thank you.
og_labels = pickle.load(f) this is showing : Ran out of input error help me
At first, you have to run your faces-train.py file then you need to run faces.py file.
@@noobninja7565 do you know how i might go about getting past this error "UnsupportedOperation: read" with the line og_labels = pickle.load(f)?
When I run python faces-train.py, my cmd didn't have "[INFO:0] Initialize OpenCL runtime". Is this ok or not?
Same issue..
Could you resolve it ? I’m facing the same issue !
www.codingforentrepreneurs.com/comments/9784
stackoverflow.com/questions/54274298/opencv-4-typeerror-expected-cvumat-for-argument-labels
Same Issue. Did you find how to reslove the problem ? After that, I tried to continue the code withou caring, but when I launch the faces2.py code the window closes itself directly when it sees me.
The best python ocv tutorial ever 💪🔥 thank you so much
lovely videos. Very interesting way of teaching as well. Thank you immensely.
Thank you
Dude, you look so much like jaime lannister you might want to avoid crumbling buildings
Lol. Good call
Watch dogs here I come...
what is that supposed to mean.
@@benbambae oh i see
guys he is talking about the game Watch Dogs as it has a profiler system in game, great game, must play.
Dude, I'll be freaking Wrench from Watch Dogs 2
Hey man, you got a new subscribed. I tried a lot to do this recoginition but i never found a tutorial who helped me like that. Thank you a lot
Can you please share the code?
I'm loving this thanks mate!!
It keeps recognizing me as Justin...
ive got a problem error message: AttributeError: module 'cv2.cv2' has no attribute 'createLBPHFaceRecognizer'
but ive found the solution. anyone who has the same problem just install opencv-contrib-python
pip install opencv-contrib-python
how can i install opencv_contrib-python in anaconda
Update attributes bro... "Python -m pip install opencv-contrib-python"
2.7
I have same problem
AttributeError: module 'cv2.cv2' has no attribute 'CascadeClassifer' . What to do?
Guys try this
opencv use share same path so it will mess-up.
1) use pip uninstall opencv-python
2)use pip install opencv-contrib-python
Thank you for helpful video, it's worked like a charm.
It was a pleasure to see your video. I learned a lot. Thanks.
Hey justin I have a problem " recognizer = cv2.face.LBPHFaceRecognizer_create() AttributeError: module 'cv2.cv2' has no attribute 'face' " and I have try the solution in comment but he don't work for me if you can help thanks.
Oh and the video is very great !!!
pip install opencv-contrib-python then yoyur problem be solved
@@aakashsharma3226 Noo, this didn't solve it for me. Please help, I'm struck there :'( (Using PyCharm)
you look like nikolaj coaster
Lol
The trainer wasnt wrong
please what version of python should i use
This was a brilliant tutorial, thank you so much!
excellent video about a loved topic
cv2 has no attribute face
Installed opencv-contrib-python
But still didn't work
Do pip "install opencv-contrib-python" in terminal
@@hectorkolind9668 that's what i mentioned as,
Installed opencv-contrib-python
But still didn't work
@@shivatejasannareddy "pip install opencv-contrib-python" works as a replacement for "open-cv" so you have to uninstall "OpenCV" first.
Did it work?
Anyone have tried it on windows?
ruclips.net/video/VrthLPWB3yg/видео.html
Yeppp... Working superb
Yeah it works
@@tabasummulla8722 which IDE are you using
LOVE IT SOOO MUCH you just got a new subscriber
This is a great tutorial for face recognition.
Best explanation i ever heard....
Awesome bro...
and Thanks :-)
Thank You for this exciting tutorial video.
2023 still working Really Coool ! thank you ! Perfect!
I completed this project and actually I enjoyed doing this. You are a very good teacher man. Thank you so much. Really hoping to learn more from you.❤️
Can you share me proper code
Can you share ?
You really taught me the detail. And I gave you a new subscriber.
Yeah buddy!!
Thanks for the video, it was really helpful.
looking forward to tutorial with tensorFlow
Superb technical video. Thank you.
Thanks, very well organised and teached
greatest teacher...i have ever seen
Thank you so much for this video. I really learned a lot and you really helped me on my project. Thank you!!! Earned a sub for sure!!
Gr8 video... Excellent teaching...
Thanks, bro! for your great videos.
thank you! His video has helped my project a lot.
Hey can u help me please in my project ?
Bless your soul. You're a legend :)
This video is too much helpful. It became very easy to understand and implement. Thanks lot
Please make a video to show how to train with tensorflow..
Thank you so much for this tutorial it really helps me .
Amazing video, I had build a model for Quick face recognition using CNN but just wanted to use it over OpenCV and this was perfect! Thank you :)
heey can you send me the face recognition using cnn project details
@@somasekharsarma726 i will upload it on github on friday after some fine-tuning, will share the link for you
@@Gavy093 can i have the link to yaagoubi.mohammed@gmail.com thank uuuu
Thank you for this lesson.
This was very helpful. Thanks!
Thanks a lot!, really good the tutorial!
Nice tutorial really great for beginners in face recognition.
Great tutorial! Thanks.
Wonderful introduction! Thank you! Maybe resize the training ROIs rather than the original training images to train the recognizer for better results?
great course... love the way u explain :p
Thank you very much!!! Great video!!!
Thanks for your video, it's super useful.
Thank you So Much sir For this Tutorial,it's helped me a lot
very interesting show and exited presentation, Thanks alot :)