- Home /
Gesture Recognition, determining shapes
Hi guys,
So at the moment i'm creating a game in which the user draws runic symbols to cast spells (similar examples would be the magic in infinity edge or the gameplay mechanic of magic touch)
so at the moment i'm using a linerenderer to draw the user input. I'm storing the vector3 co-ordinates of the screen space in a list to record the user input. I was wondering what the most effective way to work out if the user has drawn a square / swirl / triangle is etc. Is it advisable to reduce the number of co-ordinates to a smaller number before trying to work this out and then calculating the number of angles within a certain range or... what would be the best way to do this?
sorry if this is a dumb question. just any pointers. In case you need to know i'm most comfortable writing in c#.
Answer by siaran · Mar 02, 2015 at 11:05 PM
If you want to calculate the number of angles in a certain range for a user-drawn line, you might not want to count very small ones, as those were likely intended to be a straight line. You'll have to experiment a bit on where you'll draw the line between 'angle' and 'not an angle', and it won't be foolproof.
What you will then probably want to do is store the angles you end up with in-order in an array or list (instead of the vertex positions - although you can start with those and work out where and what your angles are later), then compare with pre-stored lists of angles that define your shapes (with some margin for error). You may also want to check if the shape was closed, i.e. if your last vertex is close to your first.
I have no idea how you'd recognize a circle or any other shape with a curve in it though. (I suppose you could try drawing some, see what kind of angles you get and see if you get a result that's useable but I have some doubts on how well that would work).
Alternatively, you could look into some machine learning pattern recognition methods but...that might be a bit much. Maybe just stick to 'edgy' shapes.
Hi, many thanks for your reply. That was what I was thinking of doing but I was wondering how it would be best to convert the co-ordinates into angles because there will be a lot of co-ordinates in each angle is it best to reduce the number of co-ordinates by the amount of integrity to the shape or is there a way to get the angle as a generalisation from the co-ordinates in the area. What's the best way to do that?
Once again many thanks.
Okay so I was thinking of tracking the direction vector using (x',y')=(x/r,y/r) where r=sqrt(x^2+y^2) so that it only factors direction and then record the direction vector leading upto each point and once it starts changing record that as a bool that the user is changing direction and then when the vector normalises again that's the end of the corner. Then maybe apply an algorithm to reduce the number of co-ordinates to 3 (since there will be a start, corner point, and end in the user input) so that I can work out the angle and stuff. Is this over complicating the situation? Is there a better way to do it?
Thanks community
Hmm, what you could do ins$$anonymous$$d is simply track the direction between frames, and if it is significantly different, you add the angle between them to your list of angles? No idea if that would really work, just an idea I had.
Your answer
![](https://koobas.hobune.stream/wayback/20220613184814im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Help - Kinect for windows v2, Gesture recoginition 3 Answers
Pinch-zoom camera 2 Answers
Shooting with get joint rotation .eulerAngles kinect 0 Answers
Swipe Drag Select Gameobjects :( ? 1 Answer
How to make a Running game with Microsoft Kinect Sensor 0 Answers