Measure size of objects with image | Computer Vision | Opencv with Python | Pyresearch

preview_player
Показать описание
#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.

### 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

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:

#python #opencv #cvzone #computervision #ai #shorts
Рекомендации по теме
Комментарии
Автор

hi sir, i found this informative, i have a doubt without that 2cm box.. if i have to predict original dimension of parcel basically. is it possible?

cindrellabk
Автор

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.

anusiyakumari
Автор

Does this work for curved objects? Ie, a thick curved line, or a thick circle

slavic_cousin
Автор

Do you have a Volume measure like 3d estimation?

gog
Автор

May I know the distance between camera and the object

-BMadhan