User Generator
C Reference » Production Nodes Functionality

## Topics

| Skeleton Capability
| Pose Detection Capability
| Hand Touching FOV Edge Capability

## Functions

XN_C_API XnStatus XN_C_DECL | xnCreateUserGenerator (XnContext *pContext, XnNodeHandle *phUserGenerator, XnNodeQuery *pQuery, XnEnumerationErrors *pErrors)
XN_C_API XnUInt16 XN_C_DECL | xnGetNumberOfUsers (XnNodeHandle hInstance)
XN_C_API XnStatus XN_C_DECL | xnGetUsers (XnNodeHandle hInstance, XnUserID *pUsers, XnUInt16 *pnUsers)
XN_C_API XnStatus XN_C_DECL | xnGetUserCoM (XnNodeHandle hInstance, XnUserID user, XnPoint3D *pCoM)
XN_C_API XnStatus XN_C_DECL | xnGetUserPixels (XnNodeHandle hInstance, XnUserID user, XnSceneMetaData *pScene)
XN_C_API XnStatus XN_C_DECL | xnRegisterUserCallbacks (XnNodeHandle hInstance, XnUserHandler NewUserCB, XnUserHandler LostUserCB, void *pCookie, XnCallbackHandle *phCallback)
XN_C_API void XN_C_DECL | xnUnregisterUserCallbacks (XnNodeHandle hInstance, XnCallbackHandle hCallback)
XN_C_API XnStatus XN_C_DECL | xnRegisterToUserExit (XnNodeHandle hInstance, XnUserHandler handler, void *pCookie, XnCallbackHandle *phCallback)
XN_C_API void XN_C_DECL | xnUnregisterFromUserExit (XnNodeHandle hInstance, XnCallbackHandle hCallback)
XN_C_API XnStatus XN_C_DECL | xnRegisterToUserReEnter (XnNodeHandle hInstance, XnUserHandler handler, void *pCookie, XnCallbackHandle *phCallback)
XN_C_API void XN_C_DECL | xnUnregisterFromUserReEnter (XnNodeHandle hInstance, XnCallbackHandle hCallback)

## Detailed Description

A User Generator node is a Generator that identifies a user in the scene. It supports all Generator functions, and adds additional functions.

## Function Documentation

## xnCreateUserGenerator()

XN_C_API XnStatus XN_C_DECL xnCreateUserGenerator | ( | XnContext * | pContext,
|  | XnNodeHandle * | phUserGenerator,
|  | XnNodeQuery * | pQuery,
|  | XnEnumerationErrors * | pErrors )

Creates a user generator.

Parameters

  pContext | [in] The context in which to create the user generator.
  phUserGenerator | [out] A handle to the created user generator.
  pQuery | [in] Optional. Can be used to select which user generator to create. If not specified, this function may create any user generator that is available.
  pErrors | [in] Optional. If provided, will be filled with information about user generators that could not be created.

## xnGetNumberOfUsers()

XN_C_API XnUInt16 XN_C_DECL xnGetNumberOfUsers | ( | XnNodeHandle | hInstance | ) |

Get current number of users.

Parameters

  hInstance | [in] A handle to the instance

## xnGetUserCoM()

XN_C_API XnStatus XN_C_DECL xnGetUserCoM | ( | XnNodeHandle | hInstance,
|  | XnUserID | user,
|  | XnPoint3D * | pCoM )

Get the center of mass of a user.

Parameters

  hInstance | [in] A handle to the instance
  user | [in] The user for which to get the center of mass
  pCoM | [out] The center of mass

## xnGetUserPixels()

XN_C_API XnStatus XN_C_DECL xnGetUserPixels | ( | XnNodeHandle | hInstance,
|  | XnUserID | user,
|  | XnSceneMetaData * | pScene )

Get the pixels that belong to a user.

The output is in a XnSceneMetaData object, holding a map of the pixels of the scene, with the user's label as the value in the places corresponding with the user's pixels. Pixels outside the user will not contain the user's ID. ID 0 means a request for the pixels of all users. In this case, the background will get the label 0.

Parameters

  hInstance | [in] A handle to the instance
  user | [in] The user for which to get the pixels
  pScene | [out] XnSceneMetaData object, that holds the pixels of the user

## xnGetUsers()

XN_C_API XnStatus XN_C_DECL xnGetUsers | ( | XnNodeHandle | hInstance,
|  | XnUserID * | pUsers,
|  | XnUInt16 * | pnUsers )

Get the current users.

Parameters

  hInstance | [in] A handle to the instance
  pUsers | [out] Preallocated memory for the users
  pnUsers | [in,out] The size of the preallocated memory. Changes to the number of users

## xnRegisterToUserExit()

XN_C_API XnStatus XN_C_DECL xnRegisterToUserExit | ( | XnNodeHandle | hInstance,
|  | XnUserHandler | handler,
|  | void * | pCookie,
|  | XnCallbackHandle * | phCallback )

Register to when the user exits the scene (but not lost yet).

Parameters

  hInstance | [in] A handle to the instance
  handler | [in] Callback to be called when a user leaves the scene
  pCookie | [in] User's cookie, to be delivered to the callbacks
  phCallback | [out] The handle to this callback, to allow unregistration

## xnRegisterToUserReEnter()

XN_C_API XnStatus XN_C_DECL xnRegisterToUserReEnter | ( | XnNodeHandle | hInstance,
|  | XnUserHandler | handler,
|  | void * | pCookie,
|  | XnCallbackHandle * | phCallback )

Register to when a user re-enters the scene after exiting.

Parameters

  hInstance | [in] A handle to the instance
  handler | [in] Callback to be called when a user leaves the scene
  pCookie | [in] User's cookie, to be delivered to the callbacks
  phCallback | [out] The handle to this callback, to allow unregistration

## xnRegisterUserCallbacks()

XN_C_API XnStatus XN_C_DECL xnRegisterUserCallbacks | ( | XnNodeHandle | hInstance,
|  | XnUserHandler | NewUserCB,
|  | XnUserHandler | LostUserCB,
|  | void * | pCookie,
|  | XnCallbackHandle * | phCallback )

Register to user callbacks.

Parameters

  hInstance | [in] A handle to the instance
  NewUserCB | [in] Callback to be called when a new user is identified
  LostUserCB | [in] Callback to be called when an existing user is no longer identified
  pCookie | [in] User's cookie, to be delivered to the callbacks
  phCallback | [out] The handle to these callbacks, to allow unregistration

## xnUnregisterFromUserExit()

XN_C_API void XN_C_DECL xnUnregisterFromUserExit | ( | XnNodeHandle | hInstance,
|  | XnCallbackHandle | hCallback )

Unregister from when a user exits the scene.

Parameters

  hInstance | [in] A handle to the instance
  hCallback | [in] The handle received from registration

## xnUnregisterFromUserReEnter()

XN_C_API void XN_C_DECL xnUnregisterFromUserReEnter | ( | XnNodeHandle | hInstance,
|  | XnCallbackHandle | hCallback )

Unregister from when a user re-enters the scene.

Parameters

  hInstance | [in] A handle to the instance
  hCallback | [in] The handle received from registration

## xnUnregisterUserCallbacks()

XN_C_API void XN_C_DECL xnUnregisterUserCallbacks | ( | XnNodeHandle | hInstance,
|  | XnCallbackHandle | hCallback )

Unregister from user callbacks.

Parameters

  hInstance | [in] A handle to the instance
  hCallback | [in] The handle received from registration