All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
MultiTouch::Screen Class Reference

This class provides a high-level API to a touch-screen. More...

#include <MultiTouch/MultiTouch.hpp>

Public Types

typedef std::function< void(bool)> LicenseActivationWizardDisplayCallback
 

Public Member Functions

void addCVExtension (CVExtension *ext)
 Adds a new computer vision extension to be ran before the main image processing pipeline. More...
 
void commitUpdate ()
 Finish pending samples by setting latestSampleNumber = pendingSampleNumber.
 
float framesPerSecond () const
 Return the frame-rate of the touch-screen input sampling. More...
 
bool hasNetBridge () const
 Check if the tracker is using a NetBridge setup (i.e. More...
 
bool initialize (const char *configfile, const QString &licenseFile="", QString *errorMessage=nullptr, const char *appname=nullptr, Luminous::MultiHead *multiHead=nullptr)
 Initialize the touch-screen, based on settings in the configuration file. More...
 
bool initializeDummy (const QString &licenseFile, const char *appname=0, Luminous::MultiHead *multiHead=0)
 Initialize a dummy tracker. More...
 
bool initializeWithConfig (const Radiant::Config &config, const QString &licenseFile="", const char *appname=nullptr, Luminous::MultiHead *multiHead=nullptr)
 Same as initialize(), except configuration is given in-memory instead of as an file path. More...
 
Radiant::ConfiginputConfig ()
 Get the input configuration. More...
 
QString & inputConfigFileName ()
 Get the configuration filename. More...
 
bool isRunning () const
 Check if the touch-tracking is operational. More...
 
MultiTouch::Sample latestSample () const
 Get the latest sample. More...
 
int latestSampleNumber () const
 Returns the latest sample number. More...
 
int pendingSampleNumber () const
 Samples that are pending but not yet finalized by committing can still be modified. More...
 
void reloadConfiguration ()
 Reload the touch-screen configuration.
 
size_t ringBufferSize () const
 Get the ring-buffer size. More...
 
MultiTouch::Sample sample (size_t index) const
 Returns the sample with the given index. More...
 
 Screen ()
 Constructor.
 
void setLicenseActivationWizardDisplayCallback (LicenseActivationWizardDisplayCallback callback)
 This function is used to set a callback function for the license activation.
 
void setSaveSettingsOnExit (int save, const char *filename=0)
 Control whether the system saves settings on exit (default = false). More...
 
void stop ()
 Stops the touch-screen operation. More...
 
void synthesizeFingerInput (int sample, TrackedObject::Id handId, int handAge, TrackedObject::Id fingerId, int fingerAge, Nimble::Vector2 loc, Nimble::Vector2 motion, Nimble::Vector2 dir)
 Synthesize fake input data. More...
 
void synthesizeHandInput (int sample, TrackedObject::Id id, int age, Nimble::Vector2 loc)
 Synthesize fake input data. More...
 
void synthesizeMarkerInput (int sampleNo, TrackedObject::Id markerId, int markerAge, long code, Nimble::Vector2 loc, float rot, Nimble::Vector2 motion)
 Synthesize fake input data. More...
 
void synthesizePenInput (int sample, TrackedObject::Id penId, int penAge, Nimble::Vector2 loc, Nimble::Vector2 motion)
 Synthesize fake input data. More...
 
Nimble::Rect totalOutputArea () const
 The total output area of the multi-touch engine. More...
 
void update (unsigned timeoutMs, bool autoCommit=true)
 Update the ring-buffer. More...
 
 ~Screen ()
 Destructor.
 

Detailed Description

This class provides a high-level API to a touch-screen.

Typically there is a single instance of this class. This class stores the input sample data in a ring-buffer. This data is updated through update() function calls. The application can run faster or slower than the input capture rate. If the application does not process samples fast enough some are dropped.

Member Function Documentation

void MultiTouch::Screen::addCVExtension ( CVExtension *  ext)

Adds a new computer vision extension to be ran before the main image processing pipeline.

The extensions need to be added before the image processing can take place.

Parameters
extAn extension to the computer vision pipeline.
float MultiTouch::Screen::framesPerSecond ( ) const

Return the frame-rate of the touch-screen input sampling.

Returns
touch-screen frame-rate
bool MultiTouch::Screen::hasNetBridge ( ) const

Check if the tracker is using a NetBridge setup (i.e.

transmitting data over network).

Returns
true if the tracker is using NetBridge; otherwise false
bool MultiTouch::Screen::initialize ( const char *  configfile,
const QString &  licenseFile = "",
QString *  errorMessage = nullptr,
const char *  appname = nullptr,
Luminous::MultiHead multiHead = nullptr 
)

Initialize the touch-screen, based on settings in the configuration file.

Parameters
configfileA filename of text file that contains the parameters of all cameras.
licenseFilelicense file to use. Leave empty for default.
errorMessageignored
appnameapplication name for license check
multiHeadoptional multihead configuration for getting the default output area / input resolution. Used by TUIO import.
Returns
Returns true if the initialization was successful, false otherwise.
bool MultiTouch::Screen::initializeDummy ( const QString &  licenseFile,
const char *  appname = 0,
Luminous::MultiHead multiHead = 0 
)

Initialize a dummy tracker.

Initializes a dummy tracker that won't actually perform any input tracking. It only provides the mouse/keyboard emulation input support.

Parameters
licenseFilename of the license file to use. Leave empty for default.
Returns
true if initialization was successful; otherwise false
bool MultiTouch::Screen::initializeWithConfig ( const Radiant::Config config,
const QString &  licenseFile = "",
const char *  appname = nullptr,
Luminous::MultiHead multiHead = nullptr 
)

Same as initialize(), except configuration is given in-memory instead of as an file path.

See Also
initialize
Radiant::Config& MultiTouch::Screen::inputConfig ( )

Get the input configuration.

Returns
input configuration
QString& MultiTouch::Screen::inputConfigFileName ( )

Get the configuration filename.

Returns
configuration filename
bool MultiTouch::Screen::isRunning ( ) const

Check if the touch-tracking is operational.

Returns
true if the tracker is running
MultiTouch::Sample MultiTouch::Screen::latestSample ( ) const

Get the latest sample.

Returns
the latest sample available
int MultiTouch::Screen::latestSampleNumber ( ) const

Returns the latest sample number.

Returns
latest sample number
int MultiTouch::Screen::pendingSampleNumber ( ) const

Samples that are pending but not yet finalized by committing can still be modified.

Returns
latest pending sample number
size_t MultiTouch::Screen::ringBufferSize ( ) const

Get the ring-buffer size.

Returns
size of the ring-buffer in samples
MultiTouch::Sample MultiTouch::Screen::sample ( size_t  index) const

Returns the sample with the given index.

If the sample cannot be found (it is too old, or in the future), then null sample is returned.

Parameters
indexsample index to get
Returns
sample matching the index
void MultiTouch::Screen::setSaveSettingsOnExit ( int  save,
const char *  filename = 0 
)

Control whether the system saves settings on exit (default = false).

By default the tracker does not save settings as the application is stopped. In many cases you do want to save settings because they have been adjusted.

Parameters
saveIf save is zero nothing is saved. If save is non-zero configuration is saved. If save is two then all of the settings concerning configuration of machine vision is saved (applies only to MT467 & MT469).
filenameThe name of the file for saving the settings. If it is zero, then the original configuration file name will be used.
void MultiTouch::Screen::stop ( )

Stops the touch-screen operation.

Typically you do not need to call this function explicitly, as it is called in the object destructor automatically.

void MultiTouch::Screen::synthesizeFingerInput ( int  sample,
TrackedObject::Id  handId,
int  handAge,
TrackedObject::Id  fingerId,
int  fingerAge,
Nimble::Vector2  loc,
Nimble::Vector2  motion,
Nimble::Vector2  dir 
)

Synthesize fake input data.

This function can be used to generate simulated touch-input. Note that the fingerId and handId must be unique from the ids coming from the real computer vision system. In practice the best way to accomplish this is that your application has an internal counter for these values, and the counter starts from a large value (e.g. one billion) that is likely to be larger than any value coming from computer vision. If your application assumes that greater id values indicate newer hand/finger, this may be a problem - but only if you use fake input and real input at the same time.

Parameters
sampleSample number to inject the data, see Sample::index
handIdHand id to inject, corresponds to Hand::id
handAgeHand age to inject, corresponds to Hand::age
fingerIdFinger id to inject, corresponds to Finger::id
fingerAgeFinger age to inject, corresponds to Finger::age
locLocation of the finger tip, corresponds to Finger::tipLocation
motionMotion of the finger, corresponds to Finger::tipMotion
dirdirection of the finger tip, corresponds to Finger::tipDirection
void MultiTouch::Screen::synthesizeHandInput ( int  sample,
TrackedObject::Id  id,
int  age,
Nimble::Vector2  loc 
)

Synthesize fake input data.

This function can be used to generate simulated hand on the touch screen. This does not add any fingers to the hand. Those needs to be added afterwards using synthesizeFingerInput-function.

Parameters
sampleSample number to inject the data, see Sample::index
idHand id to inject, corresponds to Hand::id
ageHand age to inject, corresponds to Hand::age
locLocation of the hand palm, corresponds to Hand::palmCenter
void MultiTouch::Screen::synthesizeMarkerInput ( int  sampleNo,
TrackedObject::Id  markerId,
int  markerAge,
long  code,
Nimble::Vector2  loc,
float  rot,
Nimble::Vector2  motion 
)

Synthesize fake input data.

This function can be used to generate simulated marker-input. Note that the markerId must be unique from the ids coming from the real computer vision system.

See Also
synthesizeFingerInput
Parameters
sampleNoSample number to inject the data, see Sample::index
markerIdMarker id to inject, corresponds to Marker::id
markerAgeMarker age to inject, corresponds to Marker::age
codemarker code to inject, corresponds to Marker::code
locLocation of the marker, corresponds to Marker::centerLocation
rotRotation of the marker, corresponds to Marker::rotation
motionIgnored parameter, Marker doesn't have motion at the moment
void MultiTouch::Screen::synthesizePenInput ( int  sample,
TrackedObject::Id  penId,
int  penAge,
Nimble::Vector2  loc,
Nimble::Vector2  motion 
)

Synthesize fake input data.

This function can be used to generate simulated pen-input. Note that the penId must be unique from the ids coming from the real computer vision system.

See Also
synthesizeFingerInput
Parameters
sampleSample number to inject the data, see Sample::index
penIdPen id to inject, corresponds to Pen::id
penAgePen age to inject, corresponds to Pen::age
locLocation of the pen, corresponds to Pen::location
motionIgnored parameter, Pen doesn't have motion at the moment
Nimble::Rect MultiTouch::Screen::totalOutputArea ( ) const

The total output area of the multi-touch engine.

This function returns a rectangle that includes the nominal output area.

Returns
total output rectangle
void MultiTouch::Screen::update ( unsigned  timeoutMs,
bool  autoCommit = true 
)

Update the ring-buffer.

Gets a new sample from the tracker optionally blocking until a new sample is available. This will update latestSampleNumber if autoCommit is true, otherwise it will just update pendingSampleNumber.

Parameters
timeoutMshow many milliseconds to wait for a new sample.
autoCommitrun commitUpdate() automatically