Coder Social home page Coder Social logo

wmhui007 / object-size Goto Github PK

View Code? Open in Web Editor NEW

This project forked from snsharma1311/object-size

0.0 0.0 0.0 1.08 MB

Measure size of an object (height and width) using a reference object

License: GNU General Public License v3.0

Python 100.00%

object-size's Introduction

Measure 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 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')

Constraints

  1. Shadow effect: use dark braground
  2. Object boundry: use contrasting background

Getting Started

Prerequisites

Python 3 Pip OpenCV Numpy

Installing

For python and pip installation follow this blog

  1. For windows https://www.howtogeek.com/197947/how-to-install-python-on-windows/
  2. For Linux https://docs.python-guide.org/starting/install3/linux/

Other prerequisites:

  • pip install numpy
  • pip install opencv-python

Algorithm

  1. 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
  1. 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
  1. Reference object
  • Calculate how many pixels are there per metric (centi meter is used here)
  1. Compute results
  • Draw bounding boxes around each object and calculate its height and width

Results

Result

Authors

  • Shashank Sharma

Acknowledgments

object-size's People

Contributors

snsharma1311 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.