Skip to content

alexandremendoncaalvaro/draw-size

Repository files navigation

Draw Size

Basic example of real time size estimation from camera with with OpenCV

The first-left object width is the reference for measurement

  • MIT License
  • Required Python 3.6+

References

Base examples from pyimagesearch:

How to use

after install...

Example

python3 draw_size.py --camera 0 --width 2.0 --float 2

arguments:

  • camera: source id (default webcam is 0) - optional
  • width: width in centimeters of the first-left object (for reference) - required
  • float: floating point precision

press q to exit

For study and sharing purposes I added a basic shape detection algorithm

Example

python3 shape_detector.py --image images\example_01.png

arguments:

  • image: the image path

Install

*if pip3 command not working use pip instead

**if something not work, try to reboot the terminal. :)

MacOS

xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git cmake python3
git clone https://github.com/alexandremendoncaalvaro/draw-size.git
cd draw-size
pip3 install virtualenv
virtualenv cv
source cv/bin/activate
pip3 install -r requirements.txt

Ubuntu

sudo apt update && sudo apt upgrade
sudo apt-get install git build-essential cmake python3 python3-pip python3-dev python3-setuptools
git clone https://github.com/alexandremendoncaalvaro/draw-size.git &&
cd draw-size
pip3 install virtualenv
virtualenv cv && source cv/bin/activate
pip3 install -r requirements.txt

Windows

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install git cmake python3 -Y
git clone https://github.com/alexandremendoncaalvaro/draw-size.git &&
cd draw-size
pip3 install virtualenv
virtualenv cv &&
cv\Scripts\activate
pip3 install -r requirements.txt

Virtual Enviroments

*It's optional, but I strongly recomend you to know about (and use) Virtual Enviroments

The virtualenv lib is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.

pip command

pip3 install virtualenv

You can create a virtualenv using the following command (*choose a name, I used cv):

virtualenv cv

Activate it:

MacOS & Ubuntu

source cv/bin/activate

Windows

cv\Scripts\activate

Now ALL pip libraries will be installed isolated inside the environment. It'll look like this:

(cv)$ pip3 install ...

If you want to deactivate:

(cv)$ deactivate

Command:

deactivate

About

Estimates draw size based on left shape width (webcam)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages