Haar Cascade Object Detection Face & Eye - OpenCV with Python for Image and Video Analysis 16

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 807

  • @jo-of-joey
    @jo-of-joey 8 лет назад +111

    you are such a big help to my final project

    • @sentdex
      @sentdex  8 лет назад +28

      Great! Best wishes on your project.

    • @adriandeveraaa
      @adriandeveraaa 6 лет назад

      what class whats that project for?

    • @asadullah3129
      @asadullah3129 4 года назад +2

      Plz tell me about your final project

  • @Dylan-qk8ss
    @Dylan-qk8ss 8 лет назад +54

    "Morbidity aside, you aren't going to find eyes outside your face." - you made my day sir

  • @rahard
    @rahard 6 лет назад +1

    for those who are having errors, I found out that when downloading the Haar Cascades through the link, sometimes it saves the file(s) as HTML (not XML). make sure it is NOT saved as HTML. check the first line of the file.
    originally I saved the link by using web browser, it saved it as HTML. then I just clone the link through git command. got everything (in another directory though, just copy them). it works. I hope it helps. this is a cool video tutorial. love it.

  • @geoffreyhuntoon4409
    @geoffreyhuntoon4409 7 лет назад +20

    The entire series up to this point was worth it for the Haar pun.

    • @geoffreyhuntoon4409
      @geoffreyhuntoon4409 7 лет назад

      I mean, it's been extremely helpful, too, but the puns really make it. :)

  • @lilbastards7885
    @lilbastards7885 8 лет назад +1

    Hey, Harrison! Your channel is the Python: The Definitive guide on the internet. Literally everything I am not sure about, I can find the answer in one of your videos! Yesterday I found out I will need to learn some OpenCV for one of my projects. I came straight to Sentdex and bingo! How come you still don't have 100K subscribers? I don't get it. :)
    Thanks for sharing your knowledge!

    • @sentdex
      @sentdex  8 лет назад +1

      +Soundscrap Glad to hear you are enjoying the tutorials! I enjoy doing them. Maybe 100K subs some time in 2016 :P

  • @Caique12392
    @Caique12392 6 лет назад

    Hello! I'm from Brazil and I just finishing the course of computer engineering and this video helped me a lot to complete my project, thank you! I'll subscribe to your channel

  • @tylersnard
    @tylersnard 4 года назад

    That was SO FAST! Usuall these tutorials take hours, I got it up and running in 5 minutes! Thank you!

    • @tylersnard
      @tylersnard 4 года назад

      @maryam I've never used spyder IDE. But I think you could modify the code to work on a video instead of webcam

    • @tylersnard
      @tylersnard 4 года назад

      @Maryam Ashraf ruclips.net/video/HjCuISHb9WE/видео.html Does this help?

  • @shoebmoin10
    @shoebmoin10 6 лет назад +23

    To avoid mouth being considered as eye we can consider ROI as just upper 70% of the face ,Therefore :
    roi = frame[ y:int((y+h)*0.7) , x:x+w ]

    • @shailendrapandit440
      @shailendrapandit440 5 лет назад +6

      roi_gray = gray[y:y-int((y + h) * 0.7), x:x + w]
      roi_color = img[y:y-int((y + h) * 0.7), x:x + w]
      right way to do it

    • @bennguyen1325
      @bennguyen1325 4 года назад +1

      @@shailendrapandit440 Thanks sir.

    • @sonalisahoo5170
      @sonalisahoo5170 4 года назад +1

      @@shailendrapandit440 what does these two lines mean?? Even the tutor didnt explain about it..so pls do help @takeTech @Shoeb Moin

    • @zlls
      @zlls 4 года назад +1

      ​@@sonalisahoo5170 It means you're grabbing from y to the 70% of the height and from X to X + W (width). It's a little bit complicated to explain

  • @JohnnyRottenest
    @JohnnyRottenest 8 лет назад +2

    Great videos. I watch all the time, just want to tell you I appreciate that you cover advanced (for me at least) and useful topics.

  • @rogzam
    @rogzam 6 лет назад +15

    "If you laughed, I appreciate it"... hahah, love this tutorials!

  • @abdeen91
    @abdeen91 7 лет назад

    your channel is heavenly! everything is just awesome!!

  • @vaishnavivaishu8338
    @vaishnavivaishu8338 4 года назад

    Love your way of teaching😘😘

  • @matheusrodrigues-kf6pj
    @matheusrodrigues-kf6pj 4 года назад

    you're so intelligent and funny man, thanks for the videos

  • @diegodibelardino7149
    @diegodibelardino7149 6 лет назад +1

    listen... you're the best at it... I really want to learn image analysis and I'm sure none is gonna explain better than you... but in this tutorial you missed to explain some part of the program like you usually do in your other tutorial... in fact in some part I'm really getting lost...

  • @amitabhphatak
    @amitabhphatak 5 лет назад

    Just ran my first face detection program.Thanks a lot !

  • @ellemagic3856
    @ellemagic3856 8 лет назад +1

    Thank you sir! You are very helpful and generous in sharing your codes with others :)

  • @jonesman1308
    @jonesman1308 7 лет назад

    sentdex you're prob not going to read this but we have to do a project in university where we need to something with augmented reality so we stumbeld upon your video, and as it turns out the guy you're using the haar cascades from is our professor who's guiding/grading our project :D

    • @sentdex
      @sentdex  7 лет назад

      Haha, small world :)

  • @borjasanchez3137
    @borjasanchez3137 6 лет назад

    i love you, you saved my final project of the degree

  • @yonatantasew3070
    @yonatantasew3070 8 лет назад

    your face detection code works perfectly and i was wondering if you are planning to make a face recognition tutorial any time soon or at all. Oh and u r awesome!!!

  • @naeemayoub1534
    @naeemayoub1534 6 лет назад

    you are really awesome, i am learning a lot from your videos. keep it up. thanks for sharing your knowledge.

  • @CariagaXIII
    @CariagaXIII 7 лет назад

    if you are having problems add. incase you're cascade is on a different location
    import os
    os.chdir("C:/Users/cariaga/Documents/haarcascades")
    on top
    right before
    face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')

  • @adib0078full
    @adib0078full 7 лет назад

    dude you're such an inspiration !

  • @dhaves
    @dhaves 8 лет назад

    I can't laugh because i still dont know how hard will be create my cascades!
    Amazing work, btw!

  • @amey97
    @amey97 Год назад +1

    Thank You!!

  • @csdc4891
    @csdc4891 8 лет назад +2

    Your tutorials are very helpful :) waiting for the next video as it is going to help me a lot :) :)

  • @jaiyesh007
    @jaiyesh007 7 лет назад

    Thanks Bro you saved me i used your code from your page and its working fine.

    • @InspirationalQuotes480
      @InspirationalQuotes480 7 лет назад +1

      hi, i am trying to run this code and i got this error,
      Traceback (most recent call last):
      File "C:\Users\Lenovo\Desktop\camerapro.py", line 13, in
      faces = face_cascade.detectMultiScale(gray, 1.3, 5)
      error: C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\objdetect\src\cascadedetect.cpp:1634: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale
      Do you know what is the problem?

  • @Fiand.s
    @Fiand.s 5 лет назад

    thanks for your video tutorial so finally my project is done

    • @paulinamoras9108
      @paulinamoras9108 5 лет назад

      Did you use the same haar cascade files from the link of 3 years ago?

  • @divadbate
    @divadbate 8 лет назад +15

    just subbed...I am so going to binge watch your videos tonight :P

    • @sentdex
      @sentdex  8 лет назад +4

      +divadbate Thanks for joining us!

    • @urs_rkm
      @urs_rkm 8 лет назад +2

      how to enhance this detection into recognition. i.e., displaying the name of the person after detecting the face(on bounding box).

    • @ItsGlizda
      @ItsGlizda 7 лет назад +1

      Maybe convolutional neural network?

    • @marcone1338
      @marcone1338 6 лет назад

      Can you help me with this?
      Traceback (most recent call last):
      File "C:/Users/Marcone/Desktop/Marcone/ex001.py", line 12, in
      gray = cv2.cvtColor(img, cv2.COLOR_BRG2GRAY)
      AttributeError: module 'cv2.cv2' has no attribute 'COLOR_BRG2GRAY'

    • @umangahuja1
      @umangahuja1 6 лет назад

      CH4pI3 it's BGR2GRAY and not BRG2GRAY

  • @FairPlayGaming
    @FairPlayGaming 4 года назад +2

    Just in case anyone has problems the cascades; use this code instead:
    face_Cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_alt.xml")

  • @adarshsn8728
    @adarshsn8728 6 лет назад

    Really helpful tutorial.
    keep up the good work.

  • @kuaranir2440
    @kuaranir2440 2 года назад

    Great tutorial👍

  • @MikeAirforce111
    @MikeAirforce111 7 лет назад +1

    Love your bad taste in humor :D thx for the vid bro!

  • @technicalilm8999
    @technicalilm8999 7 лет назад

    Your videos are amazing ..

  • @17jhoow
    @17jhoow 8 лет назад

    thank you so much for you videos!!! They are easy to follow and helped me a lot! I'm so happy that my face detector is working hahah

    • @sentdex
      @sentdex  8 лет назад

      Happy to share!

  • @nurbolbizhigit2557
    @nurbolbizhigit2557 5 лет назад

    That is epic,dude.Thank you for your this informative videos

  • @dr4gon743
    @dr4gon743 8 лет назад

    Amazing tutorial! Loved it.

  • @jsquared5730
    @jsquared5730 7 лет назад +1

    U R amazing
    i can now track objects from my drone

  • @gianfrancodagostino3938
    @gianfrancodagostino3938 5 лет назад

    Pure gold!!! THANK YOU!

  • @SpikyCat
    @SpikyCat 8 лет назад +9

    Can you do something on Neural Evolution in python?

  • @ronakjain4690
    @ronakjain4690 7 лет назад

    it is very helpful for my assignment.. Thanx Buddy

  • @abdullahsaif4859
    @abdullahsaif4859 7 лет назад +2

    Hi, got this error<
    any help :(
    face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    TypeError: 'str' object is not callable

    • @sunOOconuresOOrock
      @sunOOconuresOOrock 7 лет назад

      Sounds like perhaps the file wasn't found? Ensure the .xml is saved in the same directory as your script, with case sensitive naming. It is possible to call it from another directory but I generally find it's one less possible problem on small scales like this to just put it all in the same bowl and eat with a big spoon I guess you could say. No need to dig for each file we are using.

  • @CoteDivoireMakingof
    @CoteDivoireMakingof 7 лет назад +2

    Hi , can you code with JES?

  • @shoravsuriyal5954
    @shoravsuriyal5954 7 лет назад

    now its working thanks guys

  • @yehonatanpeleg7637
    @yehonatanpeleg7637 4 года назад

    great tutorial

  • @mato2968
    @mato2968 3 года назад

    Such a great video.
    Do you have an Idea why I'm only seeing frames instead of a video?

  • @YadishareTutorial
    @YadishareTutorial 7 лет назад

    very nice tutorial...thanks

  • @techm3825
    @techm3825 5 лет назад

    Teach how make identification of the user. I saw a video of u about it... and I did not understand much... I'm Brazilian and study English hehehe.. but I like so much of u job!! Congratulations!! I wait your answer.

  • @shivadhanush3131
    @shivadhanush3131 4 года назад

    Hello Sentdex, i had been following your videos on NLP and CV and they are awesome. was looking for help. What is the solution for the faces which are recorded from side angle. Any other algorithm or parameter tuning. I tried many so far.

  • @sharonshaju1872
    @sharonshaju1872 7 лет назад

    Hey sir!
    I've been working on a project for the blind people and yea your tutorials is just great! can i have some personal attention of yours please?
    i really understand the way you teach.

  • @evanmaltz6103
    @evanmaltz6103 8 лет назад +1

    Hi sentdex,
    Thank you so much for this! Is there a way to do the same type of object recognition in a list of images rather than from a video feed?
    Thanks!

  • @1368dainn
    @1368dainn 8 лет назад +1

    Thanks for the tutorial it was great. I was wondering if I'm using raspberry pi camera module, will cap = cv2.VideoCapture(0) work? Sorry I'm still a beginner and want to detect cars using haar cascade.

  • @amandaye2331
    @amandaye2331 8 лет назад

    Thanks a lot! By the way, which version of OpenCV and Python are you using ?

  • @Retro_Floyd
    @Retro_Floyd 3 года назад

    Thank you so much for making this video, you are a legend.

  • @tanmayagarwal1356
    @tanmayagarwal1356 4 года назад +3

    "If you laughed, I appreciate" ... LOL that was amazing!! ... N i actually laughed LOL

  • @edlynx9078
    @edlynx9078 4 года назад

    Been watching your videos. What do you recommend using for commercial use on facial recognition?

  • @vallabh2803
    @vallabh2803 6 лет назад

    Awesome !!!
    Thanks for this video.. :)

  • @RishabhGoyal
    @RishabhGoyal 6 лет назад

    Suggesting a modification. Because we are using the ROI of face to detect the eyes within that ROI, when the lower half of the face is out of frame, the eye will never get detected.

  • @tamaldas3544
    @tamaldas3544 7 лет назад

    thanks for this beautiful tutorial....

    • @mdmahedihassan2444
      @mdmahedihassan2444 3 года назад

      Hi, can you please tell me,
      in which software he wrote the code

  • @xXConstancex
    @xXConstancex 5 лет назад

    Hi! Thanks for the guide. Do you have a guide to help with putting a label to the person in front of the webcam?

  • @arjunkm3031
    @arjunkm3031 8 лет назад

    Hey Harrison. The face detection part is really nice. Is there any way to detect emotions from an image??

  • @ayushagarwal69
    @ayushagarwal69 3 года назад

    so funny when he says " my mouth is also probably an eye " XD

  • @ACArguson
    @ACArguson 5 лет назад

    Nice video tutorial. I was hoping if you could give an advise a new method on how to detect rules of thirds on a photograph using OpenCV? Thanks in advance.

  • @toantruong9203
    @toantruong9203 7 лет назад

    Love it bro, thanks u very much!

  • @redaabdellahkamraoui7325
    @redaabdellahkamraoui7325 6 лет назад

    you're THE MAN !!!!

  • @anupamyedida5484
    @anupamyedida5484 8 лет назад

    really good video man ! Keep it up !!! :)

  • @medicharlaabhijeet2055
    @medicharlaabhijeet2055 2 года назад

    Hi,
    I have done plant detection using ur method it worked well.
    Now I'm trying to do bottle detection
    But it doesn't recognise bottles
    Can u help me with taking the best suitable data set for it, i have tried many possible ways but didn't get results.

  • @kevinvidzzz5393
    @kevinvidzzz5393 7 лет назад

    You don't wanna find "eyes" outside of a "face" . . . . very funny stuff

  • @darshanshanbhag
    @darshanshanbhag 5 лет назад

    thank you so much it was very helpful

  • @urs_rkm
    @urs_rkm 8 лет назад

    nicely done! i have a question,How to locate landmarks on face using opencv python?

  • @sumedhaagarwal7890
    @sumedhaagarwal7890 8 лет назад

    Hey Sentdex,
    I have been working on a project for detecting traffic signs and I was wondering how many negatives and positives will suffice?
    Any source for getting the negatives?

  • @PhDdronerobotlab
    @PhDdronerobotlab 8 лет назад

    Thanks a lot men.! It works ..!

  • @vineetkumar2396
    @vineetkumar2396 7 лет назад

    Great help, thank you very much. Can you suggest how to detect pupil using the same method?

  • @piyushchoudhary4923
    @piyushchoudhary4923 6 лет назад

    You are awesome man

  • @vasusharma1192
    @vasusharma1192 5 лет назад +1

    Why did you take y co-ordinate first in roi_gray and roi_color...

  • @kuldeepchaturvedi1894
    @kuldeepchaturvedi1894 7 лет назад +2

    it's not showing the rectangle why? :( please help about that i am using Ubuntu...

  • @WHITE444YT
    @WHITE444YT 6 лет назад +2

    how to add filter like dogs .. like snapchat ?

  • @learnshare382
    @learnshare382 6 лет назад

    I m 3D Artist working as a Level designer, I m really new to coding and have only a bit knowledge on C# which I tried to learn once working in Unity3D.
    I just wanna make an app for both mobile and desktop-like lensKart or other latest selfie camera App like tracking face and placing goggles or some object in it. Kindly Let me know where should I start when this tutorial helps.
    Because I have some confussion like what camera you using to recognise any special or general Webcam while u testing and First most thing the software that which I need to develop my need.
    Thanks in advance.

  • @rosyluo7710
    @rosyluo7710 7 лет назад

    It works! Thanks !!

  •  7 лет назад

    can it determine different ppl or that just that they all have faces? i want to identify with face recognition for home automation?

  • @winecheese2185
    @winecheese2185 8 лет назад

    you are a geniussssss

  • @vikingsraven
    @vikingsraven 8 лет назад

    cheers for doing these videos, its making sense now. got a problem with the xmls though, it keeps saying file should start

  • @burhansancakl351
    @burhansancakl351 5 лет назад +1

    5:03 there is some nice drum going on in the background :D

    • @00ShiNoda
      @00ShiNoda 5 лет назад

      müptezel cihat nikiyle python tutorialı izlemek baya sıradışı bi olay reis fdsfad

  • @thankgodezeoffor8376
    @thankgodezeoffor8376 5 лет назад

    Hi, where can i get the full playlist for OpenCV. Amazing video by the way

  • @ridahamid247
    @ridahamid247 5 лет назад

    Very useful tutorial. Do you know any tutorial for insects detection

  • @alejanserna
    @alejanserna 8 лет назад +2

    Thanks for the video, amazing!
    My question is why did you apply faces to the gray image? why not to the color img?
    why did we do the cvtcolor to gray?
    Thanks

    • @sentdex
      @sentdex  8 лет назад +1

      +Alejandro Serna allowing there to be colors means exponentially far more variables

    • @brainbeantechnolabs8648
      @brainbeantechnolabs8648 7 лет назад

      Does it affect on result! ????

    • @sentdex
      @sentdex  7 лет назад +9

      Try it and find out. See what happens. That's how you learn.

    • @naghechebilal7269
      @naghechebilal7269 6 лет назад +1

      i think that the gray scale image means less data processed

    • @jean4j_
      @jean4j_ 5 лет назад

      @@naghechebilal7269 Colored images have 3 channels (R,G,B), gray images only have one.
      Using gray images makes the problem easier and the computation faster.

  • @moritzpainz1839
    @moritzpainz1839 4 года назад

    hi, i have an understanding problem with this code.
    with the following code:
    for (ex, ey, ew, eh) in eyes:
    cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey+eh),(0,255,0),2)
    with this code we draw every eye(s) detected on the roi_color, since the first parameter is the image we draw our rectangle on.
    At the end we say cv2.imshow("img", img). Now with which line do we say draw the eyes on this img that we later show??
    Great video and greedings from germany

  • @Am3r1Kan0
    @Am3r1Kan0 8 лет назад

    Hello, this video was very helpful and it works great, but I'd just like to ask you if there is any possible way to detect when you close your eyes. I'm trying to write a sleep detection program that sends a signal to the user when he is falling asleep, and I've been having an issue when trying to detect when the eye is closed.
    Thank you

  • @yanlidong519
    @yanlidong519 5 лет назад +1

    Thanks for your wonderful videos!
    I have one question: why convert img to gray? I change faces = face_cascade.detectMultiScale(gray) to faces = face_cascade.detectMultiScale(img), still work. So, I think we don't need convert. Am I right?

    • @burhansancakl351
      @burhansancakl351 5 лет назад

      its probably faster

    • @andreivilla9009
      @andreivilla9009 4 года назад

      Yup makes it faster because there are less color channels (rgb is three, grayscale is one) to process.

  • @joojoo1020
    @joojoo1020 5 лет назад

    Hi,
    Thank you for your wonderful work.
    What would be the "BEST" camera to get for this type of projects? Is it the more resolution the better? What do you recommend under $45

  • @vnctomato3723
    @vnctomato3723 4 года назад

    Thank you bro for this tutorial is there any way to show the confidence level of the detection?

  • @ShirazHazrat
    @ShirazHazrat 8 лет назад

    Great video. I laughed.

  • @jakerember
    @jakerember 8 лет назад +2

    Haarcascades are hard! Haar haar haar.
    Anyways, would it be possible to go from tracking the eye to where the is pupil within the eye (like what you did with going from tracking the face to tracking eyes within the face)? If so, is it then possible to pull out information on where the gaze is? I was thinking if you can get the position of the pupil, it may be possible to calibrate that information to a screen position and have something of a rough eye tracker without $30,000 of research software and hardware.
    Anyways, great video!

    • @sentdex
      @sentdex  8 лет назад +1

      +Jake Rember Great question. It would seem to me, logically, that you could indeed do this to track gaze. I'd personally detect the eye region, then detect the center of the pupil region. From there, assuming your eye center and pupil centers were indeed correct, you could draw a line between them and continue out to get the gaze.

    • @jakerember
      @jakerember 8 лет назад +1

      +sentdex I was thinking about how you would clean up the data from this as well. I was thinking maybe add in a statement which evaluated a certain amount of deviance per frame and would ignore anything outside of that threshold. That way, if you calibrated/started with the eyes and face, and assuming the person was not moving too fast, one could decrease the jitter of the face and eyes in the video feed.
      It is all pretty exciting to me, once I have time, I think I may take a crack at trying to make a simple eye tracker and see if valid data can be gathered from it. Like say, mapping where a person is looking to a location on a screen. It would be very convenient for looking at the effectiveness of an application or webpage! It could also be a great tutorial (nudge, nudge :p). Thank you for your reply!

    • @goodn1051
      @goodn1051 6 лет назад

      did you make the eye tracker code

  • @ZeroTwoTwoFive
    @ZeroTwoTwoFive 4 года назад

    Hi I am using IPython and Jupyter notebook to run the code. But the video streaming and detection is very slow. Any idea what might be the issue?

  • @anilgurung641
    @anilgurung641 5 лет назад

    nice tutorial. How would you write a text('face_detected') on the screen when face is detected. Under 1st forloop, i tried like (if w>0): then cv2.putText....., but didn't work. Any suggestions?

  • @different2261
    @different2261 7 лет назад

    Wow ! Is it possible to "log in" with facial recognition ? so I can unlock my session just with my face ?

  • @MohsinKhan-ve1hn
    @MohsinKhan-ve1hn 6 лет назад

    Could you please tell me which opencv version and which environment you are using ?

  • @premrajs683
    @premrajs683 5 лет назад

    We are using stretch and VNC viewer, our videos are having very low frame rates and has about 3 seconds latency, will remote desktop reduce the latency

  • @hassainehassen5700
    @hassainehassen5700 4 года назад

    Thank you so much

  • @Afterschooltime
    @Afterschooltime 7 лет назад

    Hi Sentdex, is there any way to detect the forehead with OpenCV ? I want to crop the forehead after the image is captured.

  • @kayc170
    @kayc170 8 лет назад +3

    Thanks for this video. How can I also get to track the eye gaze itself ?

    • @LetCode96666
      @LetCode96666 6 лет назад +1

      bro! I also want to detect gaze ! can we talk ?

    • @WHITE444YT
      @WHITE444YT 6 лет назад +1

      lol bro did you know how to add image in the eye like i want to add glasses (like snapchat) please answer me in quicktime and thank you