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+
Base examples from pyimagesearch:
- https://www.pyimagesearch.com/2016/03/28/measuring-size-of-objects-in-an-image-with-opencv/
- https://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/
after install...
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
python3 shape_detector.py --image images\example_01.png
arguments:
- image: the image path
*if pip3 command not working use pip instead
**if something not work, try to reboot the terminal. :)
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
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
@"%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"
-
Install Visual Studio with Visual C++ Build Tools 2015
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
*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.
pip3 install virtualenv
You can create a virtualenv using the following command (*choose a name, I used cv):
virtualenv cv
Activate it:
source cv/bin/activate
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