Go to the documentation of this file.00001
00002
00003
00004
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
00028 class XNV_NITE_API XnVCircleDetector :
00029 public XnVPointControl
00030 {
00031 public:
00035 enum XnVNoCircleReason
00036 {
00037 NO_CIRCLE_ILLEGAL,
00038 NO_CIRCLE_NO_INPUT,
00039 NO_CIRCLE_BAD_POINTS,
00040 NO_CIRCLE_MANUAL
00041 };
00042
00051 typedef void (XN_CALLBACK_TYPE *CircleCB)(XnFloat fTimes, XnBool bConfident, const XnVCircle* pCircle, void* pUserCxt);
00059 typedef void (XN_CALLBACK_TYPE *NoCircleCB)(XnFloat fLastValue, XnVNoCircleReason eReason, void* pUserCxt);
00060
00066 XnVCircleDetector(const XnChar* strName = "XnVCircleDetector");
00067 ~XnVCircleDetector();
00068
00075 void OnPrimaryPointCreate(const XnVHandPointContext* pContext, const XnPoint3D& ptFocus);
00082 void OnPrimaryPointUpdate(const XnVHandPointContext* pContext);
00088 void OnPrimaryPointDestroy(XnUInt32 nID);
00089
00098 XnCallbackHandle RegisterCircle(void* cxt, CircleCB pCB);
00107 XnCallbackHandle RegisterNoCircle(void* cxt, NoCircleCB pCB);
00108
00114 void UnregisterCircle(XnCallbackHandle handle);
00120 void UnregisterNoCircle(XnCallbackHandle handle);
00121
00125 void Reset();
00126
00132 XnStatus SetMinimumPoints(XnUInt32 nMinimumPoints);
00138 XnStatus SetCloseToExistingRadius(XnFloat fCloseToExistingRadius);
00145 XnStatus SetCloseEnough(XnFloat fCloseEnough);
00151 XnStatus SetMinRadius(XnFloat fMinRadius);
00157 XnStatus SetMaxRadius(XnFloat fMaxRadius);
00163 XnStatus SetExistingWeight(XnFloat fExistingWeight);
00169 XnStatus SetMaxErrors(XnUInt32 nMaxErrors);
00170
00176 XnStatus GetMinimumPoints(XnUInt32& nMinimumPoints) const;
00182 XnStatus GetCloseToExistingRadius(XnFloat& fCloseToExistingRadius) const;
00189 XnStatus GetCloseEnough(XnFloat& fCloseEnough) const;
00195 XnStatus GetMinRadius(XnFloat& fMinRadius) const;
00201 XnStatus GetMaxRadius(XnFloat& fMaxRadius) const;
00207 XnStatus GetExistingWeight(XnFloat& fExistingWeight) const;
00213 XnStatus GetMaxErrors(XnUInt32& nMaxErrors) const;
00214
00215 protected:
00216 XN_DECLARE_EVENT_2ARG(XnVNoCircleSpecificEvent, XnVNoCircleEvent, XnFloat, fValue, XnVNoCircleReason, eReason);
00217 XN_DECLARE_EVENT_3ARG(XnVCircleSpecificEvent, XnVCircleEvent, XnFloat, fTimes, XnBool, bConfidence, const XnVCircle*, pCircle);
00218
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;
00239 static const XnFloat ms_fDefaultCloseToExistingRadius;
00240 static const XnFloat ms_fDefaultCloseEnough;
00241 static const XnFloat ms_fDefaultMinRadius;
00242 static const XnFloat ms_fDefaultMaxRadius;
00243 static const XnFloat ms_fDefaultExistingWeight;
00244 static const XnUInt32 ms_nDefaultMaxErrors;
00245
00246 XnVPointBuffer* m_pMovementDetectionBuffer;
00247
00248 XnVCircleSpecificEvent m_CircleCBs;
00249 XnVNoCircleSpecificEvent m_NoCircleCBs;
00250 };
00251
00252 #endif // _XNV_CIRCLE_DETECTOR_H_