3

I'm working with user tracking: I've registered the callbacks (User_NewUser, User_LostUser, Pose_Detected, Calibration_Start, Calibration_End). When I enter in the sensor area I'm detected and calibrated in the right way. But when I leave sensor area (and nobody else is inside) I expect that the program calls the callback "User_LostUser", but does not seem to do it. (in fact, when I enter again, sensor still track me!) I expect that when an user leave scene, program unregister/remove him and restart to check for new user: can anybody help me?

void XN_CALLBACK_TYPE User_LostUser(xn::UserGenerator& generator, XnUserID nId,
    void* pCookie) {
generator.GetPoseDetectionCap().StopPoseDetection(nId);
generator.GetPoseDetectionCap().Release();
generator.GetPoseDetectionCap().StartPoseDetection("Psi", nId);
}
Asd Asd
  • 31
  • 2

2 Answers2

5

OpenNI (NITE, actually) will keep tracking you for a few seconds after leaving the scene. If you wait a bit you should get the LostUser callback eventually.

Having said that, if you want to detect the user leaving the scene yourself you can get the user center of mass (using UserGenerator::GetCoM). The center of mass will be 0,0,0 when the user leaves the scene.

Shlomo Zippel
  • 681
  • 4
  • 5
1

You could also RegisterToUserExit callback, which fires immediately after the user leaves the area.

// register user callbacks

XnCallbackHandle user_cb_exit_handle;

user_generator.RegisterToUserExit(
User_ExitUser
,this
,user_cb_exit_handle
);
Franci
  • 165
  • 2
  • 9