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>
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... | |
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.
|
explicit |
Constructs new virtual object with proper id.
| loc | Location where the object is placed |
| MultiWidgets::VirtualObject::VirtualObject | ( | long | id, |
| Nimble::Vector2 | loc | ||
| ) |
Constructs new virtual object with given id.
| id | Id for the virtual object |
| loc | Location where the object is placed |
| int MultiWidgets::VirtualObject::age | ( | ) | const |
Age (number of frames detected) of object.
| long MultiWidgets::VirtualObject::id | ( | ) | const |
Id of the virtual object.
|
protected |
Increases the age of the virtual object.
| frames | Fow many frames the age of the object is increased with. |
|
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).
| touchScreen | The synthesized input is injected to this touchscreen's samples |
| sampleBegin | Index of the first sample to handle |
| sampleEnd | Index 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.
|
virtual |
Moves object by given vector.
| d | Vector 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.
| void MultiWidgets::VirtualObject::setLocation | ( | Nimble::Vector2f | location | ) |
Sets the location of the object.
| location | New location of the object in screen (pixel) coordinates |
|
protected |
Sets the previous location of the object.
| loc | Location to set as previous location. |
|
pure virtual |
Type of the object.
Implemented in MultiWidgets::VirtualMarker, MultiWidgets::VirtualPen, MultiWidgets::VirtualFinger, and MultiWidgets::VirtualHand.