NITE 1.4.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 00030 class XNV_NITE_API XnVSwipeDetector : 00031 public XnVPointControl 00032 { 00033 public: 00037 typedef void (XN_CALLBACK_TYPE *SwipeCB)(XnFloat fVelocity, XnFloat fAngle, void* pUserCxt); 00038 typedef void (XN_CALLBACK_TYPE *GeneralSwipeCB)(XnVDirection eDir, XnFloat fVelocity, XnFloat fAngle, void* pUserCxt); 00039 00046 XnVSwipeDetector(XnBool bUseSteadyBeforeSwipe = true, const XnChar* strName = "XnVSwipeDetector"); 00047 ~XnVSwipeDetector(); 00048 00055 void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus); 00062 void OnPrimaryPointUpdate(const XnVHandPointContext* pContext); 00070 void OnPrimaryPointReplace(XnUInt32 nOldId, const XnVHandPointContext* pContext); 00076 void OnPrimaryPointDestroy(XnUInt32 nID); 00080 void Reset(); 00081 00082 // Events 00091 XnCallbackHandle RegisterSwipeUp(void* cxt, SwipeCB pCB); // Add CB to list 00100 XnCallbackHandle RegisterSwipeDown(void* cxt, SwipeCB pCB); // Add CB to list 00109 XnCallbackHandle RegisterSwipeLeft(void* cxt, SwipeCB pCB); // Add CB to list 00118 XnCallbackHandle RegisterSwipeRight(void* cxt, SwipeCB pCB); // Add CB to list 00127 XnCallbackHandle RegisterSwipe(void* cxt, GeneralSwipeCB pCB); 00128 00134 void UnregisterSwipeUp(XnCallbackHandle handle); 00140 void UnregisterSwipeDown(XnCallbackHandle handle); 00146 void UnregisterSwipeLeft(XnCallbackHandle handle); 00152 void UnregisterSwipeRight(XnCallbackHandle handle); 00158 void UnregisterSwipe(XnCallbackHandle handle); 00159 00165 void SetMotionSpeedThreshold(XnFloat fThreshold); 00166 XnFloat GetMotionSpeedThreshold() const; 00167 00173 void SetMotionTime(XnUInt32 nThreshold); 00174 XnUInt32 GetMotionTime() const; 00175 00181 void SetXAngleThreshold(XnFloat fThreshold); 00182 XnFloat GetXAngleThreshold() const; 00183 00189 void SetYAngleThreshold(XnFloat fThreshold); 00190 XnFloat GetYAngleThreshold() const; 00191 00197 void SetSteadyMaxStdDev(XnFloat fStdDev); 00198 XnFloat GetSteadyMaxStdDev() const; 00199 00200 XnFloat XN_API_DEPRECATED("Use GetSteadyMaxStdDev() instead") 00201 GetSteadyMaxVelocity() const; 00202 void XN_API_DEPRECATED("Use SetSteadyMaxStdDev() instead") 00203 SetSteadyMaxVelocity(XnFloat fVelocity); 00204 00210 void SetSteadyDuration(XnUInt32 nDuration); 00211 XnUInt32 GetSteadyDuration() const; 00212 00213 void SetUseSteady(XnBool bUse); 00214 XnBool GetUseSteady() const; 00215 protected: 00216 XN_DECLARE_EVENT_3ARG(XnVGeneralSwipeSpecificEvent, XnVGeneralSwipeEvent, XnVDirection, eDir, XnFloat, fVelocity, XnFloat, fAngle); 00217 00218 XnStatus AddPoint(const XnPoint3D& pt, XnFloat fTime); 00219 00220 static void XN_CALLBACK_TYPE Steady_Steady(XnUInt32 nId, XnFloat fVelocity, void* cxt); 00221 00222 XnVPointBuffer* m_pMovementDetectionBuffer; 00223 00224 static const XnFloat ms_fDefaultMotionDetectionVelocity; // = 0.25f 00225 static const XnUInt32 ms_nDefaultMotionDetectionDuration; // = 350 ms 00226 00227 XnFloat m_fMotionDetectionSpeed; 00228 XnUInt32 m_nMotionDetectionTime; 00229 00230 XnFloat m_fLowestVelocity; 00231 XnBool m_bWaitingForSlowdown; 00232 00233 XnFloat m_fAngleXThreshold; 00234 XnFloat m_fAngleYThreshold; 00235 00236 XnVFloatFloatSpecificEvent* m_pPendingEvent; 00237 XnVDirection m_ePendingDirection; 00238 XnFloat m_fPendingVelocity; 00239 XnFloat m_fPendingAngle; 00240 00241 XnVFloatFloatSpecificEvent m_SwipeDownCBs, m_SwipeUpCBs, m_SwipeLeftCBs, m_SwipeRightCBs; 00242 00243 XnVGeneralSwipeSpecificEvent m_SwipeCBs; 00244 00245 XnBool m_bUseSteady; 00246 XnBool m_bInSteady; 00247 XnVSteadyDetector m_Steady; 00248 }; // XnVSwipeDetector 00249 00250 #endif // _XNV_SWIPE_DETECTOR_H_