本文整理汇总了C++中xn::UserGenerator::GetUsers方法的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator::GetUsers方法的具体用法?C++ UserGenerator::GetUsers怎么用?C++ UserGenerator::GetUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xn::UserGenerator
的用法示例。
在下文中一共展示了UserGenerator::GetUsers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateMinecraftCharacter
int GenerateMinecraftCharacter(const xn::DepthMetaData& dmd, const xn::SceneMetaData& smd, const XnRGB24Pixel* image)
{
int ret = 0;
int xRes = dmd.XRes();
int yRes = dmd.YRes();
cv::Mat inputImage = cv::Mat(yRes, xRes, CV_8UC3);
cv::Mat skin = cv::Mat::zeros(cv::Size(64,32), CV_8UC3);
XnToCV(image,&inputImage);
cv::cvtColor(inputImage,inputImage,CV_RGB2BGR);
XnUserID aUsers[15];
XnUInt16 nUsers = 15;
g_UserGenerator.GetUsers(aUsers, nUsers);
int i = 0;
for (i = 0; i < nUsers; ++i) {
if (g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i])) break;
}
// No users being tracked
if (i == nUsers) return -1;
ret = GenerateSkin(aUsers[i], &inputImage, &skin);
printf("GenerateSkin returned %d on user %d\n",ret,(int)aUsers[i]);
cv::imwrite("skin.png",skin);
SegmentUser(aUsers[i], &inputImage, smd);
DrawDebugPoints(aUsers[i], &inputImage);
cv::imwrite("blah.png",inputImage);
sync();
system("convert skin.png -transparent black skin.png && composite -geometry +32+0 hardhat.png skin.png skin.png");
sync();
return ret;
}
示例2: send
void send(const xn::DepthMetaData& dmd)
{
XnUserID aUsers[15];
XnUInt16 nUsers = 15;
userGenerator.GetUsers(aUsers, nUsers);
for (int i = 0; i < nUsers; ++i)
{
memset(&SendBuf, '\0', BufLen); // this may be expensive
if (userGenerator.GetSkeletonCap().IsTracking(aUsers[i]))
{
strcpy(&SendBuf[0], "sensor-update");
for(int j = 0; j < 24 ; j++)
{
if(jointPos(aUsers[i], jointList[j]) == 0)
{
sprintf(&SendBuf[strlen(SendBuf)], " \"%s_x\" %f", jointNames[j], jointCoords[1]); // I know, I know :(
sprintf(&SendBuf[strlen(SendBuf)], " \"%s_y\" %f", jointNames[j], jointCoords[2]);
}
}
// Before we send each bundle, we need to send some size code
unsigned char sizeBytes[4];
//strcpy(SendBuf, P.c_str());
int len = strlen(SendBuf);
sizeBytes[0] =(unsigned char)( len >> 24 );
sizeBytes[1] =(unsigned char)( (len << 8) >> 24 );
sizeBytes[2] =(unsigned char)( (len << 16) >> 24 );
sizeBytes[3] =(unsigned char)( (len << 24) >> 24 );
if (debug)
printf("%s\n\n", SendBuf);
sendto(SendSocket, (char*)sizeBytes, 4, 0, (struct sockaddr *) &RecvAddr, sizeof(RecvAddr));
sendto(SendSocket, SendBuf, strlen(SendBuf), 0, (struct sockaddr *) &RecvAddr, sizeof(RecvAddr));
}
}
示例3: UserCalibration_CalibrationEnd
void XN_CALLBACK_TYPE UserCalibration_CalibrationEnd(xn::SkeletonCapability& capability, XnUserID nId, XnBool bSuccess, void* pCookie)
{
if (bSuccess)
{
ROS_INFO("Calibration complete, start tracking user %d", nId);
g_UserGenerator.GetSkeletonCap().StartTracking(nId);
if (default_user == 0) // set default user if still unset
{
default_user = nId;
ROS_INFO_STREAM("OpenNI tracker: Default user has been initialised with user " << default_user << ".");
}
std_msgs::UInt16MultiArray tracked_users;
XnUserID users[15];
XnUInt16 users_count = 15;
g_UserGenerator.GetUsers(users, users_count);
for (unsigned int user = 0; user < users_count; ++user)
{
tracked_users.data.push_back(users[user]);
}
available_tracked_users_pub.publish(tracked_users);
}
else
{
ROS_INFO("Calibration failed for user %d", nId);
if (g_bNeedPose)
{
g_UserGenerator.GetPoseDetectionCap().StartPoseDetection(g_strPose, nId);
}
else
{
g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
}
示例4: publishTransforms
void publishTransforms(const std::string& frame_id) {
XnUserID users[15];
XnUInt16 users_count = 15;
g_UserGenerator.GetUsers(users, users_count);
for (int i = 0; i < users_count; ++i) {
XnUserID user = users[i];
if (!g_UserGenerator.GetSkeletonCap().IsTracking(user))
continue;
publishTransform(user, XN_SKEL_HEAD, frame_id, "head2");
publishTransform(user, XN_SKEL_NECK, frame_id, "neck2");
publishTransform(user, XN_SKEL_TORSO, frame_id, "torso2");
publishTransform(user, XN_SKEL_LEFT_SHOULDER, frame_id, "left_shoulder2");
publishTransform(user, XN_SKEL_LEFT_ELBOW, frame_id, "left_elbow2");
publishTransform(user, XN_SKEL_LEFT_HAND, frame_id, "left_hand2");
publishTransform(user, XN_SKEL_RIGHT_SHOULDER, frame_id, "right_shoulder2");
publishTransform(user, XN_SKEL_RIGHT_ELBOW, frame_id, "right_elbow2");
publishTransform(user, XN_SKEL_RIGHT_HAND, frame_id, "right_hand2");
publishTransform(user, XN_SKEL_LEFT_HIP, frame_id, "left_hip2");
publishTransform(user, XN_SKEL_LEFT_KNEE, frame_id, "left_knee2");
publishTransform(user, XN_SKEL_LEFT_FOOT, frame_id, "left_foot2");
publishTransform(user, XN_SKEL_RIGHT_HIP, frame_id, "right_hip2");
publishTransform(user, XN_SKEL_RIGHT_KNEE, frame_id, "right_knee2");
publishTransform(user, XN_SKEL_RIGHT_FOOT, frame_id, "right_foot2");
}
}
示例5: User_NewUser
// Callback: New user was detected
void XN_CALLBACK_TYPE User_NewUser(xn::UserGenerator& generator, XnUserID nId, void* pCookie)
{
XnUInt32 epochTime = 0;
xnOSGetEpochTime(&epochTime);
XnUserID aUsers[MAX_NUM_USERS];
XnUInt16 nUsers;
g_UserGenerator.GetUsers(aUsers, nUsers);
printf("%d New User %d\n", epochTime, nId);
// New user found
//validate the number of users
XnUInt16 usersTracked=0;
for(XnUInt16 i=0; i<nUsers; i++)
{
if(g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i])==TRUE)
usersTracked++;
}
if(usersTracked >= numOfUser)
{
printf("%d users are currently being tracked, no more users allowed\n",numOfUser);
return;
}
if (g_bNeedPose)
{
g_UserGenerator.GetPoseDetectionCap().StartPoseDetection(g_strPose, nId);
}
else
{
g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
示例6: gl_onKeyboard
void gl_onKeyboard(unsigned char key, int x, int y)
{
XnUInt16 nUser = 16;
XnUserID users[16];
switch(key){
case 27:
gContext.Shutdown();
exit(1);
break;
case 'c':
gUserGenerator.GetUsers(users, nUser);
if(nUser == 0){
fprintf(stderr, "cannot find user\n");
}else if(capture->start(*std::min_element(users, &users[nUser]))){
fprintf(stderr, "start recording\n");
}
break;
case 's':
if(capture->stop()){
fprintf(stderr, "stop recording\n");
}
break;
}
}
示例7: LoadCalibration
// Load calibration from file
bool LoadCalibration( xn::UserGenerator& userGenerator )
{
printf("LoadCalibration\n");
XnUserID aUserIDs[20] = {0};
XnUInt16 nUsers = 20;
userGenerator.GetUsers(aUserIDs, nUsers);
for (int i = 0; i < nUsers; ++i) {
// ユーザーがキャリブレーションされているときは何もしない
if (userGenerator.GetSkeletonCap().IsCalibrated(aUserIDs[i]))
continue;
if (userGenerator.GetSkeletonCap().IsCalibrating(aUserIDs[i]))
continue;
// ファイルから、キャリブレーション情報を取得し、骨格の追跡を開始する
printf("Load user's calibration from file: user %d\n", aUserIDs[i]);
XnStatus rc = userGenerator.GetSkeletonCap().LoadCalibrationDataFromFile(aUserIDs[i], XN_CALIBRATION_FILE_NAME);
if (rc == XN_STATUS_OK) {
printf("Make sure state is coherent: user %d\n", aUserIDs[i]);
userGenerator.GetPoseDetectionCap().StopPoseDetection(aUserIDs[i]);
userGenerator.GetSkeletonCap().StartTracking(aUserIDs[i]);
return true;
}
break;
}
return false;
}
示例8: publishTransforms
void publishTransforms(const std::string& frame_id, ros::Publisher& publisher)
{
XnUserID users[NUSERS];
XnUInt16 users_count = NUSERS;
g_UserGenerator.GetUsers(users, users_count);
for (int i = 0; i < users_count; ++i)
{
XnUserID user = users[i];
XnPoint3D point;
g_UserGenerator.GetCoM(users[i], point);
int idx = user - 1;
if (isnan(point.X)==1||isnan(point.Y)==1||isnan(point.Z)==1||point.Z==0) // TODO
kinectUsers[idx].active == FALSE;
if (kinectUsers[idx].active == TRUE)
estimateVelocity(point, kinectUsers[idx]);
//if (point.X-oldX>=20)
//publisher.publish(kinectUsers[idx]);
//oldX=point.X;
//}
//g_DepthGenerator.ConvertRealWorldToProjective(1, &point, &point);
// original sceleton transform publishing.
/*if (g_UserGenerator.GetSkeletonCap().IsTracking(user))
{
publishTransform(user, XN_SKEL_HEAD, frame_id, "head");
publishTransform(user, XN_SKEL_NECK, frame_id, "neck");
publishTransform(user, XN_SKEL_TORSO, frame_id, "torso");
publishTransform(user, XN_SKEL_LEFT_SHOULDER, frame_id, "left_shoulder");
publishTransform(user, XN_SKEL_LEFT_ELBOW, frame_id, "left_elbow");
publishTransform(user, XN_SKEL_LEFT_HAND, frame_id, "left_hand");
publishTransform(user, XN_SKEL_RIGHT_SHOULDER, frame_id, "right_shoulder");
publishTransform(user, XN_SKEL_RIGHT_ELBOW, frame_id, "right_elbow");
publishTransform(user, XN_SKEL_RIGHT_HAND, frame_id, "right_hand");
publishTransform(user, XN_SKEL_LEFT_HIP, frame_id, "left_hip");
publishTransform(user, XN_SKEL_LEFT_KNEE, frame_id, "left_knee");
publishTransform(user, XN_SKEL_LEFT_FOOT, frame_id, "left_foot");
publishTransform(user, XN_SKEL_RIGHT_HIP, frame_id, "right_hip");
publishTransform(user, XN_SKEL_RIGHT_KNEE, frame_id, "right_knee");
publishTransform(user, XN_SKEL_RIGHT_FOOT, frame_id, "right_foot");
}*/
}
for (int i = 0; i < NUSERS; ++i)
{
if (kinectUsers[i].id != 0)
publisher.publish(kinectUsers[i]);
//if (kinectUsers[i].active == 0)
//kinectUsers[i].id = 0;
}
}
示例9: publishTransforms
void publishTransforms(const std::string& frame_id) {
XnUserID users[15];
XnUInt16 users_count = 15;
g_UserGenerator.GetUsers(users, users_count);
for (int i = 0; i < users_count; ++i) {
XnUserID user = users[i];
publishTransform(user, frame_id, "user");
}
}
示例10: jointConf
// this function will print the confidence values of all the joints
void jointConf()
{
XnUserID nId[15];
XnUInt16 oId = 15;
g_UserGenerator.GetUsers(nId, oId);
int userSum = 0;
float userConfidence = 0;
// ITERATE THROUGH ALL TRACKED USERS AND OUTPUT INDIVIDUAL JOINT CONFIDENCE VALUES
for (int i = 0; i < oId; ++i){
if (g_bDrawSkeleton && g_UserGenerator.GetSkeletonCap().IsTracking(nId[i])){
XnSkeletonJointPosition jointData;
printf("\n");
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_HEAD, jointData);
std::cout << "User " << nId[i] << " - Head " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_NECK, jointData);
std::cout << "User " << nId[i] << " - Neck " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_TORSO, jointData);
std::cout << "User " << nId[i] << " - Torso " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_SHOULDER, jointData);
std::cout << "User " << nId[i] << " - L Shoulder " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_ELBOW, jointData);
std::cout << "User " << nId[i] << " - L Elbow " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_HAND, jointData);
std::cout << "User " << nId[i] << " - L Hand " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_SHOULDER, jointData);
std::cout << "User " << nId[i] << " - R Shoulder " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_ELBOW, jointData);
std::cout << "User " << nId[i] << " - R Elbow " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_HAND, jointData);
std::cout << "User " << nId[i] << " - R Hand " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_HIP, jointData);
std::cout << "User " << nId[i] << " - L Hip " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_KNEE, jointData);
std::cout << "User " << nId[i] << " - L Knee " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_FOOT, jointData);
std::cout << "User " << nId[i] << " - L Foot " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_HIP, jointData);
std::cout << "User " << nId[i] << " - R Hip " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_KNEE, jointData);
std::cout << "User " << nId[i] << " - R Knee " << jointData.fConfidence << std::endl;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_FOOT, jointData);
std::cout << "User " << nId[i] << " - R Foot " << jointData.fConfidence << std::endl;
}
}
}
示例11: FirstTrackingUser
XnUserID FirstTrackingUser(xn::UserGenerator userGenerator) {
XnUserID aUsers[10];
XnUInt16 nUsers = 10;
userGenerator.GetUsers(aUsers, nUsers);
// The first user that's tracking will be in control
for (int i = 0; i < nUsers; ++i) {
if(userGenerator.GetSkeletonCap().IsTracking(aUsers[i])){
return aUsers[i];
}
}
return NULL;
}
示例12: 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;
}
示例13: jointConfidence
// this function will calculate the average joint confidence value for every user
void jointConfidence()
{
XnUserID nId[15];
XnUInt16 oId = 15;
g_UserGenerator.GetUsers(nId, oId);
int userSum = 0;
float userConfidence = 0;
for (int i = 0; i < oId; ++i){
if (g_bDrawSkeleton && g_UserGenerator.GetSkeletonCap().IsTracking(nId[i])){
XnSkeletonJointPosition jointData;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_HEAD, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_NECK, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_TORSO, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_SHOULDER, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_ELBOW, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_HAND, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_SHOULDER, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_ELBOW, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_HAND, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_HIP, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_KNEE, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_LEFT_FOOT, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_HIP, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_KNEE, jointData);
userSum += jointData.fConfidence;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(nId[i], XN_SKEL_RIGHT_FOOT, jointData);
userSum += jointData.fConfidence;
userConfidence = userSum / 15.0f;
csvConfidence(nId[i], userConfidence);
}
}
}
示例14: SaveCalibration
// Save calibration to file
void SaveCalibration(){
XnUserID aUserIDs[20] = {0};
XnUInt16 nUsers = 20;
g_UserGenerator.GetUsers(aUserIDs, nUsers);
for (int i = 0; i < nUsers; ++i){
// Find a user who is already calibrated
if (g_UserGenerator.GetSkeletonCap().IsCalibrated(aUserIDs[i])){
// Save user's calibration to file
g_UserGenerator.GetSkeletonCap().SaveCalibrationDataToFile(aUserIDs[i], XN_CALIBRATION_FILE_NAME);
break;
}
}
}
示例15: DrawDepthMap
void DrawDepthMap(const xn::DepthMetaData& dmd, const xn::SceneMetaData& smd)
{
char strLabel[50] = "";
XnUserID aUsers[15];
XnUInt16 nUsers = 15;
glBegin(GL_POINT);
g_UserGenerator.GetUsers(aUsers, nUsers);
for (int i = 0; i < nUsers; ++i)
{
if (g_bDrawSkeleton && g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i])){
DrawJoint(aUsers[i], XN_SKEL_HEAD);
DrawJoint(aUsers[i], XN_SKEL_NECK);
DrawJoint(aUsers[i], XN_SKEL_TORSO);
DrawJoint(aUsers[i], XN_SKEL_WAIST);
DrawJoint(aUsers[i], XN_SKEL_LEFT_COLLAR);
DrawJoint(aUsers[i], XN_SKEL_LEFT_SHOULDER);
DrawJoint(aUsers[i], XN_SKEL_LEFT_ELBOW);
DrawJoint(aUsers[i], XN_SKEL_LEFT_WRIST);
DrawJoint(aUsers[i], XN_SKEL_LEFT_HAND);
DrawJoint(aUsers[i], XN_SKEL_LEFT_FINGERTIP);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_COLLAR);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_SHOULDER);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_ELBOW);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_WRIST);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_HAND);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_FINGERTIP);
DrawJoint(aUsers[i], XN_SKEL_LEFT_HIP);
DrawJoint(aUsers[i], XN_SKEL_LEFT_KNEE);
DrawJoint(aUsers[i], XN_SKEL_LEFT_ANKLE);
DrawJoint(aUsers[i], XN_SKEL_LEFT_FOOT);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_HIP);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_KNEE);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_ANKLE);
DrawJoint(aUsers[i], XN_SKEL_RIGHT_FOOT);
}
}
glEnd();
}