本文整理汇总了C++中xn::UserGenerator::GetNumberOfUsers方法的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator::GetNumberOfUsers方法的具体用法?C++ UserGenerator::GetNumberOfUsers怎么用?C++ UserGenerator::GetNumberOfUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xn::UserGenerator
的用法示例。
在下文中一共展示了UserGenerator::GetNumberOfUsers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTrackedUserID
XnUserID hiKinect::getTrackedUserID(){
XnUInt16 nUsers = g_UserGenerator.GetNumberOfUsers();
XnUserID aUsers[nUsers];
g_UserGenerator.GetUsers(aUsers, nUsers);
xn::SkeletonCapability cap = g_UserGenerator.GetSkeletonCap();
for (int i = 0; i < nUsers; ++i) {
if (cap.IsTracking(aUsers[i])) {
return aUsers[i];
}
}
return 0;
}
示例2: UserDetected
// ユーザー検出
void XN_CALLBACK_TYPE UserDetected(xn::UserGenerator& generator,
XnUserID nId, void* pCookie)
{
std::cout << "ユーザー検出:" << nId << " " << generator.GetNumberOfUsers() << "人目" << std::endl;
XnChar* pose = (XnChar*)pCookie;
if (pose[0] != '¥0') {
generator.GetPoseDetectionCap().StartPoseDetection(pose, nId);
}
else {
generator.GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
示例3: printf
void XN_CALLBACK_TYPE
User_NewUser(xn::UserGenerator& generator, XnUserID nId, void* pCookie) {
printf("New User: %d\n", nId);
FBLOG_INFO("User_NewUser", nId);
XnUInt16 nUsers = g_UserGenerator.GetNumberOfUsers();
XnUserID aUsers[nUsers];
g_UserGenerator.GetUsers(aUsers, nUsers);
for (int i = 0; i < nUsers; ++i) {
if (g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i])) {
return;
}
}
g_UserGenerator.GetPoseDetectionCap().StartPoseDetection(POSE_TO_USE, nId);
(*((hiKinect *)pCookie)->callbackPtr)->InvokeAsync("", FB::variant_list_of("NEW_USER"));
}
示例4: UserDetected
// ユーザー検出
void XN_CALLBACK_TYPE UserDetected(xn::UserGenerator& generator, XnUserID nId, void* pCookie)
{
std::cout << "ユーザー検出:" << nId << " " << generator.GetNumberOfUsers() << "人目" << std::endl;
// キャリブレーションデータをロードする
if ( !LoadCalibration( generator ) ) {
// ファイルからトラッキングできなければ、ポーズからキャリブレーションを行う
XnChar* pose = (XnChar*)pCookie;
if (pose[0] != '¥0') {
generator.GetPoseDetectionCap().StartPoseDetection(pose, nId);
}
else {
generator.GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
}
示例5: xnGetStatusString
reader_result kinect_reader2::get_next() {
XnUserID aUsers[15];
XnUInt16 nUsers = 15;
XnSkeletonJointPosition joint;
while(true) {
// Read next available data
nRetVal = g_Context.WaitOneUpdateAll(g_DepthGenerator);
if(nRetVal != XN_STATUS_OK) {
printf("Failed updating data: %s\n", xnGetStatusString(nRetVal));
continue;
}
if(g_UserGenerator.GetNumberOfUsers() > 0) {
g_UserGenerator.GetUsers(aUsers, nUsers);
for(int i=0; i< nUsers; i++)
{
if(g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i]))
{
reader_result new_tuple;
// player
new_tuple.push_back(boost::any((int)aUsers[i]));
// 1 = XN_SKEL_HEAD, ..., 24 = XN_SKEL_RIGHT_FOOD
for(short j = 1; j <= 24; j++) {
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], (XnSkeletonJoint)j, joint);
new_tuple.push_back(boost::any(boost::lexical_cast<std::string>((float)joint.position.X)));
new_tuple.push_back(boost::any(boost::lexical_cast<std::string>((float)joint.position.Y)));
new_tuple.push_back(boost::any(boost::lexical_cast<std::string>((float)joint.position.Z)));
new_tuple.push_back(boost::any(boost::lexical_cast<std::string>((float)joint.fConfidence)));
}
return new_tuple;
}
}
}
}
}
示例6: UserDetected
//----------------------------------------------------
// ユーザー検出
//----------------------------------------------------
void XN_CALLBACK_TYPE UserDetected(xn::UserGenerator& generator, XnUserID nId, void* pCookie){
cout << "ユーザー検出:" << nId << " " << generator.GetNumberOfUsers() << "人目" << endl;
}
示例7: main
int main() {
printf("main() START\n");
signal(SIGINT, onSignalReceived); // hit CTRL-C keys in terminal (2)
signal(SIGTERM, onSignalReceived); // hit stop button in eclipse CDT (15)
mapMode.nXRes = XN_VGA_X_RES;
mapMode.nYRes = XN_VGA_Y_RES;
mapMode.nFPS = 30;
CHECK_RC(ctx.Init(), "init");
CHECK_RC(depthGenerator.Create(ctx), "create depth");
depthGenerator.SetMapOutputMode(mapMode);
XnStatus userAvailable = ctx.FindExistingNode(XN_NODE_TYPE_USER, userGenerator);
if(userAvailable != XN_STATUS_OK) {
CHECK_RC(userGenerator.Create(ctx), "create user");
}
XnCallbackHandle hUserCallbacks, hCalibrationCallbacks, hPoseCallbacks;
xn::SkeletonCapability skel = userGenerator.GetSkeletonCap();
CHECK_RC(userGenerator.RegisterUserCallbacks(onUserNew, onUserLost, NULL, hUserCallbacks), "register user");
CHECK_RC(skel.RegisterCalibrationCallbacks(onCalibrationStart, onCalibrationEnd, NULL, hCalibrationCallbacks), "register calib");
CHECK_RC(userGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(onPoseDetected, NULL, NULL, hPoseCallbacks), "register pose");
XnChar poseName[20] = "";
CHECK_RC(skel.GetCalibrationPose(poseName), "get posename");
printf("poseName: %s\n", poseName);
CHECK_RC(skel.SetSkeletonProfile(XN_SKEL_PROFILE_ALL), "set skel profile");
CHECK_RC(skel.SetSmoothing(0.8), "set smoothing");
// xnSetMirror(depth, !mirrorMode);
CHECK_RC(ctx.StartGeneratingAll(), "start generating");
printf("waitAnyUpdateAll ...\n");
while(!shouldTerminate) {
ctx.WaitAnyUpdateAll();
// depthGenerator.GetMetaData(tempDepthMetaData);
const XnUInt16 userCount = userGenerator.GetNumberOfUsers();
// printf("userCount: %i\n", userCount);
XnUserID aUsers[userCount];
XnUInt16 nUsers = userCount;
userGenerator.GetUsers(aUsers, nUsers);
for (int i = 0; i < nUsers; ++i) {
XnUserID currentUserId = aUsers[i];
if (skel.IsTracking(aUsers[i])) {
XnSkeletonJointPosition joint;
skel.GetSkeletonJointPosition(currentUserId, XN_SKEL_HEAD, joint);
XnFloat x = joint.position.X;
XnFloat y = joint.position.Y;
XnFloat z = joint.position.Z;
printf("joint position: %.2f x %.2f x %.2f\n", x, y, z);
printf("joint.fConfidence: %.2f\n", joint.fConfidence);
}
}
}
printf("STOP\n");
CHECK_RC(ctx.StopGeneratingAll(), "stop generating");
ctx.Shutdown();
printf("main() END\n");
}