Face Detection in 2 Minutes using OpenCV and Python
Vložit
- čas přidán 4. 09. 2024
- In this quick tutorial I explain how you can detect faces in images as well as videos using Haar Cascades in OpenCV and Python. Face detection is the first step for doing face recognition.
Written version of this tutorial:
towardsdatasci...
GitHub link: github.com/ada...
Having trouble ? Need help ? Connect with me !
Email: adarsh1021@gmail.com
Instagram: / adarsh_menon_
Twitter : / adarsh_menon_
Github : github.com/ada...
#machinelearning #python #facedetection #opencv
while others are struggling to explain opencv. you did it in a simple way. In just 2 min
GREAT vlog
this is not 2 min...
actually he skip it for a seconds without skipping the countdown in the screen
This is not a vlog. If you don’t know, don’t use it
i really have to say ...nice work man ...u deserve to be recognised not just be these cascades but also by real people all around this ML community...
Thank you so much 😀
@@AdarshMenon which terminal have u used
You gotta be kidding me..
The error I've been trying to fix got fixed in 2 seconds just cuz of you 🔥
Thanks buddy!
u earned my like with 2 min stopper clock
This helped me a lot done with my project just in 15 mins😊 ,.... U r fabulous bro...
Finally, a good video. Thank you!
Glad you liked it!
Watched every commercial videos but got the thing in DESI ONE
Great Video, everyone else makes hour-long videos and explains basically the same stuff, here I learned all what is important in 6min. Good job!
@Maryam Ashraf i can
@@mufeezazam4763 i want it.. Please if u can
Bro explained very well. Just carry on !!!!
Thank you!!! I tried to do this for more than a month...
You explained very well!
good job man. keep up the good work because im sure it'll pay off in the long run. its rare to find talanted teachers and you are definitely one. simply well done
Best one I have come across on CZcams. Works without any error SO INSTANTLY.
Keep more coming!
Thanks, will do!
This is great video, I knew the basics off all the commands, your video helped me put all my knowledge to a functional detector. Thank you
Plz tell me which terminal is used in this video?
@@alizekhan2745 It's Linux terminal :-)
I have some error with this --> 'cv2.CascadeClassifier' object has no attribute 'detectMultiScal'. Could you tell how to fix it ????
Can u pls upload about human activity recognition
hi Ardas, thanks for your Lesson. god bless you ..Rusbi from Indonesia
u are a king man thanks from turkey
amazing buddy its really help me my mca projects thanks a lot buddy.
So I have been getting this error OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' any idea?
thank you , this was my first face detection project , awesome explanation
This was hella easy to follow, thank you!
by far the best explanation
Wow simply amazing, hats off to you😍
Traceback (most recent call last):
File "C:/face recognition/detectfacevideo.py", line 19, in
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
cv2.error: OpenCV(4.5.2) C:\Users
unneradmin\AppData\Local\Temp\pip-req-build-vi271kac\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' iam having this error how can i solve it..
try again but make sure you webcam wasnt use that time
work for me
Hello, I have a question to ask, I did the exact same thing as you in the video but the program didn't work and it announced an error while running the color saying "error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' " how do I fix it ? and thanks in advance for your help.
try again but make sure you webcam wasnt use that time
Same error can anyone help me with this one!
Very well explained. ..found it easiest tutorial
Glad you liked it!
Good bro Also made video on face MASK detection.
Thanks
thanks my man you save my life
Happy to help!
Hey, I have one question to ask. How can I make my own classifier instead of using pre-built haar cascade files?
Sentdex has made an amazing video on making your own classifier using haar cascasde - czcams.com/video/jG3bu0tjFbk/video.html
Another option for object detection would be to build a deep learning model using keras. You can also use something called "transfer learning", to retrain existing classification models to classify the objects you want to
Thanks, it works so easy in just 5 minutes,
Glad it helped
you may not reply for the error i think , you only reply for the person who appreciate you
you may try to clear the errrors of your subscribers also it may gives you a real happiness and thats the true appretiation
Hi Adarsh,
You made Face Recognition look so simple . Felt like I can learn FR hands down. . I have subscribed to your channel.
Thanks form KM
Great
thanks man, beneficial video for beginners
Good work Adarsh..Saved a lot of time!!
Glad to hear that !
Can u please make video like detecting the presence of human and with respect to open or close the relay
Everything is Awesome.... Tnq bro
Good job. Your code is still working.
Nice video, because :
-Indian tutorial
-Cursed audio
-Machine backsound
It works properly. Thank you.
Glad to hear that!
Helped A lot. Thanks for a detailed tutorial!
If we want to recognize faces with names then what we can do ?
Means it can able to detect face. Then what ?
This is only to detect faces. To recognize them - czcams.com/video/987QtKPZ-P0/video.html
@@AdarshMenon I watched that video but I am saying that if a moving person comes infront of camera. Then how we can do that in real time??
the face recognition library can help you do that - github.com/ageitgey/face_recognition
Nice, clean and good explanation tutorial ❌
Indian guy tutorial, machine sound, cursed audio 👍👍👍👍
Thanks bro, just thanks, now i really get this
hey...i need your help please reply..
can you tell me how can i detect the face of dog and cat and their emotions ...in python..please let me know if you know anything about it ..please help!
its small to get started on and its good
thank you very much. very educational and helpful tutorial.
Oh man you just save my day. Thank u
Glad to hear it!
yep mee too
Good one..
Thankyou so much vdo helped a lot🙌❤️
Very useful Adarsh. Thank you.
Glad it was helpful!
How to detect two or more faces coming towards camera. Thankyou for your video
Hi
I'm getting this error:
C:\Users\pc\AppData\Local\Programs\Python\Python38-32\python.exe: can't open file 'test2.py': [Errno 2] No such file or directory
I'm try to solve but I can't solve it, can you help me ? @Adarsh Menon
you need to be inside the directory where you saved your file 'test2.py'. Use chdir command in windows terminal to change directory
@@AdarshMenon Thanks but ı already solved, thx for help
thank you so much. it totally worked. Keep up the good work.
Thank u so much..😍
U saved me today😅
Thanks for making this video not complex
sir thank your for this video. i tried this. but i have a error.how can i fix it?
Traceback (most recent call last):
File "C:\Users\amali\Desktop\Face_Detection\test1.py", line 13, in
faces = face_casCade.detectMultiScale(gray, 1.3, 5)
NameError: name 'face_casCade' is not defined
looks like the variable is not defined, python is case sensitive. I think it should be face_cascade if you have used my code. Or else make sure the cascade file is in the same folder where the code is
In what software do you code this
What if we need to detect a photo which is in a particular drive
In the video at 1:30, line number 5 simply change the path of your file. For example if your file is C:/pictures/test.jpg, you can change that line to cv2.imread('C:/pictures/test.jpg')
@@AdarshMenon thank you for replying
@@AdarshMenon I have a doubt could you pls help me out...how can I reach you!!pls a small help
adarsh1021@gmail.com
@@AdarshMenon I mailed!!pls checkout
Thank you very much for this , helped a lot !!!
hey help plz getting errors like
Module 'cv2' has no 'CascadeClassifier' member..,Module 'cv2' has no 'VideoCapture' member,..Module 'cv2' has no 'cvtColor' member...,Module 'cv2' has no 'COLOR_BGR2GRAY' member...,Module 'cv2' has no 'rectangle' member....,Module 'cv2' has no 'waitKey' member
Please install cv2 first
Pip install opencv-python
Hi I did: pip3 install opencv-python but I get an error with pycharm regarding open cv2 : ModuleNotFoundError: No module named 'cv2' How to fix it?
Maybe you are on another version of python ? if you are using pip3, then make sure you call the script with python3
thank u very much bro its really nice working
Welcome 👍
No problem video is six minete greet job dud
Most straightforward video and useful video. Very helpful to me! Thank you very much.
Glad it was helpful!
Thanks Bro You Made Simple ;)
Glad to hear that!
thankyou for this video..
OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
how can i resolve this error
Maybe your haar cascade file did not load properly. Check if you donwloaded it in the same directory as your code.
Maybe this will help - answers.opencv.org/question/52340/opencv-error-assertion-failed-empty-in-detectmultiscale/
Working Now..Thanks
Can we add some time limit for the camera so that the camera turns off automatically and we don't have to press the ESC button ???
inside the while loop you could add a delay of say 100ms. Then you can keep a counter to count the number of times it ran (or maybe use a for loop). So now when this counter reaches 100 then you know that 10 seconds have passed
wow He explained so simply! Others are just making 23 mins video for this little purpose, anyways any solution to reduce cpu usage in the while loop? This takes up the whole cpu after 6 seconds!! Would be very helpful If we can run it on our gpu... is that possible?
Glad it helped ! It can be done, but seems complicated - www.quora.com/How-can-I-code-OpenCV-to-use-GPU-using-Python#:~:text=%2F%20Umat%20Objects)%20.-,When%20you%20use%20Umat%20type%2C%20OpenCV%20automatically%20tries%20to%20utilize,with%20CUDA%20and%20Python%20support.
That's Very Nice 👍👍.............
You have any report of this project which gives details information about this project.
Hello. For detecting faces from images and detecting images from webcam do we need to build two different models
Hi... im working with upperbody detection, this is not working with the detection of upper-body. can u plz help me out to get a frame over the upperbody recognition
hello, there is a problem in line 19
In web cam capture it is not showing rectangle on more than 1 face what should i do
This will help you stackoverflow.com/questions/33546356/how-to-detect-multiple-faces-in-opencv
Super sir
Thank you very much brother.
Welcome!
it didn't work in my sublime software because there's no run button but it run on idle python
Hello sir I am getting this error:
error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
Please tell me how to resolve it
Same error sir can you help me if you know how to resolve it
Please help me same error
i want to cheek if the face is my face then it wil give me a signe that the face is my you know what i'm saying
I'm getting this error please help
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
AttributeError: module 'cv2' has no attribute 'CascadeClassifier'
Maybe your haar cascade file did not load properly. Check if you donwloaded it in the same directory as your code.
Maybe this will help - answers.opencv.org/question/52340/opencv-error-assertion-failed-empty-in-detectmultiscale/
@@AdarshMenon Thank you for replying brother! Actually the problem was w/ the version of OpenCV. It wasn't compatible with the python version installed on my PC
Liked and subscribed.
One question.
I want to this with 10 diff ip cams not just one laptop camera. Pls tell how to do
you can definitely do it with 2 or even 3 i guess, but 10 might be a bit too much on your computer, unless you have a really powerful machine. In the line cv2.VideCapture(cam_no) - for each camera you need to write this like, where cam_no = 0, 1, 2.. no, of cameras. ref - stackoverflow.com/questions/29664399/capturing-video-from-two-cameras-in-opencv-at-once
Really loved you way of explaining stuff, could you tell where can I find internship to actually apply what I've learnt :)
Thank You So Much !!
Very Brilliant !!
Hi sir it shows an error cv2 has no attribute wait key can u solve this sir???
great video i founded on youtube thanks a lot bro.
I am facing some error in code can u help me with that
how can we display the name along with the rectangle box around the face
there is a method cv2.putText to write text on the image - you can also check my face recognition video, where I did that
Please help me sir..it is showing error no Module named cv2
make sure you have installed opencv - run pip install opencv-python
@@AdarshMenon sir I have followed all the steps.already installed openCV n I have saved raw file as well .but this error is coming
@@akankshachoudante2489 if you are on python3 then you might also want to try pip3 install opencv-python. Or the recommended way is to create a virtual env and do everything inside it
@@AdarshMenon ok thank you Sir I will try ...
Hi brother ... You really explained awesome ... Thanks for sharing your knowledge brother How could I modify the code for the recognition of twins ??? ....
Very great video sir, please tell me how I save XML file in python project
installing error 1 while doing pip install opencv-python
please guide for opencv installation
please post your exact error
giving a start on your github too
Awesome video! Keep going 👍
Thanks man!
thanks lot bro ,i use the code and it works
Hello buddy I have cctv footage video it's possible to detect the face coz the face in video lil blur
Getting an error on line 7 saying src.empty() in function cv::cvtColor
i wrote the exact code but i there is not rectangle formation for the detection of faces
how did u use face recognization module without having it to train ??? arent we suppose to upload example of face and no face pic and make him learn?
bro how to close this application it opens again when i close it,, i am running this in anaconda... any key to stop this?