OpenCV Python Tutorial For Beginners 25 - Detect Simple Geometric Shapes using OpenCV in Python

  Рет қаралды 91,811

ProgrammingKnowledge

ProgrammingKnowledge

Күн бұрын

Пікірлер: 71
@TheNightFox919
@TheNightFox919 4 жыл бұрын
For anyone wondering: the parameter epsilon in the method approxPolyDP represents the maximum distance between the shape and the approximation. If epsilon = 0 then the approximation will be really precise. But the bigger epsilon gets, the further you allow your approximation to be less rigorous, and an epsilon that's too big will simply not detect shapes properly. Trying the code as it is in the video on some random shapes image I found on google, I get that 0.01*cv2.arcLength(contour, closed=True) is actually an approximation that's "too good" (as in it'll try and draw more than 3 edges on a triangle). I put epsilon = 3 and it seems to do the job fine. Depending on what you're coding and how precisely you want to detect, play around with the epsilon value.
@BipinJethwani
@BipinJethwani 2 жыл бұрын
You're awesome. Your Github Gist works
@Its-Not-Funny
@Its-Not-Funny 4 жыл бұрын
We can also use width == height instead of using aspect ratio, it will work as same as the ratio and it is simple to understand. (If w == h: "square")
@theearthish
@theearthish 4 жыл бұрын
I think aspect ratio is used so that it takes care of any error in the boundingRect method
@haastrupadebayoibukun6817
@haastrupadebayoibukun6817 2 жыл бұрын
@@theearthish The aspect ratio was used because of the noise. Under normal situation, the width and height of a square is the same, in that situation the aspect ratio will be 1.
@lewlew212
@lewlew212 Жыл бұрын
If with the above problem, I want to identify parallelogram, what should I do? Looking forward to your support. Thank!
@Ironslayer423
@Ironslayer423 4 ай бұрын
How can we detect something which is combination of two or more geometries, like an arrow?
@LaurinusPonpon
@LaurinusPonpon 5 жыл бұрын
Can't wait the next one!
@chapaalejandro90
@chapaalejandro90 5 жыл бұрын
where do I find the shapes.jpg file? I could not find it in OpenCV github
@JJVR10
@JJVR10 5 жыл бұрын
I did it using paint. It took me 2 min. All the shapes are there.
@saipatil2462
@saipatil2462 3 жыл бұрын
Hello. Can you please tell how can we detect the same in live video.
@parthasaha4174
@parthasaha4174 3 жыл бұрын
Can you help me with the "trackbar" to find the threshold values?
@JalalKhan-we1th
@JalalKhan-we1th 3 жыл бұрын
Will this python program work in real time geometric shapes detection.??
@xueyuanye
@xueyuanye 2 жыл бұрын
where could I download the shapes.jpg for testing? Thanks a lot
@memonaijaz5429
@memonaijaz5429 5 жыл бұрын
How to get there x,y coordinates values
@shivakumark4275
@shivakumark4275 3 жыл бұрын
I'm getting error in line 5 .. Should I need to save the 'shapes.jpg' to a specific path?
@reealtech_xr
@reealtech_xr 3 жыл бұрын
you need to enter the full path with image name and extension. Example: "E:/saurabh/image/shape.jpg"
@shivakumark4275
@shivakumark4275 3 жыл бұрын
@@reealtech_xr thanks bro ❤
@henokadisumebratu7268
@henokadisumebratu7268 4 жыл бұрын
do you have a live version of this which can detect from webcam , please
@heyawaltuh
@heyawaltuh 3 жыл бұрын
cap = cv2.VideoCapture(0)
@rio2414
@rio2414 5 жыл бұрын
can i use this for movement shapes
@memonaijaz5429
@memonaijaz5429 5 жыл бұрын
How can i get there x,y coordinates values?
@SigmaLiving
@SigmaLiving 4 жыл бұрын
Did you ever solve this?
@ndsingh2368
@ndsingh2368 4 жыл бұрын
any luck in getting shapes x, y coordinates?
@gurakashsidhu8256
@gurakashsidhu8256 2 жыл бұрын
Hi guys I was just wondering if I could use this code for nuts shape classification and detection? any help is appreciated.
@danielmeireles1
@danielmeireles1 3 жыл бұрын
Thanks for sharing!
@surajveertalreja9438
@surajveertalreja9438 4 жыл бұрын
what if the object is a vehicle or plant? we can definitely identify them but how can we name it? like we used 3 sides for triangle and so on. What can be the logic to name car and say cactus?
@kumarabhishek5652
@kumarabhishek5652 4 жыл бұрын
maybe car would fall in the category of trapezoid.
@theearthish
@theearthish 4 жыл бұрын
That falls under object recognition
@jun2705
@jun2705 4 жыл бұрын
Thanks for this great video!
@fun-ih5sc
@fun-ih5sc 4 жыл бұрын
Can anybody tell me why it is multiplied with "0.01" at 5:40 ,Line no: 10. I was liking his way of explaining things but totally disappointed now. Not explaining basic only -_- 👎
@shubhambagdare6600
@shubhambagdare6600 4 жыл бұрын
Did u listen to the whole thing? The closer your epsilon value is to 0, the more precise is your approximation of the curve and so your shape will be detected more precisely. Learn to listen.
@adityaanand5686
@adityaanand5686 4 жыл бұрын
@@shubhambagdare6600 Did u listen to the whole thing? Where it is mentioned "The closer your epsilon value is to 0, the more precise is your approximation"?? Btw thanks for clearing my doubt.
@rishabhkumar8415
@rishabhkumar8415 3 жыл бұрын
@@adityaanand5686 You are fool someone is helping you and you are giving reply to him in negative way instead of Say Thanks
@பி.அம்ரித
@பி.அம்ரித 5 жыл бұрын
sir what is the aspect ratio for rectangle because i want do for trapozoids also...!
@venur8153
@venur8153 4 жыл бұрын
Can u know aspect ratio of rhombus?
@TrungNguyen-tm6fd
@TrungNguyen-tm6fd 4 жыл бұрын
great. Thank you for this video.It helped me a lot.
@kamathprajna
@kamathprajna 3 жыл бұрын
Does it works
@dandavatisuhas5428
@dandavatisuhas5428 4 жыл бұрын
how to detect the color of a simple shape in opencv ? could you please give me any references?
@mihirsrivastava2460
@mihirsrivastava2460 4 жыл бұрын
You here for eyrc?
@hardikkamboj3528
@hardikkamboj3528 3 жыл бұрын
@Dandavati You can change the image to HSV, and then use value of Hue to detect the color.
@saifaldeenal7451
@saifaldeenal7451 5 жыл бұрын
Thanks a lot, wonderful!
@sethwhite4155
@sethwhite4155 4 жыл бұрын
I can't find the shapes image. Help?
@btigenie
@btigenie 4 жыл бұрын
No matter what I try, I get the error - "too many values to unpack (expected 2)" on the countours definition line. I am running directly from the repo and with the downloaded image file noted in comments.
@abdeldjalilettaharboucetta2238
@abdeldjalilettaharboucetta2238 4 жыл бұрын
i think you run it in python 2 not 3 or you didnt upgrade the version of opencv
@Its-Not-Funny
@Its-Not-Funny 4 жыл бұрын
It is because , the findContours will give 2 outputs. May be you are giving like (contours = cv2.findcontours(" ") ). You have to give like( contours, _ = cv2. ........).
@beatrizaubele369
@beatrizaubele369 3 жыл бұрын
Try with "_, contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)" Too late but it can probably help someone in the future.
@venur8153
@venur8153 4 жыл бұрын
How to find colour of the shapes? Can anyone help
@RiteshNEVERUNIFORM
@RiteshNEVERUNIFORM 4 жыл бұрын
Are you from Nirikshuk bot ?
@venur8153
@venur8153 4 жыл бұрын
@@RiteshNEVERUNIFORM yeah
@venur8153
@venur8153 4 жыл бұрын
@@RiteshNEVERUNIFORM I sort out this one but I am struggling in task _b
@pranitham1586
@pranitham1586 4 жыл бұрын
Did this code help u to solve nirishuk task 1
@abdeldjalilettaharboucetta2238
@abdeldjalilettaharboucetta2238 4 жыл бұрын
hi thanks for the tutorial can you tell us how we can do it in real time ? not just for an image ,and thank you
@nikhilrizal3729
@nikhilrizal3729 4 жыл бұрын
What does ravel does
@Its-Not-Funny
@Its-Not-Funny 4 жыл бұрын
As per my knowledge , ravel will give the starting point of contour draw in img pixel. So x will give x- coordinate Y- gives y coordinate.
@kamathprajna
@kamathprajna 3 жыл бұрын
@@Its-Not-Funny do this code works
@RahulKumar-tl4dv
@RahulKumar-tl4dv 5 жыл бұрын
Thanks for video
@pedramtehranchi9653
@pedramtehranchi9653 5 жыл бұрын
Thanks a lot
@shashanksharmadon4295
@shashanksharmadon4295 4 жыл бұрын
thanks bro......
@InfoPOLRES
@InfoPOLRES 3 жыл бұрын
You saved me woahhhhh from pepe's fury
@puturoi
@puturoi 4 жыл бұрын
неужели нельзя приложить файл с этой е.бучей картинкой?
@karishmatyagi3585
@karishmatyagi3585 4 жыл бұрын
Instead of displaying the shape name once, it shows multiple times. Anyone faced the same issue?
@HK-ct1tg
@HK-ct1tg 4 жыл бұрын
I faced the same issue. Did you find a solution for it ?
@rishi2405
@rishi2405 4 жыл бұрын
I had that too, the reason for mine was i didn't use elif for the other if statements after the first one
@gauninha12
@gauninha12 4 жыл бұрын
Im also facing this problema, and im using elif statements though
@kamathprajna
@kamathprajna 3 жыл бұрын
@@gauninha12 help??how?
@sushrutkenkre105
@sushrutkenkre105 Жыл бұрын
Reduce the threshold. It is working perfectly after reducing. I changed mine from 240 to 225.
@NiteshGupta-jr6ib
@NiteshGupta-jr6ib 5 жыл бұрын
there are way too many ads in between.
@austinyan1616
@austinyan1616 4 жыл бұрын
You're only reading through the code. Total waste of time.
@HM-cw8im
@HM-cw8im 4 жыл бұрын
Have you watched the previous videos? Most of the functions are explained there.
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Detect Simple Geometric Shapes using OpenCV in Python شرح عربي
16:47
28 - Thresholding and morphological operations using openCV in Python
20:31
Image Processing with OpenCV and Python
20:38
Rob Mulla
Рет қаралды 188 М.
How to use Bounding Boxes with OpenCV (OCR in Python Tutorials 03.02)
18:27
Python Tutorials for Digital Humanities
Рет қаралды 53 М.
Tracking Objects | OpenCV Python Tutorials for Beginners 2020
18:28
Murtaza's Workshop - Robotics and AI
Рет қаралды 130 М.
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН