1 #ifndef NUITRACK_GESTURE_RECOGNIZER_H_
2 #define NUITRACK_GESTURE_RECOGNIZER_H_
6 #include "nuitrack/modules/HeaderOnlyAPI_Module.h"
7 #include "nuitrack/types/Export.h"
8 #include "nuitrack/types/GestureData.h"
9 #include "nuitrack/capi/GestureRecognizer_CAPI.h"
10 #include "nuitrack/utils/ExceptionTranslator.h"
11 #include "nuitrack/utils/CallbackStruct.h"
36 typedef std::shared_ptr<GestureRecognizer> Ptr;
68 typedef std::function<void (UserGesturesStateData::Ptr)>
OnUpdate;
78 static GestureRecognizer::Ptr
create()
80 NuitrackModule* pimpl = NULL;
81 ExceptionType exception_code = nuitrack_CreateGestureRecognizer(&pimpl);
82 ExceptionTranslator::generateExceptionByErrorCode(exception_code);
92 _onUserStateChangeCallbackStruct =
new CallbackStruct<UserStateData::Ptr>();
93 _onUpdateCallbackStruct =
new CallbackStruct<UserGesturesStateData::Ptr>();
104 nuitrack_DestroyGestureRecognizer(
_pimpl);
142 return _onUserStateChangeCallbackStruct->addCallback(callback);
153 _onUserStateChangeCallbackStruct->deleteCallback(handler);
166 return _onUpdateCallbackStruct->addCallback(callback);
177 _onUpdateCallbackStruct->deleteCallback(handler);
185 return nuitrack_GetGestureRecognizerProcessingTime(
_pimpl);
198 nuitrack_UserGesturesSetControlStatus(
_pimpl, status);
206 if(_onUserStateChangeCallbackStruct)
207 delete _onUserStateChangeCallbackStruct;
208 if(_onUpdateCallbackStruct)
209 delete _onUpdateCallbackStruct;
212 bool canUpdate()
const
214 return nuitrack_GetNuitrackModuleCanUpdate(
_pimpl);
225 return nuitrack_GetNuitrackModuleTimestamp(
_pimpl);
238 UserStateData::Ptr newFrame = UserStateData::Ptr(
new UserStateData(data));
239 tracker->_onUserStateChangeCallbackStruct->executeAllCallbacks(newFrame);
245 tracker->_onUpdateCallbackStruct->executeAllCallbacks(newFrame);
253 CallbackStruct<UserStateData::Ptr>* _onUserStateChangeCallbackStruct;
254 CallbackStruct<UserGesturesStateData::Ptr>* _onUpdateCallbackStruct;
Represents the interface to the capabilities of the Nuitrack Gesture Recognizer module.
Definition: GestureRecognizer.h:33
std::function< void(UserStateData::Ptr)> OnUserStateChange
The callback type of the user state change event.
Definition: GestureRecognizer.h:57
static GestureRecognizer::Ptr create()
Create the GestureRecognizer module object.
Definition: GestureRecognizer.h:78
float getProcessingTime() const
Returns last gesture recognition time in milliseconds.
Definition: GestureRecognizer.h:183
Stores the results of user state estimation.
Definition: GestureData.h:84
void disconnectOnUserStateChange(uint64_t handler)
Remove a callback of the user state change event.
Definition: GestureRecognizer.h:151
ExceptionType
Possible error codes for Nuitrack internal functions.
Definition: Error.h:20
void destroyGestureRecognizer()
Definition: GestureRecognizer.h:202
Stores the results of gesture estimation.
Definition: GestureData.h:16
void disconnectOnNewGestures(uint64_t handler)
Remove a callback of the new gesture detection event.
Definition: GestureRecognizer.h:127
GestureRecognizerCallbackWrapper _callbackWrapper
Definition: GestureRecognizer.h:250
void setControlGesturesStatus(bool status)
Set control gesture recognition state.
Definition: GestureRecognizer.h:196
Stores the results of estimation of the state of gestures for every tracked user. ...
Definition: GestureData.h:152
static void onNewGesturesCallback(GestureRecognizerData *data, GestureRecognizer *tracker)
Definition: GestureRecognizer.h:230
NuitrackModule * _pimpl
Definition: GestureRecognizer.h:248
std::function< void(UserGesturesStateData::Ptr)> OnUpdate
The callback type of the user gesture data update request.
Definition: GestureRecognizer.h:68
uint64_t connectOnUpdate(const OnUpdate &callback)
Add a callback for the gesture state data update request.
Definition: GestureRecognizer.h:164
GestureRecognizer(NuitrackModule *pimpl)
Definition: GestureRecognizer.h:87
uint64_t connectOnNewGestures(const OnNewGestures &callback)
Add a callback for the new gesture detection event.
Definition: GestureRecognizer.h:116
CallbackStruct< GestureData::Ptr > * _onNewGesturesCallbackStruct
Definition: GestureRecognizer.h:252
static void onUserStateChangeCallback(UsersStateChanges *data, GestureRecognizer *tracker)
Definition: GestureRecognizer.h:236
std::function< void(GestureData::Ptr)> OnNewGestures
The callback type of the new gesture detection event.
Definition: GestureRecognizer.h:46
static void onUpdateCallback(GestureRecognizerUserGesturesStateData *data, GestureRecognizer *tracker)
Definition: GestureRecognizer.h:242
virtual uint64_t getTimestamp()
Returns the last processed data timestamp in microseconds.
Definition: GestureRecognizer.h:223
uint64_t connectOnUserStateChange(const OnUserStateChange &callback)
Add a callback for the user state change event.
Definition: GestureRecognizer.h:140
void disconnectOnUpdate(uint64_t handler)
Remove a callback of the gesture state data update request.
Definition: GestureRecognizer.h:175