C2 can detect geometric shapes drawn by Canvas?

Get help using Construct 2

Post » Wed Jul 08, 2015 10:52 pm

Hi everybody! :D

As I still don't dominate the Canvas object, I ask if is possible to C2 recognize certain shapes drawn by the player, such as an "X" and "check".

I learned to do it recognize closed shapes, but without discriminating a triangle of a circle, for example.

I thank you all in advance for your attention and collaboration.
B
38
S
9
G
3
Posts: 257
Reputation: 4,318

Post » Thu Jul 09, 2015 1:18 am

@R0J0hound, do you have any suggestions for this? ^^
B
38
S
9
G
3
Posts: 257
Reputation: 4,318

Post » Thu Jul 09, 2015 2:24 am

Search for "gesture recognition" for a few examples that may help.

What is usually done is to compare the points of the line drawn instead of the resulting image.
One way is to evenly divide the drawn stroke and compare that with a saved stroke. The simplest way is if both strokes have the same number of points, but you can do some interpolation if the number is different.
The comparison can compare the direction or positions of the points. If by location you'll need to scale the strokes to be the same size.

For each point you add up the differences. Then that sum will indicate how similar the two shapes are. 0 would be identical and anything higher would be less similar. Typically you pick a number that would be good enough to consider it that shape.

For comparing against multiple shape you'd do the same for each and keep the one that was closest.

For comparing if a triangle was drawn then you would have to have to do something a bit more clever. Since you could have started drawing the triangle from any point and went either direction.
One idea would be to find the center of the stroke and find the distances around that to the point. Then you could compare the distances of both strokes at the same angles around the shape.

Anyway, just some ideas. I've made an example that you can find by searching that does some of the above. There are also some examples made by others as well as a plugin that could be of use.
B
91
S
31
G
103
Posts: 5,240
Reputation: 67,766

Post » Thu Jul 09, 2015 2:41 am

Thanks for the help, @R0J0hound. :D

I'm not good at math as you, and I'm more designer than programmer, so often I read tutorials and/or study through reverse engineering. ^^
B
38
S
9
G
3
Posts: 257
Reputation: 4,318


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher and 2 guests