NITE 1.5.1 - API Reference
|
00001 /******************************************************************************* 00002 * * 00003 * PrimeSense NITE 1.3 * 00004 * Copyright (C) 2010 PrimeSense Ltd. * 00005 * * 00006 *******************************************************************************/ 00007 00008 00009 #ifndef _XNV_SWIPE_DETECTOR_H_ 00010 #define _XNV_SWIPE_DETECTOR_H_ 00011 00012 #include "XnVNiteDefs.h" 00013 #include "XnVPointControl.h" 00014 #include "XnVDirection.h" 00015 00016 #include "XnVSteadyDetector.h" 00017 00018 class XnVPointBuffer; 00019 class XnVFloatFloatSpecificEvent; 00020 class XnVGeneralSwipeSpecificEvent; 00031 class XNV_NITE_API XnVSwipeDetector : 00032 public XnVPointControl 00033 { 00034 public: 00038 typedef void (XN_CALLBACK_TYPE *SwipeCB)(XnFloat fVelocity, XnFloat fAngle, void* pUserCxt); 00039 typedef void (XN_CALLBACK_TYPE *GeneralSwipeCB)(XnVDirection eDir, XnFloat fVelocity, XnFloat fAngle, void* pUserCxt); 00040 00047 XnVSwipeDetector(XnBool bUseSteadyBeforeSwipe = true, const XnChar* strName = "XnVSwipeDetector"); 00048 ~XnVSwipeDetector(); 00049 00056 void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus); 00063 void OnPrimaryPointUpdate(const XnVHandPointContext* pContext); 00071 void OnPrimaryPointReplace(XnUInt32 nOldId, const XnVHandPointContext* pContext); 00077 void OnPrimaryPointDestroy(XnUInt32 nID); 00081 void Reset(); 00082 00083 // Events 00092 XnCallbackHandle RegisterSwipeUp(void* cxt, SwipeCB pCB); // Add CB to list 00101 XnCallbackHandle RegisterSwipeDown(void* cxt, SwipeCB pCB); // Add CB to list 00110 XnCallbackHandle RegisterSwipeLeft(void* cxt, SwipeCB pCB); // Add CB to list 00119 XnCallbackHandle RegisterSwipeRight(void* cxt, SwipeCB pCB); // Add CB to list 00128 XnCallbackHandle RegisterSwipe(void* cxt, GeneralSwipeCB pCB); 00129 00135 void UnregisterSwipeUp(XnCallbackHandle handle); 00141 void UnregisterSwipeDown(XnCallbackHandle handle); 00147 void UnregisterSwipeLeft(XnCallbackHandle handle); 00153 void UnregisterSwipeRight(XnCallbackHandle handle); 00159 void UnregisterSwipe(XnCallbackHandle handle); 00160 00166 void SetMotionSpeedThreshold(XnFloat fThreshold); 00167 XnFloat GetMotionSpeedThreshold() const; 00168 00174 void SetMotionTime(XnUInt32 nThreshold); 00175 XnUInt32 GetMotionTime() const; 00176 00182 void SetXAngleThreshold(XnFloat fThreshold); 00183 XnFloat GetXAngleThreshold() const; 00184 00190 void SetYAngleThreshold(XnFloat fThreshold); 00191 XnFloat GetYAngleThreshold() const; 00192 00198 void SetSteadyMaxStdDev(XnFloat fStdDev); 00199 XnFloat GetSteadyMaxStdDev() const; 00200 00201 XnFloat XN_API_DEPRECATED("Use GetSteadyMaxStdDev() instead") 00202 GetSteadyMaxVelocity() const; 00203 void XN_API_DEPRECATED("Use SetSteadyMaxStdDev() instead") 00204 SetSteadyMaxVelocity(XnFloat fVelocity); 00205 00211 void SetSteadyDuration(XnUInt32 nDuration); 00212 XnUInt32 GetSteadyDuration() const; 00213 00214 void SetUseSteady(XnBool bUse); 00215 XnBool GetUseSteady() const; 00216 protected: 00217 XnStatus AddPoint(const XnPoint3D& pt, XnFloat fTime); 00218 00219 static void XN_CALLBACK_TYPE Steady_Steady(XnUInt32 nId, XnFloat fVelocity, void* cxt); 00220 00221 XnVPointBuffer* m_pMovementDetectionBuffer; 00222 00223 static const XnFloat ms_fDefaultMotionDetectionVelocity; // = 0.25f 00224 static const XnUInt32 ms_nDefaultMotionDetectionDuration; // = 350 ms 00225 00226 XnFloat m_fMotionDetectionSpeed; 00227 XnUInt32 m_nMotionDetectionTime; 00228 00229 XnFloat m_fLowestVelocity; 00230 XnBool m_bWaitingForSlowdown; 00231 00232 XnFloat m_fAngleXThreshold; 00233 XnFloat m_fAngleYThreshold; 00234 00235 XnVFloatFloatSpecificEvent* m_pPendingEvent; 00236 XnVDirection m_ePendingDirection; 00237 XnFloat m_fPendingVelocity; 00238 XnFloat m_fPendingAngle; 00239 00240 XnVFloatFloatSpecificEvent* m_pSwipeDownCBs; 00241 XnVFloatFloatSpecificEvent* m_pSwipeUpCBs; 00242 XnVFloatFloatSpecificEvent* m_pSwipeLeftCBs; 00243 XnVFloatFloatSpecificEvent* m_pSwipeRightCBs; 00244 00245 XnVGeneralSwipeSpecificEvent* m_pSwipeCBs; 00246 00247 XnBool m_bUseSteady; 00248 XnBool m_bInSteady; 00249 XnVSteadyDetector m_Steady; 00250 }; // XnVSwipeDetector 00251 00252 #endif // _XNV_SWIPE_DETECTOR_H_