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 sample images given, a box of dimension 2cm x 2cm is taken as a reference object.
For any other reference object provide actual width of the object. (change line 59 in file 'init.py')
- Shadow effect: use dark braground
- Object boundry: use contrasting background
Python 3 Pip OpenCV Numpy
- cd object-size
- python3 -m venv .env
- source .env/bin/activate
- pip install -r requirements.txt
- cd object-size
- cp images/example_01.jpg images/foo01.jpg
- python init.py
- you should see new files appearing inside the image folder:
- foo01_blurred.jpg foo01_edged.jpg foo01rslt.jpg
- Image pre-processing
- Read an image and convert it it no grayscale
- Blur the image using Gaussian Kernel to remove un-necessary edges
- Edge detection using Canny edge detector
- Perform morphological closing operation to remove noisy contours
- Object Segmentation
- Find contours
- Remove small contours by calculating its area (threshold used here is 100)
- Sort contours from left to right to find the reference objects
- Reference object
- Calculate how many pixels are there per metric (centi meter is used here)
- Compute results
- Draw bounding boxes around each object and calculate its height and width
- Shashank Sharma