Measure size of objects with image | Computer Vision | Opencv with Python | Pyresearch
HTML-код
- Опубликовано: 20 авг 2024
- #Pyresearch
#Measure #size #objects #image #ComputerVision #Opencv #Python #Pyresearch
Measure the size of objects in an image using OpenCV
The project provides a script to read an image and based on the dimensions of a reference object find the dimensions of other objects in a scene. The reference object must be the leftmost object in the scene. In the sample images given, a box of dimension 2cm x 2cm is taken as a reference object.
For any other reference, the object provides the actual width of the object. (change line 59 in file 'size_object.py')
Constraints
1. Shadow effect: use a dark background
2. Object boundary: use a contrasting background
Getting Started
Prerequisites
Python 3
Pip
OpenCV
Numpy
Other prerequisites:
- pip install numpy
- pip install opencv-python
Algorithm
1. Image pre-processing
- Read an image and convert it to no grayscale
- Blur the image using Gaussian Kernel to remove unnecessary edges
- Edge detection using Canny edge detector
- Perform morphological closing operation to remove noisy contours
2. Object Segmentation
- Find contours
- Remove small contours by calculating their area (the threshold used here is 100)
- Sort contours from left to right to find the reference objects
3. Reference object
- Calculate how many pixels are there per metric (centi meter is used here)
4. Compute results
- Draw bounding boxes around each object and calculate its height and width
code: github.com/noo...
Please let me know your valuable feedback on the video by means of comments. Please like and share the video. Do not forget to subscribe to my channel for more educational videos.
Any type of problem you can comment down.
Want more education? Connect with me here:
Twitter: / noorkhokhar10
Github:github.com/noo...
Subscribe: / @pyresearch
Organizations: / pyresearch
RUclips: / pyresearch
#python #opencv #cvzone #computervision #ai #shorts
Hello sir the video was really useful for me. But i have a struggle in measuring a particular object ( example: I want to measure the size of single tree in image where as the image has many trees and other noisy background). Can you please suggest me to measure the particular object with exact edges in image. Please. Waiting for you reply.
Use an image segmentation algorithm to separate the tree of interest from the background. There are various techniques available for image segmentation, such as thresholding, region growing, watershed, and active contours.
Once you have segmented the tree of interest, you can use techniques like edge detection or boundary tracing to extract the exact edges of the tree.
Finally, you can measure the size of the tree by calculating its area, perimeter, or other relevant metrics.
Some popular image processing libraries like OpenCV or scikit-image have built-in functions for image segmentation and edge detection. You can explore those libraries and their documentation for more details.
I hope this helps!
@@Pyresearch thank you so much sir
@@anusiyakumari7321 keep connect with us
Does this work for curved objects? Ie, a thick curved line, or a thick circle
you can try it, we are nnot used in curved shape
Do you have a Volume measure like 3d estimation?
You try it this code into your way
Please share report
code: github.com/noorkhokhar99/Measure-size-of-objects-in-an-image-using-OpenCV
I can’t find code
🫡 hahahaha
May I know the distance between camera and the object
depen on your camera your camera angle
is it run using gpu or cpu?
cpu