Real time Shape Detection using Contours [9] | OpenCV Python Tutorials for Beginners 2020
HTML-код
- Опубликовано: 19 июн 2024
- In this video, we will learn how to detect the shapes of objects by finding their contours. Contours are basically outlines that bound the shape or form of an object. So we will be detecting multiple shapes and how many corners points each shape has along with its area.
🚀🚀 My Urdu/Hindi AI RUclips Channel 🚀🚀
/ @murtazahassan01
Code & Complete Course:
The stack image function can be found in Chapter 6.
www.computervision.zone/cours...
Premium Courses:
✔️ Computer Vision Game Development Course:
bit.ly/3ttLZ2s
✔️ Computer Vision with Arduino Course:
bit.ly/3wzLB4m
✔️ Advanced Drone Programming Course:
bit.ly/3qs3v5g
✔️ Learn to Build Computer Vision Mobile Apps:
bit.ly/3uioY1J
✔️ Jetson Nano Premium Course:
bit.ly/3L8uIlF
⚙️⚙️⚙️--My Gear - ⚙️⚙️⚙️
👉 Complete Gear 💈: www.computervision.zone/tech-...
👉 My PC Specs 🖥️: www.computervision.zone/tech-...
👉 My Video Shooting Gear📽️ : www.computervision.zone/tech-...
👉 My Laptops 💻: www.computervision.zone/tech-...
👉 Educational Products🧑🎓: www.computervision.zone/tech-...
👉 RUclips Starter Kit 🔴: www.computervision.zone/tech-...
Follow Me:
TikTok: bit.ly/3Vo76OQ
Facebook Group: bit.ly/3irDcb7
Discord: bit.ly/3JvyxAM
Facebook Page: bit.ly/3IvpU7W
Instagram : bit.ly/3NdGME3
Website: bit.ly/3ICFTS0
Github: bit.ly/3woU6PS
#ComputerVision
#OpenCV
#CVZone
Моє шанування! Прекрасні уроки, дякую!
Thank you for explaining it in such an easy and simple way. A Must watch video for everyone. ❤️
Everything is clear now. Thanks :)
I appreciate the little adjustments before using the "main" feature detector more and more
I love your channel. Keep up the great projects!
exactly what i was looking for thank you a million! subbed
Gald it was helpful
I can't thank you enough for this!
Incredible and very well explained tutorial
Glad you liked it!
What a great tutorial! You are really saving my grades right now! I've just gotta apply this to only the pip symbols on playing cards. Which of the links in the description leads to the imgStack function?
A most interesting OpenCV video. I have a new Orange Pi-5 SBC and would like to do some OpenCV Python examples on it. The Raspberry Pi-4 has a wealth of examples to practice with first. This wonderful Tutorial Shape Detection lesson [9] will be very helpful. 😎 Thank you.
Amazing tutorial! very insightful
Thank you my friend. It took an hour to translate from python to C++ but I made it
GREAT TO HAVE THIS ON RUclips SIR
This Channel deserve more Subscribes than it has..!!
i love you you are awesome, the best videos on youtube for computer vision!
It is really helpful. Thank you...
Thank you so much
You help me to start with my final year project idea
I just need to know how can I crop each rectangle and show it as many photos
Heres some of the code that was totally 'linked in the description'
#im suffering
def stackImages(scale, imgArray):
rows = len(imgArray)
cols = len(imgArray[0])
rowsAvailable = isinstance(imgArray[0], list)
width =imgArray[0][0].shape[1]
height = imgArray[0][0].shape[0]
if rowsAvailable:
for x in range (0, rows):
for y in range(0, cols):
if imgArray[x][y].shape[:2] == imgArray[0][0].shape[:2]:
imgArray[x][y] = cv2.resize(imgArray[x][y], (0,0), None, scale, scale)
else:
imgArray[x][y] = cv2.resize(imgArray[x][y], (imgArray[0][0].shape[1], imgArray[0][0].shape[0]), None, scale, scale)
if len(imgArray[x][y].shape) == 2: imgArray[x][y] = cv2.cvtColor(imgArray[x][y], cv2.COLOR_GRAY2BGR)
imageBlank = np.zeros((height, width, 3), np.uint8)
hor = [imageBlank]*rows
hor_con = [imageBlank] *rows
for x in range (0,rows):
hor[x] = np.hstack(imgArray[x])
ver = np.vstack(hor)
else:
for x in range(0,rows):
if imgArray[x].shape[:2] == imgArray[0].shape[:2]:
imgArray[x] = cv2.resize(imgArray[x], (0,0), None, scale, scale)
else:
imgArray[x] = cv2.resize(imgArray[x], (imgArray[0].shape[1], imgArray[0]), None, scale, scale)
if len(imgArray[x].shape) ==2: imgArray[x] = cv2.cvtColor(imgArray[x], cv2.COLOR_GRAY2BGR)
hor = np.hstack(imgArray)
ver = hor
return ver
Thank you so much for the clear explanation. I am currently working on a project,This will definitely help me.
You're welcome. Good luck with your project.
So do i
@Ajay Nair What is the use of it?
Thank you your video help me alot
Good contribution, I have a question, how you can transform the area that you get with the function into a value of square meters? Thank you
thanks for video!!
Great one.
Thanks a lot!
great work Dr Murtaza, is it possible to like this work with think speak to show the detection of the object.thanks in advance
You are the man.
nicely done :)
i love this video
Great tutorial Thank you very much, Unfortunately, The reference code is not available in the links. So i had to type all from the beginning.
Thanks for the informative video, can u help me once...how could i label the individual objects? Actually i want to calculate how many objects and their total area.
First, I gave you a LIKE! , Second: I have a question, What code(s) can we use to get the poinst (x,y) of the shape to draw (after) the shape in Autocad?? Thanks for the answer!
Hi there! I have got a question: I am looking for an algorithm which gives a proposal on the region of interest in an image. Based on this proposal I want then to run an object detection. Is this video now more a "proposal on the region of interest" or is it alreday the "object detection"? Thanks! :-)
Thank you!
Greate tutorial, thanks lot
Anyone knows how to find out the coordinates of the shapes detected? Any help would be really appreciated. Also the tutorial's really really helpful. Thanks!
Thank you very much sir👍
You're Welcome
Nice tutorial !!
Thank you
Can you give me the link for this course, the link in description just redirects me to the new website of yours. I cant find this particular project there. Thanks
Hi, can We store the value of points and area of the object detected outside the for loop?
thank you so much Murtaza's
You're Welcome
I am little confuse here? Is it calculating are of the bounding box around the object or area of the object itself?
I think it's calculating of bounding box?
Btw the tutorial is good ❤️💯
helpful, but can contours used to detect texts from distorted image?
Bro, u have journal of this method? i mean finding contour
omg you do it with no model lol awesome
The area which is the output that is in mm ?And instead of area can we find height and width of that bounding box ? Please help..
this is really great video, just wondering as a next step can we name them as what are these objects? like detecting them as a certain type of object, that is classifying it as a car, scissors and rectangle etc? that will be great help
Yolo does that for you.
@@anupambanerjee8336 it does not do automatically, we have to train it, which is what i want to learn too
Thanx so much 💔💔
No problem 😊
by now, already have image stack function support by library? so we don't need your custime fuction? library function like below? stacked = np.hstack((frame, foregroundPart, frameCopy))
Can you do a tutorial on detecting plants in real time?
thanks god
hi, whats happens the area value if object moving opposite the camare direction?
subbed
Hello sir,
I have one doubt on ..."is it possible to identification of object in sort manner like....example on one table 5-6 different nd same objects are there, in that 2 glass are at different corners...so i want to show that was not proper that 2 glasses should be placed in one place. Like that i have to show through objects detection is it feasible?
Looking for your suggestions
Thank you
Can't you use the Numpy function "hstack" (like this: "images = np.hstack((img1, img2))") instead of creating a new function called "stackedImages" ?
Project is good ❤️....But How to detect size in mm like width and height ....
can i use this with infrared images to get animal's name as a output
If I use my normal laptop webcam is not detecting properly the objects. I have to take it really close to the screen, then I am getting the details properly. Is there anything wrong with how I am doing it
Hi thank you for this , I have a quick question , why i have (invalid syntax) in( ; 0xFF) The last line
this is an html issue of the website. I will fix this. if you find 'amp' remove it.
anyone got a link for the split windows function?
Superb tutorial! Can you do a tutorial that can measure a height of a person using open cv ? Kind regards
I will look into it .
@@murtazasworkshop Thank you. It will be a great help of my project in which the dealine is this coming feb haha.
@@jericreyechavez9 You can follow this tutorial ( ruclips.net/video/dZ4itBvIjVY/видео.html ) with the full body cascade which should give you a bounding box around a human body. Then u could used a fixed coefficient for pixel to cm to find the height. Your camera and target position should be fixed though.
@@murtazasworkshop Thank you so much! You deserve more followers!
@@murtazasworkshop But I will also love to watch your tutorial about this, if you're planning to.
i have a problem where if there's nothing is detected it will error. especially when i remove the object from camera view. it is either from lines convert into gray or in get contour lines where it says expecting 2 argument received 0.
could you post a git hub repository?
How to get the summation of areas of more than one object ?
How to detect object with position x,y and rotation angle alpha?
why we used success,img at the 12th lines?
thanks, how can i get cord?
When I click the link to get the code, it says the webpage has been moved. How can I obtain the code? Anyone has a direct link?
Thank you very much@@
I have a question about your video.
I wanna detect shapes of objects from video files.
so I add the code that below. But it doesn't work. what is the problem?
cap = cv2.VideoCapture('../2.mp4')
while True:
success, img = cap.read()
Your file might not be in the correct folder. Try the code in the link for the video . github.com/murtazahassan/OpenCV-Python-Tutorials-for-Beginners/blob/master/Basics/Read_Image_Video_Webcam.py
If you are still unable to run . Share the error message and i will have a look .
Murtaza's Workshop - Robotics and AI Thank you for your kindness. 😊😊 It works well.
Can you show us sir on how to compute the weight based on an image? Thanks
You could find it based on the area. if your environment is fixed.
@@murtazasworkshop can you demo it Sir show how pls
Is this AWESOME! but i cant find this code in website,,,,, also i dont know this opencv's version,, i want slove error plz answer my Q i wait your answer,,
i'm tryng to run the code but i'm getting
cv2.error: OpenCV(4.3.0) /io/opencv/modules/highgui/src/window_QT.cpp:462: error: (-27:Null pointer) NULL window handler in function 'icvFindTrackBarByName'
Try pasting this error code in google or stack overflow you may get the answer
Great video bro, but, how can i know the area in cm2?
Hola, has logrado conseguir información de como pasar el área que se obtiene a cm2?
@@dennyssantiago3165 can anyone learn
Where is the code you just for the program on your site ? and please mention the installation process too.
check his github
@@tlmyasirs where is the image file 😭
@@indi4889 use any image
Your video is awesome, I can't find your code, can you share it?
In the description (Updated)
can we upload the images and find out the area of that image or pic, using that reference object
Yes i have a similar tutorial on this called object measurement.
@@murtazasworkshop here you represent the area in which format, because in video has 4digit and 5digit valuess , but i don't know the mm2 or cm2
What is the use of it?
How can i use it for detecting only human contours please, i really need help on that.
I suggest you to check my Pose Estimation video
How can we detect only textboxes in an image
i can't find stackImage funtion code anywhere
How can I use this to detect circle? Circle has infinite number of "points" so we cant use points for that.
it seems a matter of how you aproximate the contour, and the shape you draw around it. Maybe there's a function to measure the angles between the segments, and maybe you can compare the are and the perimeter, to see if they are compatible with a circle.
can anybody give me the stacking code..thanks.
How can i take the stack images function on the video ???
Follow the link in the description and go to chapter 6 .
@@murtazasworkshop Thanks a lot 👍👍
can anyone give me that stack code please
rather than stacking with this long function u can use numpy to that
The function is using numpy
@@murtazasworkshop nah bro its a one line command
vis = np.concatenate((img1, img2), axis=1)
@@pythonner3644 thank you!
where we must see the codes
thank you , but the link does not work
Hey, can i have question for you on priv? 😀
sure . you can contact me through this page. facebook.com/murtazasworkshop
hi how can i get the full code for this?
follow the link in the description and enroll to get access to the code
I want to draw contour around my eye pupil only how to do it
you can use the face dlib to get the contours. If you want to use this method in the video, then its better to first detect the face and eye using the haarcascade method. (here is the tutorial).
need stack function code
where to find it?
By the way, the link you claimed to give in the video(s) are broken :). I had to copy 45 lines of complicated code from a freakinf 144p screen, and i just hope that nobody else had to go throught that, because by the end, i just gave up on the project entirely. I dont know how to get access to the code, but PLEASE PLEASE PLEASE FIX THE LINK!!!!!! (good video btw)
def stackImages(scale, imgArray):
rows = len(imgArray)
cols = len(imgArray[0])
rowsAvailable = isinstance(imgArray[0], list)
width =imgArray[0][0].shape[1]
height = imgArray[0][0].shape[0]
if rowsAvailable:
for x in range (0, rows):
for y in range(0, cols):
if imgArray[x][y].shape[:2] == imgArray[0][0].shape[:2]:
imgArray[x][y] = cv2.resize(imgArray[x][y], (0,0), None, scale, scale)
else:
imgArray[x][y] = cv2.resize(imgArray[x][y], (imgArray[0][0].shape[1], imgArray[0][0].shape[0]), None, scale, scale)
if len(imgArray[x][y].shape) == 2: imgArray[x][y] = cv2.cvtColor(imgArray[x][y], cv2.COLOR_GRAY2BGR)
imageBlank = np.zeros((height, width, 3), np.uint8)
hor = [imageBlank]*rows
hor_con = [imageBlank] *rows
for x in range (0,rows):
hor[x] = np.hstack(imgArray[x])
ver = np.vstack(hor)
else:
for x in range(0,rows):
if imgArray[x].shape[:2] == imgArray[0].shape[:2]:
imgArray[x] = cv2.resize(imgArray[x], (0,0), None, scale, scale)
else:
imgArray[x] = cv2.resize(imgArray[x], (imgArray[0].shape[1], imgArray[0]), None, scale, scale)
if len(imgArray[x].shape) ==2: imgArray[x] = cv2.cvtColor(imgArray[x], cv2.COLOR_GRAY2BGR)
hor = np.hstack(imgArray)
ver = hor
return ver
#Your Welcome :)
Thanks for letting me know. Stack image function can be found in Chapter 6 of the link below
www.computervision.zone/courses/learn-opencv-in-3-hours/
Corrected piece of code:
def stackImages(scale, imgArray):
rows = len(imgArray)
cols = len(imgArray[0])
rowsAvailable = isinstance(imgArray[0], list)
width =imgArray[0][0].shape[1]
height = imgArray[0][0].shape[0]
if rowsAvailable:
for x in range (0, rows):
for y in range(0, cols):
if imgArray[x][y].shape[:2] == imgArray[0][0].shape[:2]:
imgArray[x][y] = cv2.resize(imgArray[x][y], (0,0), None, scale, scale)
else:
imgArray[x][y] = cv2.resize(imgArray[x][y], (imgArray[0][0].shape[1], imgArray[0][0].shape[0]), None, scale, scale)
if len(imgArray[x][y].shape) == 2: imgArray[x][y] = cv2.cvtColor(imgArray[x][y], cv2.COLOR_GRAY2BGR)
imageBlank = np.zeros((height, width, 3), np.uint8)
hor = [imageBlank]*rows
hor_con = [imageBlank] *rows
for x in range (0,rows):
hor[x] = np.hstack(imgArray[x])
ver = np.vstack(hor)
else:
for x in range(0,rows):
if imgArray[x].shape[:2] == imgArray[0].shape[:2]:
imgArray[x] = cv2.resize(imgArray[x], (0,0), None, scale, scale)
else:
imgArray[x] = cv2.resize(imgArray[x], (imgArray[0].shape[1], imgArray[0].shape[0]), None, scale, scale)
if len(imgArray[x].shape) ==2: imgArray[x] = cv2.cvtColor(imgArray[x], cv2.COLOR_GRAY2BGR)
hor = np.hstack(imgArray)
ver = hor
return ver
My image is so noisy how to remove noise
Usually depends on the type of noise. You can try median filter.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
in
16
17 imgStack = stackImages(0.8, ([img,imgGray,imgCanny],
---> 18 [imgDil,imgDil,imgDil]))
19
20
I'm getting an error, what should I do?
kaynak kod paylaş haci
Where code
In description
@@murtazasworkshop no
File "d:\J.A.R.V.I.S\jarvis.py", line 384, in
getContours(imgDil, imgContour)
File "d:\J.A.R.V.I.S\jarvis.py", line 172, in getContours
cv2.rectangle(imgContour, (x, y), (x + w + y + h), (0, 255, 0), 5)
TypeError: function takes exactly 4 arguments (2 given)
I am getting this error pls help me.....
(in that qr code script same error is coming named "TypeError: function takes exactly 2 arguments (3 given)
I am using python 3.9.2