All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
MultiWidgets::VirtualObject Class Referenceabstract

VirtualObject acts as a base class for each type of virtual object that can be injected to the input processing (hand with fingers, pen and marker). More...

#include <MultiWidgets/VirtualInput.hpp>

Inheritance diagram for MultiWidgets::VirtualObject:
MultiWidgets::VirtualFinger MultiWidgets::VirtualHand MultiWidgets::VirtualMarker MultiWidgets::VirtualPen

Public Member Functions

int age () const
 Age (number of frames detected) of object. More...
 
long id () const
 Id of the virtual object. More...
 
virtual void injectToSamples (MultiTouch::Screen &touchScreen, int sampleBegin, int sampleEnd)=0
 Injects virtual object to the samples coming from computer vision layer. More...
 
Nimble::Vector2f location () const
 Location of the object, that is only updated using setLocation. More...
 
virtual void move (Nimble::Vector2f d)
 Moves object by given vector. More...
 
Nimble::Vector2f previousLocation () const
 Returns the previous location of the object. More...
 
void setLocation (Nimble::Vector2f location)
 Sets the location of the object. More...
 
virtual VirtualInputType type () const =0
 Type of the object. More...
 
 VirtualObject (Nimble::Vector2f loc)
 Constructs new virtual object with proper id. More...
 
 VirtualObject (long id, Nimble::Vector2 loc)
 Constructs new virtual object with given id. More...
 
virtual ~VirtualObject ()
 Destructor.
 

Protected Member Functions

void increaseAge (int frames=1)
 Increases the age of the virtual object. More...
 
void setPreviousLocation (Nimble::Vector2f loc)
 Sets the previous location of the object. More...
 

Detailed Description

VirtualObject acts as a base class for each type of virtual object that can be injected to the input processing (hand with fingers, pen and marker).

It collects the common features and functionality for synthesizing the objects.

Every object returned by tracker has id, age, location and motion. Id is persistent for the object, it stays the same as long as tracker can follow the object. The location depends on the location of the object. Age is the number of frames that object is detected. Motion is the movement of the object.

When one uses virtual objects it is often enough to provide location (and the code in the case of markers). Motion, age and id are generated and calculated automatically by default based on how the virtual objects are injected to touch screen samples.

Constructor & Destructor Documentation

MultiWidgets::VirtualObject::VirtualObject ( Nimble::Vector2f  loc)
explicit

Constructs new virtual object with proper id.

Parameters
locLocation where the object is placed
MultiWidgets::VirtualObject::VirtualObject ( long  id,
Nimble::Vector2  loc 
)

Constructs new virtual object with given id.

Parameters
idId for the virtual object
locLocation where the object is placed

Member Function Documentation

int MultiWidgets::VirtualObject::age ( ) const

Age (number of frames detected) of object.

Returns
How many frames the object has been detected
long MultiWidgets::VirtualObject::id ( ) const

Id of the virtual object.

Returns
Id
void MultiWidgets::VirtualObject::increaseAge ( int  frames = 1)
protected

Increases the age of the virtual object.

Parameters
framesFow many frames the age of the object is increased with.
virtual void MultiWidgets::VirtualObject::injectToSamples ( MultiTouch::Screen touchScreen,
int  sampleBegin,
int  sampleEnd 
)
pure virtual

Injects virtual object to the samples coming from computer vision layer.

Calling this function in correct place is vital when injecting virtual objects to Cornerstone's input handling framework. This function needs to be called after the samples from computer vision are fetched and before any of the Application's input handling is done. MultiWidgets::Application sends event before-input at that moment. If this is called anywhere else the results are undefined.

This function injects the artificial input described by virtual object to the multiple samples at a time. The location of the object in the samples is linearly interpolated from previous and current location. Finally the previous location is updated by the function. Same applies for the other features of the tracked object (f.ex. rotation of markers or direction of fingers).

Parameters
touchScreenThe synthesized input is injected to this touchscreen's samples
sampleBeginIndex of the first sample to handle
sampleEndIndex of the last sample (inclusive) to handle

Implemented in MultiWidgets::VirtualMarker, MultiWidgets::VirtualPen, MultiWidgets::VirtualFinger, and MultiWidgets::VirtualHand.

Nimble::Vector2f MultiWidgets::VirtualObject::location ( ) const

Location of the object, that is only updated using setLocation.

Returns
Location of the object in screen (pixel) coordinates
See Also
setLocation
virtual void MultiWidgets::VirtualObject::move ( Nimble::Vector2f  d)
virtual

Moves object by given vector.

Parameters
dVector to apply to the current location

Reimplemented in MultiWidgets::VirtualHand.

Nimble::Vector2f MultiWidgets::VirtualObject::previousLocation ( ) const

Returns the previous location of the object.

This is internally updated during the calls of injectToSamples. Motion of the object is linearly interpolated using this value and the current location.

Returns
Location that object had when injectToSamples was called previous time.
See Also
injectToSamples
location
void MultiWidgets::VirtualObject::setLocation ( Nimble::Vector2f  location)

Sets the location of the object.

Parameters
locationNew location of the object in screen (pixel) coordinates
void MultiWidgets::VirtualObject::setPreviousLocation ( Nimble::Vector2f  loc)
protected

Sets the previous location of the object.

Parameters
locLocation to set as previous location.
See Also
location
virtual VirtualInputType MultiWidgets::VirtualObject::type ( ) const
pure virtual

Type of the object.

Returns
Type of the virtual object

Implemented in MultiWidgets::VirtualMarker, MultiWidgets::VirtualPen, MultiWidgets::VirtualFinger, and MultiWidgets::VirtualHand.