Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/knosmos/set-solve
Cheating on SET with computer vision
https://github.com/knosmos/set-solve
image-processing opencv set-game
Last synced: 4 days ago
JSON representation
Cheating on SET with computer vision
- Host: GitHub
- URL: https://github.com/knosmos/set-solve
- Owner: knosmos
- Created: 2021-10-14T04:18:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-27T02:49:24.000Z (almost 3 years ago)
- Last Synced: 2024-12-08T21:46:26.226Z (2 months ago)
- Topics: image-processing, opencv, set-game
- Language: Python
- Homepage:
- Size: 5.33 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Playing Set with Computer Vision
![setsolve](https://user-images.githubusercontent.com/30610197/155866087-8139f7b6-1a5d-4793-b088-161ea118dd58.png)
Uses OpenCV to play SET, a card game where the goal is to find three cards where each "feature" - number, color, shape, shading - are all the same, or all different.## How does it work?
### Card Segmentation
The first step is to segment the cards. We do this by thresholding the image,
then running a contour detection algorithm which gives the outline of each "region".
Then we find the largest twelve rectangular contours, which finds the cards relatively
reliably. Finally, we run a perspective transformation to unwarp the cards.### Number Detection
To find how many shapes there are on one card, we run the contour detection again
on that single card. After filtering out contours that are too small (noise), we
simply count the number of contours.### Color Detection
We find the average color of a segmented contour, and compare it to prerecorded values
for red, green and purple. Color detection sometimes errors, because red and purple
can be mistaken for one another under different lighting conditions.### Shape Detection
We run OpenCV's `moments` function on one of the segmented contours, which gives various
characteristics of the shape. We then compare the result to prerecorded values to determine
whether the card is a squiggle, diamond or ellipse.### Shading Detection
This is done by finding how much of the card is colored. A solid-shaded card will have
more colored pixels than a striped or empty-shaded card. We also run a Sobel edge-detection
algorithm; a large number of edge pixels indicates that the card is striped.### SET Determination
This is the easiest part - just a complete search on all possible SETs.