NITE 1.5.1 - API Reference

XnVCircleDetector.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *                                                                              *
00003 *   PrimeSense NITE 1.3                                                        *
00004 *   Copyright (C) 2010 PrimeSense Ltd.                                         *
00005 *                                                                              *
00006 *******************************************************************************/
00007 
00008 
00009 #ifndef _XNV_CIRCLE_DETECTOR_H_
00010 #define _XNV_CIRCLE_DETECTOR_H_
00011 
00012 #include "XnVPointControl.h"
00013 #include "XnVNiteDefs.h"
00014 #include "XnVCircle.h"
00015 
00016 class XnVPointBuffer;
00017 class XnVCircleSolver;
00018 
00019 class XnVNoCircleSpecificEvent;
00020 class XnVCircleSpecificEvent;
00021 
00031 class XNV_NITE_API XnVCircleDetector :
00032     public XnVPointControl
00033 {
00034 public:
00038     enum XnVNoCircleReason
00039     {
00040         NO_CIRCLE_ILLEGAL,
00041         NO_CIRCLE_NO_INPUT,
00042         NO_CIRCLE_BAD_POINTS,
00043         NO_CIRCLE_MANUAL
00044     };
00045 
00054     typedef void (XN_CALLBACK_TYPE *CircleCB)(XnFloat fTimes, XnBool bConfident, const XnVCircle* pCircle, void* pUserCxt);
00062     typedef void (XN_CALLBACK_TYPE *NoCircleCB)(XnFloat fLastValue, XnVNoCircleReason eReason, void* pUserCxt);
00063 
00069     XnVCircleDetector(const XnChar* strName = "XnVCircleDetector");
00070     ~XnVCircleDetector();
00071 
00078     void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus);
00085     void OnPrimaryPointUpdate(const XnVHandPointContext* pContext);
00091     void OnPrimaryPointDestroy(XnUInt32 nID);
00092 
00101     XnCallbackHandle RegisterCircle(void* cxt, CircleCB pCB);
00110     XnCallbackHandle RegisterNoCircle(void* cxt, NoCircleCB pCB);
00111 
00117     void UnregisterCircle(XnCallbackHandle handle);
00123     void UnregisterNoCircle(XnCallbackHandle handle);
00124 
00128     void Reset();
00129 
00135     XnStatus SetMinimumPoints(XnUInt32 nMinimumPoints);
00141     XnStatus SetCloseToExistingRadius(XnFloat fCloseToExistingRadius);
00148     XnStatus SetCloseEnough(XnFloat fCloseEnough);
00154     XnStatus SetMinRadius(XnFloat fMinRadius);
00160     XnStatus SetMaxRadius(XnFloat fMaxRadius);
00166     XnStatus SetExistingWeight(XnFloat fExistingWeight);
00172     XnStatus SetMaxErrors(XnUInt32 nMaxErrors);
00173 
00179     XnStatus GetMinimumPoints(XnUInt32& nMinimumPoints) const;
00185     XnStatus GetCloseToExistingRadius(XnFloat& fCloseToExistingRadius) const;
00192     XnStatus GetCloseEnough(XnFloat& fCloseEnough) const;
00198     XnStatus GetMinRadius(XnFloat& fMinRadius) const;
00204     XnStatus GetMaxRadius(XnFloat& fMaxRadius) const;
00210     XnStatus GetExistingWeight(XnFloat& fExistingWeight) const;
00216     XnStatus GetMaxErrors(XnUInt32& nMaxErrors) const;
00217 
00218 protected:
00219     void AddPoint(const XnPoint3D& pt, XnFloat fTime);
00220 
00221     XnVCircleSolver* m_pCircleSolver;
00222     XnVCircle* m_pCurrentCircle;
00223 
00224     XnFloat m_fCurrentAngle;
00225     XnInt32 m_nCircles;
00226     XnBool m_bCircleExists;
00227     XnUInt32 m_nErrors;
00228 
00229     XnUInt32 m_nMinimumPoints;
00230     XnFloat m_fCloseToExistingRadius;
00231     XnFloat m_fCloseEnough;
00232     XnFloat m_fMinRadius;
00233     XnFloat m_fMaxRadius;
00234     XnFloat m_fExistingWeight;
00235     XnFloat m_fNewRadiusWeight;
00236     XnUInt32 m_nMaxErrors;
00237 
00238     static const XnUInt32 ms_nDefaultMinimumPoints;     // = 20
00239     static const XnFloat ms_fDefaultCloseToExistingRadius;  // = 50
00240     static const XnFloat ms_fDefaultCloseEnough;            // = 1000
00241     static const XnFloat ms_fDefaultMinRadius;              // = 40
00242     static const XnFloat ms_fDefaultMaxRadius;              // = 1200
00243     static const XnFloat ms_fDefaultExistingWeight;     // = 0.8f
00244     static const XnUInt32 ms_nDefaultMaxErrors;         // = 5
00245 
00246     XnVPointBuffer* m_pMovementDetectionBuffer;
00247 
00248     XnVCircleSpecificEvent* m_pCircleCBs;
00249     XnVNoCircleSpecificEvent* m_pNoCircleCBs;
00250 };
00251 
00252 #endif // _XNV_CIRCLE_DETECTOR_H_