A program to find the common element on the double's game
You need the non free algorithms of openCV, so I compile it from source with this command:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_src/opencv_contrib/modules ../opencv
Test the detection of the common element:
python3 doublegame.py test/card_06.png
You will obtain something like this:
- Read image
- Transform into grayscale
- Detect the cards (circles)
- Apply a blur to improve the HoughCircles detection
- Extract the cards for an image without background
- Apply a threshold for the contours detection
- Make a FLANN matching between each card to find the macthing points
- For each match, retrieve the corresponding contour to draw the bounding rect