Slick Forums

Discuss the Slick 2D Library
It is currently Wed Aug 21, 2019 9:21 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Mar 09, 2011 10:18 pm 
Offline

Joined: Fri Mar 04, 2011 12:34 pm
Posts: 24
Hi guys (and girls?), I dont rly know where to post this but I guess this is the right choice.
I had an idea today: I want to make motions with my mouse and the computer to recognize what ive drawn there. Easy enough: I create a path object and say path.lineTo(current mouse position). Then I have some predesigned figures that I can compare the path with and say which it fits. Thats the whole concept.
Nows my question: how do I organize this?
Heres what I have so far: http://npshare.de/files/b2329252/painttest.zip
It works but im not entirely satisfied with the class design. As you can see(if you opened my project) I have a class "Line"(I rly need a better name for this), which is the base for all "Figures". Every Figure consists of multiple Lines that are arranged in some way. Each Figure has a method matches(ArrayList<Path> paths) that checks if the given paths form that figure and then returns true or false.
Now ive made these Factory-classes which contain methods like createCross(), that obviously create the figure that the method says. This whole factory thing works, but I dont really like it oO maybe someone has a better idea to design this?
I also want to make a class like "BiggerFigures" which consists of figures instead of lines to make even "Bigger Figures" recognizable.
So im looking for design suggestions. I want to keep the systems flexibility to a max but I currently have no good ideas :/

A short introduction to the program i created:
The figures that can be drawn are at the bottom of the window: a vertical line, a horizontal line, a cross and a "日"(hi, jap. for sun or day). Booleans at the left for you to see what youve drawn there. A timer above them(You have 10s to draw something, if thats too short just change it lol) and at the top right the mouse position.
To start drawing press the "e"-key. To draw press the left mousebutton and move the mouse. When you release it and press it again a new path will be started. Press e again to stop drawing or wait for the time to run out.

The cross as no strokeorder, so you can start drawing wherever you want. When you want to draw 日 you have to make the strokes in the right order and direction. Its not yet 100% accurate tho. The correct order would be this:
Image

So there are 4 strokes total. But you have to seperate the 2nd stroke into 2 (means: release the left mousebutton when you hit the upper right corner and press again, then move down). So there are 5 strokes, simply because i havent implemented edges or curves yet.

If you guys have any ideas how to organize this better or how to improve a algorithm or simply have a better name for something, let me here it :)

_________________
Rules of Optimization:
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2011 10:25 am 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
I didn't look at your source code (yet) but just googled for "mouse gesture recognition java" and first found this wikipedia entry:
http://en.wikipedia.org/wiki/Pointing_device_gesture#Software_libraries

The Smardec link http://www.smardec.com/products/mouse-gestures.html
has a short API description here:

http://www.smardec.com/products/mouse-gestures/api/com/smardec/mousegestures/MouseGesturesListener.html

The most interesting concept idea I found there is the following:
a gesture is always a single stroke thing (clicking the mouse button, drawing something, releasing mouse button).
And the "drawing something" is described as movements up, down, right or left.
So every gesture could be described as a simple string.

So your gesture 1 would be "D" for down, 2 would be "URD" for up, right, down, 3 could be something like "UURDLRD" to draw the symbol in a single stroke and 4 could be "UURDDLUR".

But maybe you just download some of those libs (many are open source) and see if you can get some ideas/inspiration from them :wink:

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2011 11:31 am 
Offline

Joined: Fri Mar 04, 2011 12:34 pm
Posts: 24
omg, of course i didnt think of googling this xD well thanks, ill look into it.

_________________
Rules of Optimization:
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2011 10:59 am 
Offline

Joined: Sun Oct 11, 2009 4:37 pm
Posts: 12
Have a look at neural networks! they fit your problem really well because they are able to learn and can recognize patterns. imo a very interesting topic :)

Example:
http://www.youtube.com/watch?v=2XOMkkGafGc


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2011 2:15 pm 
Offline

Joined: Fri Mar 04, 2011 12:34 pm
Posts: 24
mantax wrote:
Have a look at neural networks! they fit your problem really well because they are able to learn and can recognize patterns. imo a very interesting topic :)

Example:
http://www.youtube.com/watch?v=2XOMkkGafGc

wow thats amazing! ill definitly look into that more. thanks for the link

edit:now that i think of it; i will have "basics of neural networks" this semester lol but thats not rly what i was looking for, though interesting.
my 2nd approach was more like: give the perfect sample of an image and let the system calculate relations between lines and degrees and so on. then when you put something handmade into it it can compare the values.

_________________
Rules of Optimization:
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group