Detecting figures shapes.
Classical Computer Vision approach.
-
Select ROIs of figures by their color using defined range of values of Hue channel of HSV (Hue Saturation Value) image representation;
-
Remove trash using Morphology operations: dilation and errosion;
-
Use OpenCV findContours method to find contours (obviously);
-
Get convex hull of the shapes;
-
Approximate polygon with cv2.approxPolyDP;
-
Count corners.
Some twist and tweaks are made along the implementation, see the code for more details.
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