1 of 3
1
PyMT
Posted: 12 September 2008 02:17 PM   [ Ignore ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

Hey fellow python lovers,

I have been working on some applications for some research studies I am running and thougth I’d share some code.  I was having trouble with the OSC lib in touchpy a while back (although I think the newer version work great) so I used
simpleOSC to get a thread reading TUIO messages.  I used some of the code form touchpy as well and have written some classes for use with pyglet.  This should run on Windows/OSX/linux.  I have tested it mainly on Ubuntu and more breifly on windows XP and OSX.

The idea here is to let pyglet get multi touch events just like it gets all its other events.  I have written a custom event loop for use with pyglet and a TouchWindow class that receives dispatched multitouch events just like it receives other events. So you can attach your event handler for multi touch just like you attach mouse/window event handlers (also allows multiple event handelers and dynamically attaching/detaching event handlers).  Also the mouse events will trigger touch events with touchID “mouse”...its not as full featured as a TUIO simulator yet, but it makes testing a little easier.

Check out the example apps, most of them are < 100 lines of code, so they should give you a quickidea of how to use the classes.

touchtracer.py
just draws an image and a line to trace each touch

glPaint.py
very simple drawing app with a oversimnplified colorpicker (notice that you can change color while drawing)

untabgle.py
a simple game that draws a circular graph and places the vertices at random locations.  goal of the game is to untangle the graph (similar to http://www.planarity.net)

3dmt.py
draws an obj model exported form blender and lets you rotate it around, the more fingers you use the faster it rotates

Edit: Here are some quick snapshots of untangle.py and 3dmt.py:
graphmanipulation.jpg
rotate.jpg

Any feedback, testing or suggestion welcome smile

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 12 September 2008 05:50 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRank
Total Posts:  436
Joined  2008-04-22

Wow, the blender viewer is really cool, nice work!

One weird thing though, on my computer it works fine with the mouse, but nothing happens when I touch it.

Alex

 Signature 

I am more then willing to to test your Multi-Touch programs on Linux, PM me if you have something.  If you’re looking for something faster then AS3 and Easier then C, try Python!

My Blog

Profile
 
 
Posted: 12 September 2008 08:07 PM   [ Ignore ]   [ # 2 ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

Mhh, it should work with TUIO.  Maybe there is a bug somewhere.  Which port are you using to send you TUIO over OSC?  it tries to hook up to port 3333 on 127.0.0.1 (localhost), maybe you are using a different port or a seperate machine?.  It works here with my touchlib osc on linux and QMTSim TUIO on xp simulator running on the same machine.

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 14 September 2008 02:59 AM   [ Ignore ]   [ # 3 ]
Jr. Member
Avatar
RankRank
Total Posts:  102
Joined  2008-03-02

Really nice work thomas, it’s always good to see that there are other good python projects.
Python deserves more attention from multitouch community, hopely with more apps we can make it more popular. smile

Profile
 
 
Posted: 23 October 2008 02:44 PM   [ Ignore ]   [ # 4 ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

Some updates to pymt.  Framework code is starting to shape up. 

Here is a video of some python love (all but the nui flash apps are pymt):

pymt.googlecode.com

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 24 October 2008 08:15 PM   [ Ignore ]   [ # 5 ]
New Member
Avatar
Rank
Total Posts:  79
Joined  2008-06-06

Great work! Especially the 3D app is very nice. keep up the good work!
cheers

 Signature 

My Diffused Illumination Setup

Profile
 
 
Posted: 27 October 2008 09:48 AM   [ Ignore ]   [ # 6 ]
Jr. Member
Avatar
RankRank
Total Posts:  113
Joined  2008-06-26

Hey Thomas,

nice work there! Since i am a complete Python dummy (only have some little experience with NodeBox): what exactly do i have to do to run your examples on OSX 1.5? I was trying to rund some of the examples (sse the screenshot) but i am doing probably something terribly wrong grin))

TIA & Cheers,

Image Attachments
pytest.jpg
 Signature 

Sandor Rozsa
--
corporate design cologne
http://www.cd-cologne.de
http://www.xtuio.com

Profile
 
 
Posted: 27 October 2008 10:56 AM   [ Ignore ]   [ # 7 ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

you have to install pymt first.

The root folder of has a file called setup.py.  you can instal pymt by running ‘sudo python setup.py install’ (or just python setup.py install on windows).  that will install pymt to your system, which should make all the example apps runs no matter where you run them from.  alternatly you can copy the pymt folder (also in the root directory) into the directory you are running the python program from (i.e. copy it into one of the example apps folder).  python searches the default instalation path and the current directory for modules.  hopes this helps!

thanks for testing it!

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 27 October 2008 01:07 PM   [ Ignore ]   [ # 8 ]
Jr. Member
Avatar
RankRank
Total Posts:  113
Joined  2008-06-26

Hey Thomas,

well - thank YOU for sharing it! grin I have not done yet the right way, but pasted a few minutes after my first post the pyglet and pymt directories in the NodeBox folder in the Application Support folder where all the NodeBox libraries are… Now i am able to run and edit your examples in NodeBox - and that is fine for an ignorant like me wink)

The apps are really cool! They perform very smooth and well even on that little MacMini we have bulit in inside our MT-Table. Unfortunately i don’t really have the spare time to play around (i wish i had that!) with them - would be a mazing to see if i could use some NodeBox features (like coreimage, colors etc.) with your library…

Great work man! Keep it up....

Cheers,

 Signature 

Sandor Rozsa
--
corporate design cologne
http://www.cd-cologne.de
http://www.xtuio.com

Profile
 
 
Posted: 29 October 2008 10:44 PM   [ Ignore ]   [ # 9 ]
New Member
Avatar
Rank
Total Posts:  3
Joined  2008-10-28

hi Thomas

how I can do to extend it to to recognize the /tuio/2Dobj

thanks

 Signature 

“I hear and I forget. I see and I remember. I do and I understand.”
-Confucius

Profile
 
 
Posted: 30 October 2008 06:38 PM   [ Ignore ]   [ # 10 ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

It currently only supports /tuio/2Dcur.  I have only been working on touch interfaces.

I would like if pymt supported 2Dobj and more input types(multiple mice kind of works on windows), but i have to finish some other things i’m working on for the moment.  If you have time or want to look at it yourself, all the parsing of TUIO messages and window event handlers are in the file pymt/mtpyglet.py.  I think it could be done by extending the TUIOGetter class to handle 2Dobj messages. 

Is the data of 2Dobj simillar to that of 2Dcur?  The way e.g. the mouse support works is that mouse events just get made into touch events.  The touchID would is “mouse0”.  If doing something simmilar with 2Dobj is possible, it wouldn’t be that much work.

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 05 November 2008 11:32 PM   [ Ignore ]   [ # 11 ]
New Member
Avatar
Rank
Total Posts:  3
Joined  2008-10-28
thomas.hansen - 30 October 2008 06:38 PM

It currently only supports /tuio/2Dcur.  I have only been working on touch interfaces.

I would like if pymt supported 2Dobj and more input types(multiple mice kind of works on windows), but i have to finish some other things i’m working on for the moment.  If you have time or want to look at it yourself, all the parsing of TUIO messages and window event handlers are in the file pymt/mtpyglet.py.  I think it could be done by extending the TUIOGetter class to handle 2Dobj messages. 

Is the data of 2Dobj simillar to that of 2Dcur?  The way e.g. the mouse support works is that mouse events just get made into touch events.  The touchID would is “mouse0”.  If doing something simmilar with 2Dobj is possible, it wouldn’t be that much work.

hi Thomas,

First , I did the 2Dobj extension ... if you want , I may make available for you , but I must document it !

I have some problems with pymt and the reacTVision simulator and a real MT Table with reacTVison software. When I run app first and then the simulator or when I stop using the simulator during a little time (such as 3-5 seconds) , the app doesn’t work (it doesn’t receive messages anymore).

I don’t figure out the why =\.

Do you have some guess?

 Signature 

“I hear and I forget. I see and I remember. I do and I understand.”
-Confucius

Profile
 
 
Posted: 06 November 2008 12:06 PM   [ Ignore ]   [ # 12 ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

Awesome!!

I can add you to the google code project / give you write access to the svn repo if you want (let me know your google id) or i can add the code if you send me a patch.  As for documentation, I have started writing down a little bit (still very unfinished) in a temporary wiki I have set up here : http://tehansen.de/cgi-bin/moin.cgi, feel free to add anything about code or questions (its world editable right now, ill leave it that way until it starts getting spammed).

As for the bug you are describing.  Are you running on windows?  I have had simmilar issues with touchlib on windows, tbeta works great on linux for me.  I think I also had that problem with qtsim on windows.  I’m not sure exactly what the bug is, but i think the simulator/touchlib on windows dont send any TUIO messages when there are no touches.  maybe python osc closes the OSC connection when there is no incoming messages for a certain time? I’ll try to check out the details later, it might be an easy fix of just forcing the socket to stay open somehow or re-estabishing it once its down.

--
Thomas

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 06 November 2008 12:45 PM   [ Ignore ]   [ # 13 ]
New Member
Avatar
Rank
Total Posts:  3
Joined  2008-10-28

Ok, If you add me in the project will be better , because I have some ideias to improve pymt ... ,such as , you use a disk as an area of selection for ZoomAbleObjects, but an OBB(oriented bounding box) or an ellipse fits better this regions, because we may use objects that have another shapes and the region will be limited to the center of the object ( think in a long rectangle). The events should pass a list of parameters not only the x,y positions ...
So , we can talk about these things.
My gmail is ... but I the extension is not robust ... then I’ll not upload it yet!

 Signature 

“I hear and I forget. I see and I remember. I do and I understand.”
-Confucius

Profile
 
 
Posted: 07 November 2008 02:00 AM   [ Ignore ]   [ # 14 ]
Jr. Member
Avatar
RankRank
Total Posts:  107
Joined  2007-11-29

yeah..the disk never got changed because i was too lazy… no transformations to keep track of with disks rasberry

i added you to the project.  we can chat some other time, i added you to my gtalk buddy list as well.  I’m a little busy the rest of this week, but hopefully next week i can get some coding done.  need to do some cleaning up with the code as well.

you can actually access the other parameters by using the touchID to index the touches dictionary that is also passed, i just figured passing x and y was some nice sugar so you didnt have to write touches[touchID].x everytime you wanted to access just x or y coordinate.

thanks so much for helping out with this!, python is awesome and with openGL underneath I think there is potential to do really some fancy graphics as well (im working on shader support for widgets).

 Signature 

http://blog.tehansen.de
http://cs.uiowa.edu/~tehansen

Profile
 
 
Posted: 12 December 2008 04:33 AM   [ Ignore ]   [ # 15 ]
New Member
Avatar
Rank
Total Posts:  16
Joined  2008-12-02

Hello from France,

I’m new here and I want first thanks you thomas for your really good work.
After i have tried to work with flash (very slow, and not stable for me), i have tried your PyMT toolkit,
and now i will not use other language.

Python is exactly what i looked for.It’ easy to learn, stable and fast when using OpenGL.

Here a video with some existing applications and some applications i have coded with your PyMT toolkit (it’s my first shoot).

http://www.youtube.com/watch?v=1tiRLwKztqc

There still some bugs in my code, i need to work again on it, but it works.
I can post code, when it will be cleaned, if somebody want.

Thanks to all the community for existing.

 Signature 

My Setup :http://kaswy.free.fr

Profile
 
 
   
1 of 3
1