Skip to content

Detect shapes of figures with classical computer vision approach using OpenCV

Notifications You must be signed in to change notification settings

ashnaider/opencv_shape_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shapes detector

Detecting figures shapes.

Classical Computer Vision approach.

Local Image

Algorithm

  1. Select ROIs of figures by their color using defined range of values of Hue channel of HSV (Hue Saturation Value) image representation;

  2. Remove trash using Morphology operations: dilation and errosion;

  3. Use OpenCV findContours method to find contours (obviously);

  4. Get convex hull of the shapes;

  5. Approximate polygon with cv2.approxPolyDP;

  6. Count corners.


Some twist and tweaks are made along the implementation, see the code for more details.

Reproduce

Create virtual environment with pyenv:

$ python3 -m venv env

Activate environment and install dependencies:

$ source ./env/bin/activate
$ pip3 install opencv-python

Place the input video in folder input and run the detector:

$ python3 detect_shapes.py

About

Detect shapes of figures with classical computer vision approach using OpenCV

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages