Touching Source Documentation

r455

Introduction

This is the source code documentation of Touching, the multitouch recognition and processing library written at the TU-Berlin during a multitouch student project in winter 2007/2008. For more information about it, check also our wiki: http://www.cg.tu-berlin.de/mtouch_wiki.html

class diagram

The following diagram shows the most important classes with very brief descriptions. On the left side are the image sources (from camera or any other source). Located on the right side are some preprocessing devices which may contain filters. A device contains an image producer as source and a tracker to deliver the images to. The device gets a set of touches for the current frame from the tracker and calls touch listener for each touch and frame listener for each frame processed. Those listeners do further processing on retreived data: Send it over the network or process it further locally.

In the center of the diagram below are five central pure interface classes arranged (prefixed by a capital i).

class_graph_current.png

A Example for a client app

It contains preprocessor macros (OSC_AVAIL) to decide whether to use our own protocol or the TUIO/OSC protocol to receive touches.
For a simple test it is sufficient to chose either of them.

//#define OSC_AVAIL


#ifdef OSC_AVAIL
        #include <devices/OSCNetworkDevice.h>
#else
        #include <devices/NetworkMultiTouchDevice.h>
#endif



#include <interfaces/ITouchListener.h>
#include <util/Touch.h>
#include <util/global.h>

#include <iostream>


using namespace Touching;

class MyListener : public ITouchListener {
  public:
    void onTouchDown(const Touch& touch) { std::cout << "Down: " << touch << std::endl; }
    void onTouchUp(const Touch& touch) { std::cout << "Up:   " << touch << std::endl; }
    void onTouchMove(const Touch& touch) {std::cout << "Move: " << touch << std::endl; }

};

MyListener client;

#ifdef OSC_AVAIL
        Touching::OSCNetworkDevice* netDevice = 0;
#else
        Touching::NetworkMultiTouchDevice* netDevice = 0;
#endif

void onInit(uint port) {
    std::cout << "  Start listening on port " << port << "." << std::endl;


#ifdef OSC_AVAIL
    netDevice = new Touching::OSCNetworkDevice(port);
    netDevice->start();
#else
        netDevice = new Touching::NetworkMultiTouchDevice(port);
#endif

        netDevice->registerTouchListener(&client);

}

void onIdle() {
#ifdef OSC_AVAIL
        // nothing OSC uses multithreading
#else
    netDevice->processNextPackets();
#endif
}

    

int main(int argc, char * argv[])
{
    uint port = 3333;
    if( argc > 1 ){
        port = (uint)atoi( argv[1] );
    }
    std::cout << "Usage: " << argv[0] << " <port number to listen on>" << std::endl;
    onInit(port);

    while(1)
        onIdle();

    return 0;
}

Generated on Sat May 31 12:19:42 2008 for Touching by  doxygen 1.5.5