4 ms·
I recently looked up shape matching with OpenCV for a game I'm making. Basically, you draw black and white images by spawning meatballs, then the drawing is re
by LelouBil 4y ago
I recently looked up shape matching with OpenCV for a game I'm making.
Basically, you draw black and white images by spawning meatballs, then the drawing is rendered to a image and checked against a reference using openCV.
I found gesture algorithm online's but they always take into account individual strokes, and the drawing system is not using strokes.
I also have requirements to match the *whole* image but not *exactly*.
So what I'm doing is :
1. Resizing and cropping the input image to size of the reference image.
2. Matching each shape in the source image to the closest shape in the reference image (if any shape is below a certain threshold, the drawing is failed).
3. Blur the whole image a bit, and count the percentage of overlapping pixels (if over a certain value, this makes sure the different elements of the drawing are approximately in the right position).
This took me like 4 days to figure out, but it was really interesting having to prototype it using python and translate it to C# afterwards. (Though I sadly ended up buying a 80€ Unity OpenCV library since nothing else was working for me)
- drekipus 4y agoNot quite sure what you're looking for but opencv's contour functions might help you here https://docs.opencv.org/3.4/d8/d1c/tutorial_js_contours_more_functions.html https://docs.opencv.org/3.4/d8/d1c/tutorial_js_contours_more... There's also a method of calculating the similarities of two areas called Union over Intersection, which is easy and quick to calculate. Although it sounds like you got it figured out, so don't let me over complicate something that's already working.. :) Would be interested in seeing the game!