Gathering Images for Haar Cascade - OpenCV with Python for Image and Video Analysis 18

  Рет қаралды 132,296

sentdex

sentdex

8 жыл бұрын

In this tutorial with Python and OpenCV, we continue to learn how to create our own Haar Cascades for object detection. We make use of image-net to gather relevant images.
Text-based tutorial and sample code: pythonprogramming.net/haar-ca...
Digital Ocean Server: www.digitalocean.com/?refcode...
pythonprogramming.net
/ sentdex
/ pythonprogramming.net
plus.google.com/+sentdex

Пікірлер: 99
@tox0tes
@tox0tes 8 жыл бұрын
it's a shame your videos have so few views. you have a gift for teaching and explaining things in an intuitive way, and i bet a lot of people could benefit from all this content you have produced.
@sentdex
@sentdex 8 жыл бұрын
+tox0tes Thanks for the kind words!
@ekbastu
@ekbastu 7 жыл бұрын
i ditto what toxotes has said, m loving your work too
@zakariaabderrahmanesadelao3048
@zakariaabderrahmanesadelao3048 4 жыл бұрын
been a follower of Sentdex for nearly 2 years. This guy is a hardworking honest youtuber. He has introduced me to ML and most of the knowledge I have about python is thanks to him. he asks for nothing in return but we have to be show gratefulness by liking and sharing his content for the benefit of all. Thank you sentdex you mean a lot to us.
@allolola4736
@allolola4736 6 жыл бұрын
Your way to explain is awesome, we feel that you want to share knowledge BECAUSE we have it at the end, in a good manner
@sugandichow5739
@sugandichow5739 6 жыл бұрын
Thanks to your video I have successfully done the task!!
@justchill99902
@justchill99902 6 жыл бұрын
Awesome tutorials. Thank you so much. Dumb update but if anyone is trying to copy the code from the website, don't forget to call the function 'store_raw_images()' at the end.
@christaylor8142
@christaylor8142 5 жыл бұрын
Thank you, you make learning easy. Keep doing what you do best :)
@neocephalon
@neocephalon 4 жыл бұрын
Very neat method for retrieving images!
@techwithimad4672
@techwithimad4672 8 жыл бұрын
I would like to thank you for your nice tuto.. I'm french but i understand by making an effort ! keep going !
@sentdex
@sentdex 8 жыл бұрын
+Salki Imad Happy to share!
@galinastaneva2019
@galinastaneva2019 8 жыл бұрын
Great tutorial!
@muhammadabraranwar7600
@muhammadabraranwar7600 7 жыл бұрын
This is really helping buddy, keep it up. Those, using python 2.7. Just import urllib and remove request from urllib.request.urlopen . (remove request) just write urllib.urlopen urllib.request.urlretrieve (remove request) urllib.urlretrieve
@afshananwarali9462
@afshananwarali9462 7 жыл бұрын
thankyou :)
@ujwalkaka
@ujwalkaka 7 жыл бұрын
i tried but it isnt working
@franciscoceballos9773
@franciscoceballos9773 7 жыл бұрын
Might be obvious but just in case, if you copied the code from the webpage he provides, two things: 1. The URL for imagenet is missing http. 2. The code only defines the function, if you want to actually run it you need to add at the end: store_raw_images().
@vinayvikram2999
@vinayvikram2999 7 жыл бұрын
If you didn't know man ,,then don't share wrong information...u just waste my time ...
@agh212
@agh212 6 жыл бұрын
Hi, when I try to run the script again for a second link of negative images, I get the following error: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 4906: ordinal not in range(128)" Below is my script: import urllib import cv2 import numpy as np import os def store_raw_images(): neg_images_link = 'image-net.org/api/text/imagenet.synset.geturls?wnid=n02761392' neg_image_urls = urllib.urlopen(neg_images_link).read().decode() if not os.path.exists('neg'): os.makedirs('neg') pic_num = 1419 for i in neg_image_urls.split(' '): try: print(i) urllib.urlretrieve(i, "neg/"+str(pic_num)+".jpg") img = cv2.imread("neg/"+str(pic_num)+".jpg", cv2.IMREAD_GRAYSCALE) resized_image = cv2.resize(img, (100, 100)) cv2.imwrite("neg/"+str(pic_num)+".jpg",resized_image) pic_num += 1 except Exception as e: print(str(e)) store_raw_images() ______________________ Anybody know why the error happens? :( Thanks in advance
@ujwalkaka
@ujwalkaka 7 жыл бұрын
could you please tell how is it done for python 2.7? i've a lot of methods but none of them is working
@rverm1000
@rverm1000 4 жыл бұрын
Yes you do good videos
@trashgodz42069
@trashgodz42069 4 жыл бұрын
you a real g my dude
@arshitchabukswar9741
@arshitchabukswar9741 6 жыл бұрын
Some of my images are getting converted to grayscale and to 100 x 100 and many are not. What could be the issue?
@asha5410
@asha5410 7 жыл бұрын
amazing video as always if anyone struggling with urllib.request.urlretrieve hanging I replaced urllib.request.urlretrieve(i, "neg/"+str(pic_num)+".jpg") with f = open("neg/"+str(pic_num)+".jpg", 'wb') f.write(urllib.request.urlopen(i, timeout=5).read()) f.close()
@adeelzaidi99
@adeelzaidi99 5 жыл бұрын
Hi! I saw your this tutorial and its really awesome. The problem is that image-net.org is down since few months. Can you suggest its alternative so that the code may work
@yogeshmodi3578
@yogeshmodi3578 7 жыл бұрын
Hlo sentdex your tutorials a awsom open cv is a very nic platform loved it Thanks for the Tutorial.. Bdw i had a Doubt .. do we have to save the +ve and -ve images in the same directory of diffrent...
@vjp2866
@vjp2866 5 жыл бұрын
Thank u so much
@AlchemyAperture
@AlchemyAperture 7 жыл бұрын
Hey Thanks For The Tutorial I need help regarding image matching ( match a image to dataset utilizing surf and flann (python open cv )) Is their any efficient way to do that
@nouranabdel-ghany6764
@nouranabdel-ghany6764 7 жыл бұрын
Hey, thank you so much for the tutorials it really helpful i would like to ask you if we can make recognition without using that server. our graduation project needs to detect the illness of the green leafs so we need to know how to make our own cascade but without using that server or if there is another free server :D thanks in advance...
@shantanughosh3092
@shantanughosh3092 7 жыл бұрын
What should be put inside decode? If I put decode(), it gives an error. So i tried to do some research and wrote decode('utf-8'). But it works very slow. It took almost 2 hours for downloading ~160 images. NEED HELP!!!
@nilsaha8021
@nilsaha8021 5 жыл бұрын
Hello, Needless to say that, I am enjoying your tutorials very much. I have got a problem. I run the script you used for this tutorial. However, the storing of images is stopping at different points. I run the script multiple times but stopped storing at after 8, 10, 16, 48(max) images, even though the script seems running. Does anyone has any suggestion to overcome this issue?
@godofyouruniverse
@godofyouruniverse 5 жыл бұрын
Great series! These have helped a LOT...! Like tox0tes said...you're a great teacher. In regards to this video - I'm having issues with the downloads. Images that are no longer hosted quickly show as a 404 error, the code automates the download of the "This photo is no longer available" icon (which you go over how to get rid of in the next vid, I believe) and the code moves on to the next URL. However, some of the images are still hosted on what appear to be the world's slowest servers lol Is there a "timeout" function that could be added to this script, so if the download takes longer than, for example, 30 seconds, the script would cancel that download and move on to the next URL? I've been stuck on image 572 of a 1932 image synset for close to 15 minutes, and I'm too new to Python to know how to make the code move on! I'm using Python 3.7.0 64bit, OpenCV 3.4.2, on Windows 7 64bit, with PyCharm 2018.2.1 running the code. Thanks!
@HistyMythyLord
@HistyMythyLord 7 жыл бұрын
In neg folder only one image is being made.. I'm using the latest python ver, what could be the reason and thanks for these videos !
@dhruvshah2491
@dhruvshah2491 7 жыл бұрын
hello.. some images are stored colored without resized also some are get resized i have no idea what's going on....
@Paavo1991
@Paavo1991 6 жыл бұрын
Image-net does not respond or respond very slowly... result: "urllib.error.URLError: "
@jerrycheechee4530
@jerrycheechee4530 7 жыл бұрын
Hi Harrison, I'm new to your videos and i found it awesome as you presented well :). I wonder if you can post tutorials about stereoscopic vision to make object detection and distance measurement. It's really helpful to my FYP. Hope you can teach me. Thanks in advance :D
@saikrishna9812
@saikrishna9812 5 жыл бұрын
Aren't we Saving images twice (one while URL retrieving and other time with cv2.imwrite ) ?
@cristianvasluianu
@cristianvasluianu 6 жыл бұрын
Hey Sentdex I want to know why you need to use a Linux server and I want to know if I can use my Mac to generate a haar cascade.
@tengkianen
@tengkianen 3 жыл бұрын
imagenet links not working anymore after they updated the site, are there any other alternatives to grab thousands of negative images efficiently?
@MrMichael2484
@MrMichael2484 5 жыл бұрын
Doing God's work!
@positivechange7116
@positivechange7116 6 жыл бұрын
I am working on face recognition model , I made it through haar cascade model but it does not give accurate result. What changes I have to do ? Please someone help
@agamdwivedi5799
@agamdwivedi5799 6 жыл бұрын
What python version do we need to use, Python2 or 3?
@Harsh-pf4mq
@Harsh-pf4mq 5 жыл бұрын
can you tell me how to detect objects and faces using keras with labels using any of the existing neural network architechture available
@jhonatansouza6500
@jhonatansouza6500 6 жыл бұрын
How can I do in a database that I have from my computer instead of url?
@duongphuoc9200
@duongphuoc9200 5 жыл бұрын
When I run program, it gets pictures so long because the urls are unreachable, so I want to pass the death urls, I try to program but it doesn't work. Does anybody help me?
@arvindvish2588
@arvindvish2588 3 жыл бұрын
Get "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte" error in " neg_img_url = urllib.request.urlopen(neg_img_link).read().decode() " line.....please help
@wandersonslash
@wandersonslash 7 жыл бұрын
Hi, I have urllib3 module installed. How do I adapt this code?
@omi4508
@omi4508 8 жыл бұрын
Hi, hey man i have a doubt if i have to detect face on cartoons , how do you think i should proceed.
@digvijaysingh6332
@digvijaysingh6332 7 жыл бұрын
hello, I am creating face recognition system using tkinter and opencv , I need in help in creating xml file for each person so that I can load the XML file on the basis of faceid that I will give. I try this but XML file give wrong result
@as269
@as269 5 жыл бұрын
loca variable pick_num referenced before assignment. ?? this error i face any help and thanks alot
@nenukou.615
@nenukou.615 7 жыл бұрын
I have a doubt, how did you pass the images to negative?
@aguspray
@aguspray 5 жыл бұрын
i was build folder 'neg', but there is no images
@DoNotFlyINsideOUT
@DoNotFlyINsideOUT 8 жыл бұрын
Would the negative images essentially work for any other item? for example if i am detecting a microphone then the negs could still be sport images or would that not work?
@sentdex
@sentdex 8 жыл бұрын
+Samuel Bigio negative images can be anything but the item. So, yes.
@DoNotFlyINsideOUT
@DoNotFlyINsideOUT 8 жыл бұрын
+sentdex awesome I'm in the process of trying to train a 'payload' it's actually a pvc pipe but it's rectangular and I'm afraid that the 50x50 has a lot of whitespace around my picture because it's about 5 times as long as it is wide. Would it be okay to make the pos something like 10x50?
@ashutoshsatapathy2477
@ashutoshsatapathy2477 3 жыл бұрын
How can I access multiple images and do face recognjtion of each image?
@shivam90100
@shivam90100 5 жыл бұрын
Sir, how can we install cv in python3 on raspberry pi?
@elifbalc5090
@elifbalc5090 6 жыл бұрын
helping video as ussual but i have problem understanding what does this code do : if not os.path.exists('neg'): os.makedirs('neg') and what we do with the server .
@Paavo1991
@Paavo1991 6 жыл бұрын
If there is no folder named 'neg' it creates one :)
@omeraltuntas6248
@omeraltuntas6248 5 жыл бұрын
merhaba :) Anladıgım kadarıyl bu kod belirtilen dosya yolunda 'neg' adlı klasor olusturur. As far as I understand , that code create a folder named 'neg' in the directory
@Gabo_1457
@Gabo_1457 5 жыл бұрын
Have problem with urllib module......... Python 3...... RAspberry....
@boukbabmhamed7865
@boukbabmhamed7865 5 жыл бұрын
i had this issue any help plz *** Error in `opencv_createsamples': corrupted size vs. prev_size: 0x000055d319b4c4f0 ***
@kathan.1995
@kathan.1995 8 жыл бұрын
will you please make a tutorial video for identify the objects for example a man wearing a watch the script are identify the watch and print the name of object that is watch will you please do that in python???
@SomeBud
@SomeBud 6 жыл бұрын
mine never gets the pictures just stops here is the response after running the file Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> RESTART: C:\Users\Home\Documents\opencv_workspace\download-image-by-link.py >>> a reply would really be appreciated
@MichaelTsimmerman
@MichaelTsimmerman 5 жыл бұрын
ammm did you call the function... it seems like it worked without any errors
@lifequotes424
@lifequotes424 6 жыл бұрын
Help me this error given in python3 ubuntu
@marianina8
@marianina8 6 жыл бұрын
what tool do you use to show your code and your webcam? Btw will have to +1 the comment on top by tox0tes as well! you're a great teacher! :)
@amu13160
@amu13160 7 жыл бұрын
value of pic_num is not increasing but it is overwriting the existing image, help !!
@TurkishLoserInc
@TurkishLoserInc 7 жыл бұрын
Make sure you use pic_num+=1, not just =1
@hang0401
@hang0401 5 жыл бұрын
Great tutorial. I've been watching your image processing with openCV tutorials and I'd just want to say they are far superb than other tutorials online. I'd just want to improve your code a little bit so you can read multiple url links and save all the images all at once instead of replacing the link once the first grab link is completed. #!/usr/bin/python3 import urllib.request import cv2 import numpy as np import os def store_raw_images(): neg_images_links = ['linkA', 'linkB', 'linkC'] for link in neg_images_links: neg_image_urls = urllib.request.urlopen(link).read().decode() pic_num = len(os.listdir('neg/'))+1 if not os.path.exists('neg'): os.makedirs('neg') for i in neg_image_urls.split(' '): try: print(i) urllib.request.urlretrieve(i, "neg/"+str(pic_num)+".jpg") img = cv2.imread("neg/"+str(pic_num)+".jpg",cv2.IMREAD_GRAYSCALE) #~ should be larger than samples / pos pic (so we can place our image on it) resized_image = cv2.resize(img, (300, 300)) cv2.imwrite("neg/"+str(pic_num)+".jpg",resized_image) pic_num += 1 except Exception as e: print(str(e)) if __name__ == '__main__': store_raw_images()
@KrishnaThiruvengadam2015
@KrishnaThiruvengadam2015 6 жыл бұрын
Not able to locate neg folder, where all images are saved
@hang0401
@hang0401 5 жыл бұрын
Make sure you parse in the correct path to your folder.
@javierarredondo8871
@javierarredondo8871 5 жыл бұрын
error in name name_image_urls is not defined... help meee!!!!
@MichaelTsimmerman
@MichaelTsimmerman 5 жыл бұрын
a Typo. if you are using python 3
@freddysalazar9428
@freddysalazar9428 6 жыл бұрын
Looks like the links are down #Sad
@Paavo1991
@Paavo1991 6 жыл бұрын
The worst is the image-net looks down or works very laggy..
@davidpierre3821
@davidpierre3821 5 жыл бұрын
@@Paavo1991 Do a new search on image-net.org for the same objects (watch and people) and you will have new working links from them. I had the same problem
@arizalzanuarrisqi11
@arizalzanuarrisqi11 6 жыл бұрын
@sentdex hello sir, i try run the gathering image program on ubuntu using command python3 download-image-by-link.py but there is nothing happend, the program not running? how to run it on ubuntu ??
@k01db100d
@k01db100d 7 жыл бұрын
6:28 so dirty!
@Maffoo
@Maffoo 6 жыл бұрын
Kinda overkill to use python for this, you could just do it with a really simple bash one-liner: for image in `curl yoururl`; do curl --connect-timeout 2 -m 5 -O ${image%$' '}; done
@n3gn3g12
@n3gn3g12 4 жыл бұрын
Hi, Thanks a lot for your fantastic tutorial. I tried to follow your instruction to create a Haar Cascade Classifier. However, I have some issues with opencv_createsamples on my mac. It errors out (Segmentation Fault). I was wondering if you could let me know how I can resolve my issue. I use Mac OS Catalina and OpenCV version 3.4.9 (I used an older version since it still has opencv_createsamples). I also asked my question here: stackoverflow.com/questions/60805577/opencv-createsamples-errors-out-segmentation-fault-11 Thanks!
@harikarthika
@harikarthika 7 жыл бұрын
HI ,I have a requirement where I need to find if the images of a particular animal is matching or not with the positive .Can you please guide me on the same .If you can share me your email address I can quickly send some details on the same
@lakshyanegi668
@lakshyanegi668 5 жыл бұрын
I am smarter than you computer...lol....
1 класс vs 11 класс (неаккуратность)
01:00
Omega Boy Past 3 #funny #viral #comedy
00:22
CRAZY GREAPA
Рет қаралды 36 МЛН
Letting GPT-4 Control My Terminal (TermGPT)
23:12
sentdex
Рет қаралды 74 М.
AI Weed Detector
5:37
Immersive Limit
Рет қаралды 48 М.
Video Data Processing with Python and OpenCV
32:05
Rob Mulla
Рет қаралды 66 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 714 М.
1 класс vs 11 класс (неаккуратность)
01:00