- Home /
How to check if you draw/outline a symblol by its contour?
Hello! Im currently making a game, and stuck with making a feature, in which you draw/outline a symbol that you see, main question is, how to determine if you`ve drawn it correctly? So its not gesture recognition, you are drawing a symbol by its contour. Like this.
Whats the best way to do it?I mean checking if you drew it correctly?
1)Make point along symbol and check if you connected them?
2)Or another way? Every advice is appriciated.
are you allowing any drawing order, or is it allowed to be a fixed path?
Yes, its allowed to draw from in any path, main thing is to draw it as much correctly as possible.
Here's an idea, probably naive do it might not be the best one, but, as usual, there might be no best.
First you need an ordered path of your shape as positions, a list of continuous, path-centered positions. Then, when the user starts swiping, his draw positions need to be compared with that path, to what the closest positions are. If you're at a sharp edge, you probably get alternating results, so as long as the result is not clear, in that case you check against two paths. Since the path is continuous, you shouldn't have any backtracking in positions to compare with. Up to a certain point it should be clear which path and which direction the user is about to swipe. If you always check for the shortest position, starting from the left one in both directions, stopping when the distance gets larger, you should be able to generate an average for the precision.
Your first goal might be to write a utility function that will give you the distance from a given point to a line segment on the same plane. as outlined here
The next step might be to break that figure down down into just its lines (which is likely already done, given that you're already drawing something on a canvas).
Then, apply your distance-to-a-line function to that collection of lines for each point used in the user's drawing and deter$$anonymous$$e the smallest error / distance from your canvas for each. This will give you "distance" from that point to the original figure, allowing you to use those errors / distances for each drawn point to deter$$anonymous$$e how incorrect the attempt was.
Answer by PSpiroz · Nov 30, 2017 at 01:48 PM
Have no proper answer, but I am in seek of answers to similar problems. A solution maybe "openCV" and "find Contours". In find Contours arguments you choose the represented hierarchy (https://docs.opencv.org/3.1.0/d9/d8b/tutorial_py_contours_hierarchy.html) of contours list so you can choose what you need to combine... I think It is a sophisticated way and really have no idea how you manage and code these, (this is what I am looking for right now). If you have already found another way, please share...
Your answer
Follow this Question
Related Questions
Shader for Outline Contour Points 0 Answers
Physics.CheckSphere with tag 1 Answer
Draw line from one point to another using mouse 0 Answers
Temperature map shader 0 Answers
Draw point with time function 1 Answer