Flash and TUIO libraries! (open source)

7 Apr

There are a lot of Flash <-> TUIO libraries, primarily intended to bring the Multitouch TUIO standard to Flash in an API style. Because AS3 is pretty much developed towards the concept of Event Handling (attaching events with functions that are dispatched by the AS3 itself) these libraries work in a similar way to. There are a few possibilities that I’ll show here:

Tuio-AS3-Library (link & download)

This is a small framework that allows you to do the basic stuff with the TUIO messaging under ActionScript3, it supports:

  • TUIO 1.1 (the latest spec)
  • Cursors, Objects and Blobs in 2D, 25D & 3D
  • Binary data stream via TCP & LocalConnection (because AS3 does not use UDP – this is changing as we speak)
  • Callbacks & legacy TouchEvents
  • Fully implemented OSC parser (very important, this is the way you extract information from a packed TUIO/OSC message)

Their website describes it quite nicely (see diagram above), although in a very brief testing I had some problems with the linkage in both Flash Builder 4, Flex Builder 3 and even command line MXMLC (Flex Compiler from Open Source Flex SDK) – it may be  simple problem that I’m overlooking, I’ll post more as soon as I can get it running here.

TouchLib (stronger lib – download link)

The main thing about TouchLib is that it comes packed with AS3 classes to work with TUIO, therefore it offers the same basic funcionalities as above (listening to the TUIO messages, parsing them, etc…), then it comes with something extra: AS3 classes that allow you some funcionality (very typical of Multitouch):

  • Automatic rotate, scale and move of the canvas objects (via RotatableScalabe.as)
  • and all the stuff of the previous lib…

Make sure that you understand that ToucLib is indeed a CV tracker, intended to multitouch tabletops, it is written in c++ and uses OpenCV.dll but has now been replaced with CCV, what we want here is the Classes of AS3 that comes with TouchLib files from svn, that allow us this multitouch flash behaviour.

You can also check some projects that make use of the TouchLib AS3 classes for Multitouch here (they make interesting demos..).

FiducialTUIOas3 (download here)

This fiducial AS3 framework enhances the Touchlib’s AS3 classes with Tuio object interaction functionality.

The adapted Touchlib’s TUIO AS3 classes are included. To make it even clearer: You don’t need any other TUIO AS3 classes then those of fiducialtuioas3 as fiducialtuioas3 supports both multi-touch AND fiducials. It’s complete. You can even use fiducialtuioas3 if you only want to implement multi-touch interaction.

Here’s a demo on a project that uses flash + multitouch + fiducial tracking.

 

TUIO-As3-Lib (download link)

This a small scaled library (with a very similar name to the first one, although they are two different libs) that allows you to receive and parse TUIO messages via As3. This is very simple to use: just include the .swc component in your project or command line include argument. The functionallity is stripped down to minimum, but if this is all you need it might just suit you nicely. Here’s my first demo with this lib.

http://www.youtube.com/v/_2DywsIPNDQ&hl=en_US&fs=1&

Testing the Tuio-AS3-lib on a multitouch table from PedroLopes on Vimeo.

Do not mind: the non-calibrated touch points!

I’ve built a “Hello World”-like demo to test the features of TUIO-AS3-lib. It is distributed in either Source or SWC (external component for import). The demo instantiates 3 string objects, they are assigned to an array that is check everytime a touch event arrives in TUIO-AS3-lib listener – this way for each object the colision is detected. I use CCV (tracker) & an ActionScript 3 project (that imports the external SWC of the lib). Some thoughs about TUIO-AS3-lib: interesting project if you just need to listen to the events and implement your interface on top. Simple and plain code, easy to follow. Although it does not implement the same level of features as a full scaled multitouch framework like touchlib that offers scalableObjects, rotatable, and so on…

Advertisements

5 Responses to “Flash and TUIO libraries! (open source)”

  1. angela April 16, 2010 at 8:11 pm #

    Hi,

    Thanks for your post. has very helpful.
    I have a question for you.

    It is possible to use the touhlib as3 library in a mac ambiente with CCV tracking ?

    • PedroLopes April 17, 2010 at 7:39 pm #

      it should be absolutely transparent:
      – touch lib AS3 classes are pure actionscript, so they are not dependent of any platform.

      Also, in NUI’s wiki, there’s a guide to installing touch lib on OSX, if is anything that you need from the touchlib core:
      http://wiki.nuigroup.com/Installing_Touchlib_on_Mac_OS_X

      As far as interfacing with CCV, it should be direct (just provide the host+port in which CCV is outputing the OSC commands), I can help when I get these classes working, although I’ll use Linux/Windows.

      Best regards,
      Pedro

  2. Sha July 13, 2010 at 2:16 pm #

    I have a question for the Flash and TUIO libraries can I just use this for simple touch and move events?

    Do you have any project source files created with Flash, TUIO and CCV?

    Thank you.

    • PedroLopes July 14, 2010 at 1:37 pm #

      >I have a question for the Flash and TUIO libraries can I just use this for simple touch and move events?
      Of course, any TUIO lib for Flash will accomplish that behaviour natively.

      >Do you have any project source files created with Flash, TUIO and CCV?
      Yes, but there’s better tutorials online, here’s the one I’d recommend:

      Blob lines (at NUI group)
      blob lines (at CyanCDesign)

      These just cover the very basics, just drawing blob lines where you touch. The good about this is that with all of the flash framework, you can forget about multitouch and simply use the TUIO touch events as normal flash events. Imagine a sprite that you want to react to a TUIO event:

      import flash.Events.TouchEvent;

      //whatever code of your object's class and then in the contructor or anywhere else, you can add listeners that use the TUIO events!

      this.addListener(Event.TouchDown, clicked)

      //then just create a click function

      private function click(e:Event):void
      {
      trace("i have been touched with a finger");
      }

      And so on… take a look at the tutorials. This implies that you already have some TUIO lib included (imported) in you project files. I’d recommed the NUI group AS3 classes, but there are so many good libs out there (search this blog for others too!).

      best of luck,
      Pedro

      Thank you.

      • PedroLopes July 14, 2010 at 1:39 pm #

        p.s.: The code above is not targeted at any lib specifically, its more generic for you to understand the behavior on how to add touch to an object.

        p. p.s.: The NUI group AS3 classes already provide automatic functionality, you just extend your objects to their classes (let’s say: Scalable) and now your object reacts to the pinch gesture and scales up and down. No code needed apart from extending the class itself.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: