Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

XnVCircleDetector Class Reference

#include <XnVCircleDetector.h>

Inheritance diagram for XnVCircleDetector:
Inheritance graph
[legend]
Collaboration diagram for XnVCircleDetector:
Collaboration graph
[legend]

List of all members.

Public Types

enum  XnVNoCircleReason { NO_CIRCLE_ILLEGAL, NO_CIRCLE_NO_INPUT, NO_CIRCLE_BAD_POINTS, NO_CIRCLE_MANUAL }
typedef void(XN_CALLBACK_TYPE * CircleCB )(XnFloat fTimes, XnBool bConfident, const XnVCircle *pCircle, void *pUserCxt)
typedef void(XN_CALLBACK_TYPE * NoCircleCB )(XnFloat fLastValue, XnVNoCircleReason eReason, void *pUserCxt)

Public Member Functions

 XnVCircleDetector (const XnChar *strName="XnVCircleDetector")
 ~XnVCircleDetector ()
void OnPrimaryPointCreate (const XnVHandPointContext *pContext, const XnPoint3D &ptFocus)
void OnPrimaryPointUpdate (const XnVHandPointContext *pContext)
void OnPrimaryPointDestroy (XnUInt32 nID)
XnCallbackHandle RegisterCircle (void *cxt, CircleCB pCB)
XnCallbackHandle RegisterNoCircle (void *cxt, NoCircleCB pCB)
void UnregisterCircle (XnCallbackHandle handle)
void UnregisterNoCircle (XnCallbackHandle handle)
void Reset ()
XnStatus SetMinimumPoints (XnUInt32 nMinimumPoints)
XnStatus SetCloseToExistingRadius (XnFloat fCloseToExistingRadius)
XnStatus SetCloseEnough (XnFloat fCloseEnough)
XnStatus SetMinRadius (XnFloat fMinRadius)
XnStatus SetMaxRadius (XnFloat fMaxRadius)
XnStatus SetExistingWeight (XnFloat fExistingWeight)
XnStatus SetMaxErrors (XnUInt32 nMaxErrors)
XnStatus GetMinimumPoints (XnUInt32 &nMinimumPoints) const
XnStatus GetCloseToExistingRadius (XnFloat &fCloseToExistingRadius) const
XnStatus GetCloseEnough (XnFloat &fCloseEnough) const
XnStatus GetMinRadius (XnFloat &fMinRadius) const
XnStatus GetMaxRadius (XnFloat &fMaxRadius) const
XnStatus GetExistingWeight (XnFloat &fExistingWeight) const
XnStatus GetMaxErrors (XnUInt32 &nMaxErrors) const

Protected Member Functions

 XN_DECLARE_EVENT_2ARG (XnVNoCircleSpecificEvent, XnVNoCircleEvent, XnFloat, fValue, XnVNoCircleReason, eReason)
 XN_DECLARE_EVENT_3ARG (XnVCircleSpecificEvent, XnVCircleEvent, XnFloat, fTimes, XnBool, bConfidence, const XnVCircle *, pCircle)
void AddPoint (const XnPoint3D &pt, XnFloat fTime)

Protected Attributes

XnVCircleSolver * m_pCircleSolver
XnVCirclem_pCurrentCircle
XnFloat m_fCurrentAngle
XnInt32 m_nCircles
XnBool m_bCircleExists
XnUInt32 m_nErrors
XnUInt32 m_nMinimumPoints
XnFloat m_fCloseToExistingRadius
XnFloat m_fCloseEnough
XnFloat m_fMinRadius
XnFloat m_fMaxRadius
XnFloat m_fExistingWeight
XnFloat m_fNewRadiusWeight
XnUInt32 m_nMaxErrors
XnVPointBuffer * m_pMovementDetectionBuffer
XnVCircleSpecificEvent m_CircleCBs
XnVNoCircleSpecificEvent m_NoCircleCBs

Static Protected Attributes

static const XnUInt32 ms_nDefaultMinimumPoints
static const XnFloat ms_fDefaultCloseToExistingRadius
static const XnFloat ms_fDefaultCloseEnough
static const XnFloat ms_fDefaultMinRadius
static const XnFloat ms_fDefaultMaxRadius
static const XnFloat ms_fDefaultExistingWeight
static const XnUInt32 ms_nDefaultMaxErrors

Detailed Description

Identify a circle. This is done by starting from a single point, and finding points going further away, then back closer. A best fitting circle is found, and makes sure it really is a circle - there are points in all four quadrants. The circle must be a 'correct' size, its radius between a minimum and maximum allowed values. Once the circle exists, further points are matched to it, possibly slightly changing the center of the circle. Callbacks are called to inform the current position inside the circle and the number of circles complete. Clockwise circles are considered in a positive direction, and counter clockwise in a negative direction. A callback is also called when the points no longer describe a circle.

Definition at line 28 of file XnVCircleDetector.h.


Member Typedef Documentation

typedef void(XN_CALLBACK_TYPE * XnVCircleDetector::CircleCB)(XnFloat fTimes, XnBool bConfident, const XnVCircle *pCircle, void *pUserCxt)

Type for the circle event callbacks. Gives number of circles detected, confidence of current state, and the circle itself

Parameters:
[in] fTimes Number of circles already complete
[in] bConfident Confidence of the circle
[in] pCircle The circle that is used
[in] pUserCxt User's context, passed in the registration

Definition at line 51 of file XnVCircleDetector.h.

typedef void(XN_CALLBACK_TYPE * XnVCircleDetector::NoCircleCB)(XnFloat fLastValue, XnVNoCircleReason eReason, void *pUserCxt)

Type for the no-circle event callbacks. Gives the last value it had in the circle, and a reason.

Parameters:
[in] fLastValue Number of circles completed while the circle was detected
[in] eReason A reason as to why this is no longer a circle
[in] pUserCxt User's context, passed in the registration

Definition at line 59 of file XnVCircleDetector.h.


Member Enumeration Documentation

Reasons why there would be no available circle

Enumerator:
NO_CIRCLE_ILLEGAL 
NO_CIRCLE_NO_INPUT 
NO_CIRCLE_BAD_POINTS 
NO_CIRCLE_MANUAL 

Definition at line 35 of file XnVCircleDetector.h.


Constructor & Destructor Documentation

XnVCircleDetector::XnVCircleDetector ( const XnChar *  strName = "XnVCircleDetector"  ) 

Creation

Parameters:
[in] strName Name of the control, for log purposes.
XnVCircleDetector::~XnVCircleDetector (  ) 

Member Function Documentation

void XnVCircleDetector::AddPoint ( const XnPoint3D &  pt,
XnFloat  fTime 
) [protected]
XnStatus XnVCircleDetector::GetCloseEnough ( XnFloat &  fCloseEnough  )  const

Get how close (mms, distance squared) point should be to the original, to start considering it a circle. This is after the point has gotten further away and then back closer.

Parameters:
[out] fCloseEnough The threshold.
XnStatus XnVCircleDetector::GetCloseToExistingRadius ( XnFloat &  fCloseToExistingRadius  )  const

Get how close a point must be (in mms) to an existing circle to be considered a part of it.

Parameters:
[out] fCloseToExistingRadius The threshold.
XnStatus XnVCircleDetector::GetExistingWeight ( XnFloat &  fExistingWeight  )  const

Get the weight of the existing circle's radius (relative to the new point)

Parameters:
[out] fExistingWeight The threshold.
XnStatus XnVCircleDetector::GetMaxErrors ( XnUInt32 &  nMaxErrors  )  const

Get the number of points that don't match the circle but still stay in circle mode.

Parameters:
[out] nMaxErrors The threshold.
XnStatus XnVCircleDetector::GetMaxRadius ( XnFloat &  fMaxRadius  )  const

Get the maximal size (in mms) of a valid circle's radius. This is used when no existing circle exists.

Parameters:
[out] fMaxRadius The threshold.
XnStatus XnVCircleDetector::GetMinimumPoints ( XnUInt32 &  nMinimumPoints  )  const

Get the minimum number of points to consider a circle.

Parameters:
[out] nMinimumPoints The threshold.
XnStatus XnVCircleDetector::GetMinRadius ( XnFloat &  fMinRadius  )  const

Get the minimal size (in mms) of a valid circle's radius. This is used when no existing circle exists.

Parameters:
[out] fMinRadius The threshold.
void XnVCircleDetector::OnPrimaryPointCreate ( const XnVHandPointContext pContext,
const XnPoint3D &  ptFocus 
) [virtual]

Called when the primary point is created.

Parameters:
[in] pContext The hand context of the newly created primary point
[in] ptFocus The point in which the session has started.

Reimplemented from XnVPointControl.

void XnVCircleDetector::OnPrimaryPointDestroy ( XnUInt32  nID  )  [virtual]

Called when the primary point is destroyed.

Parameters:
[in] nID the ID of the last primary point

Reimplemented from XnVPointControl.

void XnVCircleDetector::OnPrimaryPointUpdate ( const XnVHandPointContext pContext  )  [virtual]

Called when the primary point is updated. This will cause the algorithm to detect circles.

Parameters:
[in] pContext The hand context of the updated primary point

Reimplemented from XnVPointControl.

XnCallbackHandle XnVCircleDetector::RegisterCircle ( void *  cxt,
CircleCB  pCB 
)

Register for the circle event

Parameters:
[in] cxt User's context
[in] pCB The Callback to call when the event is invoked.
Returns:
A handle, to allow unregistration.
XnCallbackHandle XnVCircleDetector::RegisterNoCircle ( void *  cxt,
NoCircleCB  pCB 
)

Register for the no-circle event

Parameters:
[in] cxt User's context
[in] pCB The Callback to call when the event is invoked.
Returns:
A handle, to allow unregistration.
void XnVCircleDetector::Reset (  ) 

Stop recognizing the circle. Will result in a NoCircle callback being called if a circle existed.

XnStatus XnVCircleDetector::SetCloseEnough ( XnFloat  fCloseEnough  ) 

Change how close (mms, distance squared) point should be to the original, to start considering it a circle. This is after the point has gotten further away and then back closer.

Parameters:
[in] fCloseEnough New threshold. Default is 1000
XnStatus XnVCircleDetector::SetCloseToExistingRadius ( XnFloat  fCloseToExistingRadius  ) 

Change how close a point must be (in mms) to an existing circle to be considered a part of it.

Parameters:
[in] fCloseToExistingRadius New threshold. Default is 50
XnStatus XnVCircleDetector::SetExistingWeight ( XnFloat  fExistingWeight  ) 

Change the weight of the existing circle's radius (relative to the new point)

Parameters:
[in] fExistingWeight New threshold. Default is 0.8 (which means 0.2 for the new point)
XnStatus XnVCircleDetector::SetMaxErrors ( XnUInt32  nMaxErrors  ) 

Change the number of points that don't match the circle but still stay in circle mode.

Parameters:
[in] nMaxErrors New threshold. Default is 5
XnStatus XnVCircleDetector::SetMaxRadius ( XnFloat  fMaxRadius  ) 

Change the maximal size (in mms) of a valid circle's radius. This is used when no existing circle exists.

Parameters:
[in] fMaxRadius New threshold. Default is 1200
XnStatus XnVCircleDetector::SetMinimumPoints ( XnUInt32  nMinimumPoints  ) 

Change the minimum number of points to consider a circle.

Parameters:
[in] nMinimumPoints New threshold. Default is 20.
XnStatus XnVCircleDetector::SetMinRadius ( XnFloat  fMinRadius  ) 

Change the minimal size (in mms) of a valid circle's radius. This is used when no existing circle exists.

Parameters:
[in] fMinRadius New threshold. Default is 40
void XnVCircleDetector::UnregisterCircle ( XnCallbackHandle  handle  ) 

Unregister from the circle event

Parameters:
[in] handle The handle provided on registration.
void XnVCircleDetector::UnregisterNoCircle ( XnCallbackHandle  handle  ) 

Unregister from the no-circle event

Parameters:
[in] handle The handle provided on registration.
XnVCircleDetector::XN_DECLARE_EVENT_2ARG ( XnVNoCircleSpecificEvent  ,
XnVNoCircleEvent  ,
XnFloat  ,
fValue  ,
XnVNoCircleReason  ,
eReason   
) [protected]
XnVCircleDetector::XN_DECLARE_EVENT_3ARG ( XnVCircleSpecificEvent  ,
XnVCircleEvent  ,
XnFloat  ,
fTimes  ,
XnBool  ,
bConfidence  ,
const XnVCircle ,
pCircle   
) [protected]

Member Data Documentation

Definition at line 226 of file XnVCircleDetector.h.

XnVCircleSpecificEvent XnVCircleDetector::m_CircleCBs [protected]

Definition at line 248 of file XnVCircleDetector.h.

XnFloat XnVCircleDetector::m_fCloseEnough [protected]

Definition at line 231 of file XnVCircleDetector.h.

Definition at line 230 of file XnVCircleDetector.h.

Definition at line 224 of file XnVCircleDetector.h.

Definition at line 234 of file XnVCircleDetector.h.

XnFloat XnVCircleDetector::m_fMaxRadius [protected]

Definition at line 233 of file XnVCircleDetector.h.

XnFloat XnVCircleDetector::m_fMinRadius [protected]

Definition at line 232 of file XnVCircleDetector.h.

Definition at line 235 of file XnVCircleDetector.h.

XnInt32 XnVCircleDetector::m_nCircles [protected]

Definition at line 225 of file XnVCircleDetector.h.

XnUInt32 XnVCircleDetector::m_nErrors [protected]

Definition at line 227 of file XnVCircleDetector.h.

XnUInt32 XnVCircleDetector::m_nMaxErrors [protected]

Definition at line 236 of file XnVCircleDetector.h.

Definition at line 229 of file XnVCircleDetector.h.

XnVNoCircleSpecificEvent XnVCircleDetector::m_NoCircleCBs [protected]

Definition at line 249 of file XnVCircleDetector.h.

XnVCircleSolver* XnVCircleDetector::m_pCircleSolver [protected]

Definition at line 221 of file XnVCircleDetector.h.

Definition at line 222 of file XnVCircleDetector.h.

XnVPointBuffer* XnVCircleDetector::m_pMovementDetectionBuffer [protected]

Definition at line 246 of file XnVCircleDetector.h.

const XnFloat XnVCircleDetector::ms_fDefaultCloseEnough [static, protected]

Definition at line 240 of file XnVCircleDetector.h.

const XnFloat XnVCircleDetector::ms_fDefaultCloseToExistingRadius [static, protected]

Definition at line 239 of file XnVCircleDetector.h.

const XnFloat XnVCircleDetector::ms_fDefaultExistingWeight [static, protected]

Definition at line 243 of file XnVCircleDetector.h.

const XnFloat XnVCircleDetector::ms_fDefaultMaxRadius [static, protected]

Definition at line 242 of file XnVCircleDetector.h.

const XnFloat XnVCircleDetector::ms_fDefaultMinRadius [static, protected]

Definition at line 241 of file XnVCircleDetector.h.

const XnUInt32 XnVCircleDetector::ms_nDefaultMaxErrors [static, protected]

Definition at line 244 of file XnVCircleDetector.h.

const XnUInt32 XnVCircleDetector::ms_nDefaultMinimumPoints [static, protected]

Definition at line 238 of file XnVCircleDetector.h.


The documentation for this class was generated from the following file: