当前位置: 首页>>代码示例>>C++>>正文


C++ UserGenerator::GetCoM方法代码示例

本文整理汇总了C++中xn::UserGenerator::GetCoM方法的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator::GetCoM方法的具体用法?C++ UserGenerator::GetCoM怎么用?C++ UserGenerator::GetCoM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xn::UserGenerator的用法示例。


在下文中一共展示了UserGenerator::GetCoM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendUserPosMsg

void sendUserPosMsg(XnUserID id) {
	osc::OutboundPacketStream p(osc_buffer, OUTPUT_BUFFER_SIZE);
	XnPoint3D com;
	sprintf(tmp, "/user/%d", id);
	p << osc::BeginBundleImmediate;
	p << osc::BeginMessage(tmp);
	userGenerator.GetCoM(id, com);

	if (!raw)
	{
	  p << (float)(off_x + (mult_x * (1280 - com.X) / 2560));
	  p << (float)(off_y + (mult_y * (1280 - com.Y) / 2560));
	  p << (float)(off_z + (mult_z * com.Z * 7.8125 / 10000));
	}
	else
	{
	  p << com.X;
	  p << com.Y;
	  p << com.Z;
	}

	p << osc::EndMessage;
	p << osc::EndBundle;
	transmitSocket->Send(p.Data(), p.Size());
}
开发者ID:snowyu,项目名称:OSCeleton,代码行数:25,代码来源:OSCeleton.cpp

示例2: 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;
	}
}
开发者ID:TjlHope,项目名称:Rutler,代码行数:56,代码来源:user_tracker.cpp

示例3: writeUserPosition

void writeUserPosition(string *s, XnUserID id) {
	XnPoint3D com;
	userGenerator.GetCoM(id, com);

	if (fabsf( com.X - 0.0f ) > 0.1f)
	{
		char tmp[1024];

		sprintf(tmp, "{\"userid\":%u,\"X\":%.3f,\"Y\":%.3f,\"Z\":%.3f}\n", id, com.X, com.Y, com.Z);
		*s += tmp;
	}
}
开发者ID:bobbytables,项目名称:kinectable_pipe,代码行数:12,代码来源:kinectable_pipe.cpp

示例4: publishTransform

void publishTransform(XnUserID const& user, string const& frame_id, string const& child_frame_id) {
    static tf::TransformBroadcaster br;
    
    XnPoint3D icom;
    XnPoint3D com;
    g_UserGenerator.GetCoM(user,com);
    //g_DepthGenerator.ConvertProjectiveToRealWorld(1,&icom,&com);
    
    /*XnSkeletonJointPosition joint_position;
    g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(user, joint, joint_position);
    double x = -joint_position.position.X / 1000.0;
    double y = joint_position.position.Y / 1000.0;
    double z = joint_position.position.Z / 1000.0;

    XnSkeletonJointOrientation joint_orientation;
    g_UserGenerator.GetSkeletonCap().GetSkeletonJointOrientation(user, joint, joint_orientation);

    XnFloat* m = joint_orientation.orientation.elements;
    KDL::Rotation rotation(m[0], m[1], m[2],
    					   m[3], m[4], m[5],
    					   m[6], m[7], m[8]);
    double qx, qy, qz, qw;
    rotation.GetQuaternion(qx, qy, qz, qw);*/
    KDL::Rotation rotation(0,0,0,
    					   0,0,0,
    					   0,0,0);
    double qx, qy, qz, qw;
    rotation.GetQuaternion(qx, qy, qz, qw);

    char child_frame_no[128];
    snprintf(child_frame_no, sizeof(child_frame_no), "%s_%d", child_frame_id.c_str(), user);

    tf::Transform transform;
    double x = -com.X/1000;
    double y = com.Y/1000;
    double z = com.Z/1000;
    transform.setOrigin(tf::Vector3(x, y, z));
    ROS_INFO("X: %d\t%d\n Y: %d\t%d\nZ: %d\t%d\n",x,com.X,y,com.Y,z,com.Z);
    //transform.setRotation(tf::Quaternion(0, 0, 0, 0));
    transform.setRotation(tf::Quaternion(qx, -qy, -qz, qw));

    // #4994
    tf::Transform change_frame;
    change_frame.setOrigin(tf::Vector3(0, 0, 0));
    tf::Quaternion frame_rotation;
    frame_rotation.setEulerZYX(1.5708, 0, 1.5708);
    change_frame.setRotation(frame_rotation);

    transform = change_frame * transform;

    br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), frame_id, child_frame_no));
}
开发者ID:Cognitive-Robotics-Lab,项目名称:TurtleRPI,代码行数:52,代码来源:cluster.cpp

示例5: gl_labelCapturingUser

void gl_labelCapturingUser(XnUserID id)
{
  XnVector3D pos;
  gUserGenerator.GetCoM(id, pos);
  gDepthGenerator.ConvertRealWorldToProjective(1, &pos, &pos);
  glColor4f(0, 0, 0, 0);
  xn::DepthMetaData depthMD;
  gDepthGenerator.GetMetaData(depthMD);
  glRasterPos2i(pos.X/depthMD.XRes()*WIN_SIZE_X, 
		pos.Y/depthMD.YRes()*WIN_SIZE_Y);
  gl_printString(GLUT_BITMAP_HELVETICA_18, "Capturing");
  glColor4f(1.0, 1.0, 1.0, 1.0);
}
开发者ID:phelrine,项目名称:kica,代码行数:13,代码来源:kica.cpp

示例6: checkCenterOfMass

bool checkCenterOfMass(XnUserID const& user)
{
  XnPoint3D center_of_mass;
  XnStatus status = g_UserGenerator.GetCoM(user, center_of_mass);

  if(status != XN_STATUS_OK || (center_of_mass.X == 0 && center_of_mass.Y == 0 && center_of_mass.Z == 0))
  {
    return false;
  }
  else
  {
    return true;
  }
}
开发者ID:denbyk,项目名称:people_tracker_denbyk,代码行数:14,代码来源:OLDPeopleTracker_denbyk.cpp

示例7: glutDisplay

// this function is called each frame
void glutDisplay (void)
{

	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Setup the OpenGL viewpoint
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();

	xn::SceneMetaData sceneMD;
	xn::DepthMetaData depthMD;
	g_DepthGenerator.GetMetaData(depthMD);
	#ifdef USE_GLUT
	glOrtho(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
	#else
	glOrthof(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
	#endif

	glDisable(GL_TEXTURE_2D);

	if (!g_bPause)
	{
		// Read next available data
		g_Context.WaitOneUpdateAll(g_DepthGenerator);
	}

		// Process the data
		//DRAW
		g_DepthGenerator.GetMetaData(depthMD);
		g_UserGenerator.GetUserPixels(0, sceneMD);
		DrawDepthMap(depthMD, sceneMD, g_nPlayer);

		if (g_nPlayer != 0)
		{
			XnPoint3D com;
			g_UserGenerator.GetCoM(g_nPlayer, com);
			if (com.Z == 0)
			{
				g_nPlayer = 0;
				FindPlayer();
			}
		}

	#ifdef USE_GLUT
	glutSwapBuffers();
	#endif
}
开发者ID:imclab,项目名称:Bingsu,代码行数:49,代码来源:main.cpp

示例8: AssignPlayer

XnBool AssignPlayer(XnUserID user)
{
	if (g_nPlayer != 0)
		return FALSE;

	XnPoint3D com;
	g_UserGenerator.GetCoM(user, com);
	if (com.Z == 0)
		return FALSE;

	printf("Matching for existing calibration\n");
	g_UserGenerator.GetSkeletonCap().LoadCalibrationData(user, 0);
	g_UserGenerator.GetSkeletonCap().StartTracking(user);
	g_nPlayer = user;
	return TRUE;

}
开发者ID:imclab,项目名称:Bingsu,代码行数:17,代码来源:main.cpp

示例9: sendUserPosMsg

void sendUserPosMsg(XnUserID id) {
	XnPoint3D com;
	sprintf(oscPositionAddressBuff[0], "/user/%d", id);
	lo_bundle bundle = lo_bundle_new(LO_TT_IMMEDIATE);
	lo_message msg = lo_message_new();

	userGenerator.GetCoM(id, com);

	if (!raw)
	{
		lo_message_add_float(msg, (float)(off_x + (mult_x * (1280 - com.X) / 2560)));
		lo_message_add_float(msg, (float)(off_y + (mult_y * (1280 - com.Y) / 2560)));
		lo_message_add_float(msg, (float)(off_z + (mult_z * com.Z * 7.8125 / 10000)));
	}
	else
	{
		lo_message_add_float(msg,com.X);
		lo_message_add_float(msg,com.Y);
		lo_message_add_float(msg,com.Z);
	}

	lo_bundle_add_message(bundle, oscPositionAddressBuff[0], msg);
	lo_send_bundle(addr, bundle);
}
开发者ID:YggdrasiI,项目名称:OSCeleton,代码行数:24,代码来源:OSCeleton.cpp

示例10: DrawDepthMap


//.........这里部分代码省略.........
				else
				{
					pDestImage[0] = 0;
					pDestImage[1] = 0;
					pDestImage[2] = 0;
				}

				pDepth++;
				pLabels++;
				pDestImage+=3;
			}

			pDestImage += (texWidth - g_nXRes) *3;
		}
	}

	glBindTexture(GL_TEXTURE_2D, depthTexID);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pDepthTexBuf);

	// Display the OpenGL texture map
	glColor4f(0.75,0.75,0.75,1);

	glEnable(GL_TEXTURE_2D);
	DrawTexture(dmd.XRes(),dmd.YRes(),0,0);	
	glDisable(GL_TEXTURE_2D);

	char strLabel[20] = "";
	XnUserID aUsers[15];
	XnUInt16 nUsers = 15;
	g_UserGenerator.GetUsers(aUsers, nUsers);
	for (int i = 0; i < nUsers; ++i)
	{
		XnPoint3D com;
		g_UserGenerator.GetCoM(aUsers[i], com);
		g_DepthGenerator.ConvertRealWorldToProjective(1, &com, &com);

		if (aUsers[i] == player)
			sprintf(strLabel, "%d (Player)", aUsers[i]);
		else
			sprintf(strLabel, "%d", aUsers[i]);

		glColor4f(1-Colors[i%nColors][0], 1-Colors[i%nColors][1], 1-Colors[i%nColors][2], 1);

		glRasterPos2i(com.X, com.Y);
		glPrintString(GLUT_BITMAP_HELVETICA_18, strLabel);
	}

	// Draw skeleton of user
	if (player != 0)
	{
		glBegin(GL_LINES);
		glColor4f(1-Colors[player%nColors][0], 1-Colors[player%nColors][1], 1-Colors[player%nColors][2], 1);
    
    // gesture
    static int gesture = 0;
    static XnPoint3D previousLeftHandPt;
    XnPoint3D newLeftHandPt;
    newLeftHandPt = getJointPoint(player, XN_SKEL_LEFT_HAND);
    
    if(previousLeftHandPt.X > 0 && previousLeftHandPt.X < 640)
      if(previousLeftHandPt.X - newLeftHandPt.X > 60)
          gesture = 1;
      else if(previousLeftHandPt.X - newLeftHandPt.X < -60)
          gesture = 2;
      else if(previousLeftHandPt.Y - newLeftHandPt.Y > 60)
          gesture = 3;
开发者ID:imclab,项目名称:Bingsu,代码行数:67,代码来源:SceneDrawer.cpp

示例11: glutDisplay

// this function is called each frame
void glutDisplay (void)
{

	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Setup the OpenGL viewpoint
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();

	// Check if Registration is done for Depth and RGB Images - Brandyn, Sravanthi
	g_DepthGenerator.GetAlternativeViewPointCap().SetViewPoint(g_ImageGenerator);
//	g_DepthGenerator.GetAlternativeViewPointCap().ResetViewPoint();

	xn::SceneMetaData sceneMD;
	xn::DepthMetaData depthMD;
	xn::ImageMetaData imageMD;
	g_DepthGenerator.GetMetaData(depthMD);
	g_ImageGenerator.GetMetaData(imageMD);
	#ifdef USE_GLUT
	glOrtho(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
	#else
	glOrthof(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
	#endif

	glDisable(GL_TEXTURE_2D);

	if (!g_bPause)
	{
		// Read next available data
		g_Context.WaitAndUpdateAll();
	}

		// Process the data
		//DRAW
		// Check if Registration is done for Depth and RGB Images - Brandyn, Sravanthi
		g_DepthGenerator.GetAlternativeViewPointCap().SetViewPoint(g_ImageGenerator);
	//	g_DepthGenerator.GetAlternativeViewPointCap().ResetViewPoint();

		g_DepthGenerator.GetMetaData(depthMD);
		g_ImageGenerator.GetMetaData(imageMD);
		g_UserGenerator.GetUserPixels(0, sceneMD);


		DrawDepthMap(depthMD, imageMD, sceneMD, g_nPlayer);

		if (g_nPlayer != 0)
		{
			XnPoint3D com;
			g_UserGenerator.GetCoM(g_nPlayer, com);
			if (com.Z == 0)
			{
				g_nPlayer = 0;
				FindPlayer();
			}
		}

	#ifdef USE_GLUT
	glutSwapBuffers();
	#endif
}
开发者ID:sravanthib,项目名称:openni_annotator,代码行数:62,代码来源:main.cpp

示例12: DrawDepthMap


//.........这里部分代码省略.........
				pDepth++;
				pLabels++;
				pDestImage+=3;
			}

			pDestImage += (texWidth - g_nXRes) *3;
		}
	}
	else
	{
		xnOSMemSet(pDepthTexBuf, 0, 3*2*g_nXRes*g_nYRes);
	}

	glBindTexture(GL_TEXTURE_2D, depthTexID);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pDepthTexBuf);

	// Display the OpenGL texture map
	glColor4f(0.75,0.75,0.75,1);

	glEnable(GL_TEXTURE_2D);
	DrawTexture(dmd.XRes(),dmd.YRes(),0,0);	
	glDisable(GL_TEXTURE_2D);

	char strLabel[50] = "";
	XnUserID aUsers[15];
	XnUInt16 nUsers = 15;
	g_UserGenerator.GetUsers(aUsers, nUsers);
	for (int i = 0; i < nUsers; ++i)
	{
#ifndef USE_GLES
		if (g_bPrintID)
		{
			XnPoint3D com;
			g_UserGenerator.GetCoM(aUsers[i], com);
			g_DepthGenerator.ConvertRealWorldToProjective(1, &com, &com);

			XnUInt32 nDummy = 0;

			xnOSMemSet(strLabel, 0, sizeof(strLabel));
			if (!g_bPrintState)
			{
				// Tracking
				xnOSStrFormat(strLabel, sizeof(strLabel), &nDummy, "%d", aUsers[i]);
			}
			else if (g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i]))
			{
				// Tracking
				xnOSStrFormat(strLabel, sizeof(strLabel), &nDummy, "%d - Tracking", aUsers[i]);
			}
			else if (g_UserGenerator.GetSkeletonCap().IsCalibrating(aUsers[i]))
			{
				// Calibrating
				xnOSStrFormat(strLabel, sizeof(strLabel), &nDummy, "%d - Calibrating [%s]", aUsers[i], GetCalibrationErrorString(m_Errors[aUsers[i]].first));
			}
			else
			{
				// Nothing
				xnOSStrFormat(strLabel, sizeof(strLabel), &nDummy, "%d - Looking for pose [%s]", aUsers[i], GetPoseErrorString(m_Errors[aUsers[i]].second));
			}


			glColor4f(1-Colors[i%nColors][0], 1-Colors[i%nColors][1], 1-Colors[i%nColors][2], 1);

			glRasterPos2i(com.X, com.Y);
			glPrintString(GLUT_BITMAP_HELVETICA_18, strLabel);
		}
开发者ID:scottmeng,项目名称:VOBE_user_state_detection,代码行数:67,代码来源:SceneDrawer.cpp

示例13: DrawDepthMap


//.........这里部分代码省略.........
					}
				} else {
					pDestImage[0] = pixel->nRed;
					pDestImage[1] = pixel->nGreen;
					pDestImage[2] = pixel->nBlue;
					pDestImage[3] = 255;

					//find max/min values for width and height boundaries
					if (nX > (unsigned int)LEFT) {
						LEFT = nX;
					}

					if (nX < (unsigned int)RIGHT) {
						RIGHT = nX;
					}

					if (nY > (unsigned int)TOP) {
						TOP = nY;
					}

					if (nY < (unsigned int)BOTTOM) {
						BOTTOM = nY;
					}
				}

				pixel++;
				pDepth++;
				pLabels++;
				pDestImage+=4;
			}

			pDestImage += (texWidth - g_nXRes) *4;
		}
	//}*/

	// Display the OpenGL texture map
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pDepthTexBuf);

	nUsers = 15;
	g_UserGenerator.GetUsers(aUsers, nUsers);
	g_UserGenerator.GetCoM(aUsers[0], com);


	CENTER = com.X;

	//glDisable(GL_BLEND);
	//glDisable(GL_TEXTURE_2D);
/*
	char strLabel[20] = "";
	XnUserID aUsers[15];
	XnUInt16 nUsers = 15;
	g_UserGenerator.GetUsers(aUsers, nUsers);
	for (int i = 0; i < nUsers; ++i)
	{
		XnPoint3D com;
		g_UserGenerator.GetCoM(aUsers[i], com);
		g_DepthGenerator.ConvertRealWorldToProjective(1, &com, &com);

		if (aUsers[i] == player)
			sprintf(strLabel, "%d (Player)", aUsers[i]);
		else
			sprintf(strLabel, "%d", aUsers[i]);

		//glColor4f(1-Colors[i%nColors][0], 1-Colors[i%nColors][1], 1-Colors[i%nColors][2], 1);

		glRasterPos2i(com.X, com.Y);
		glPrintString(GLUT_BITMAP_HELVETICA_18, strLabel); */
//	}

	// Draw skeleton of user
//		glBegin(GL_LINES);
//		//glColor4f(1,0,0,1.0f);
//		glVertex3f(-1, 1, 0);
//		glVertex3f(1, -1, 0);
//		//glColor4f(1-Colors[player%nColors][0], 1-Colors[player%nColors][1], 1-Colors[player%nColors][2], 1);
//		DrawLimb(1, XN_SKEL_HEAD, XN_SKEL_NECK);
//
//		DrawLimb(1, XN_SKEL_NECK, XN_SKEL_LEFT_SHOULDER);
//		DrawLimb(1, XN_SKEL_LEFT_SHOULDER, XN_SKEL_LEFT_ELBOW);
//		DrawLimb(1, XN_SKEL_LEFT_ELBOW, XN_SKEL_LEFT_HAND);
//
//		DrawLimb(1, XN_SKEL_NECK, XN_SKEL_RIGHT_SHOULDER);
//		DrawLimb(1, XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW);
//		DrawLimb(1, XN_SKEL_RIGHT_ELBOW, XN_SKEL_RIGHT_HAND);
//
//		DrawLimb(1, XN_SKEL_LEFT_SHOULDER, XN_SKEL_TORSO);
//		DrawLimb(1, XN_SKEL_RIGHT_SHOULDER, XN_SKEL_TORSO);
//
//		DrawLimb(1, XN_SKEL_TORSO, XN_SKEL_LEFT_HIP);
//		DrawLimb(1, XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE);
//		DrawLimb(1, XN_SKEL_LEFT_KNEE, XN_SKEL_LEFT_FOOT);
//
//		DrawLimb(1, XN_SKEL_TORSO, XN_SKEL_RIGHT_HIP);
//		DrawLimb(1, XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE);
//		DrawLimb(1, XN_SKEL_RIGHT_KNEE, XN_SKEL_RIGHT_FOOT);
//		glEnd();

	//XnSkeletonJoint eJoint1 = XN_SKEL_RIGHT_HAND;

}
开发者ID:cessien,项目名称:PraserPowerpoint,代码行数:101,代码来源:SceneDrawer.cpp

示例14: DrawDepthMap


//.........这里部分代码省略.........
                pDepth++;
                pLabels++;
                pDestImage+=3;
            }

            pDestImage += (texWidth - g_nXRes) *3;
        }
    }
    else
    {
        xnOSMemSet(pDepthTexBuf, 0, 3*2*g_nXRes*g_nYRes);
    }

    glBindTexture(GL_TEXTURE_2D, depthTexID);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pDepthTexBuf);

    // Display the OpenGL texture map
    glColor4f(0.75,0.75,0.75,1);

    glEnable(GL_TEXTURE_2D);
    DrawTexture(dmd.XRes(),dmd.YRes(),0,0);
    glDisable(GL_TEXTURE_2D);

    char strLabel[50] = "";
    XnUserID aUsers[15];
    XnUInt16 nUsers = 15;
    g_UserGenerator.GetUsers(aUsers, nUsers);
    for (int i = 0; i < nUsers; ++i)
    {
#ifndef USE_GLES
        if (g_bPrintID)
        {
            XnPoint3D com;
            g_UserGenerator.GetCoM(aUsers[i], com);
            g_DepthGenerator.ConvertRealWorldToProjective(1, &com, &com);

            xnOSMemSet(strLabel, 0, sizeof(strLabel));
            if (!g_bPrintState)
            {
                // Tracking
                sprintf(strLabel, "%d", aUsers[i]);
            }
            else if (g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i]))
            {
                // Tracking
                sprintf(strLabel, "%d - Tracking", aUsers[i]);
            }
            else if (g_UserGenerator.GetSkeletonCap().IsCalibrating(aUsers[i]))
            {
                // Calibrating
                sprintf(strLabel, "%d - Calibrating [%s]", aUsers[i], GetCalibrationErrorString(m_Errors[aUsers[i]].first));
            }
            else
            {
                // Nothing
                sprintf(strLabel, "%d - Looking for pose [%s]", aUsers[i], GetPoseErrorString(m_Errors[aUsers[i]].second));
            }


            glColor4f(1-Colors[i%nColors][0], 1-Colors[i%nColors][1], 1-Colors[i%nColors][2], 1);

            glRasterPos2i(com.X, com.Y);
            glPrintString(GLUT_BITMAP_HELVETICA_18, strLabel);
        }
#endif
        if (g_bDrawSkeleton && g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i]))
开发者ID:yinancui,项目名称:KSocket,代码行数:67,代码来源:SceneDrawer.cpp

示例15: executeInputLoop

/// execution loop: runs the hole time: main logic
void executeInputLoop() {
	PackedType<Vector3<double> > packedVector3;
	//get the new informations and sent it over the udp socket to the tui server
	while (true) {
	    /// wait for new kinect data
        g_Context.WaitOneUpdateAll(g_UserGenerator);

        /// max 15 users
		XnUserID aUsers[15];
		XnUInt16 nUsers = 15;
		g_UserGenerator.GetUsers(aUsers, nUsers);

        /// track only the closest person
        //todo: hau das in eine einzelne function!!
		std::vector<XnPoint3D> userCoM(nUsers);
		for (int i = 0; i < nUsers; ++i) {
            g_UserGenerator.GetCoM(aUsers[i], userCoM[i]);
		}

        //calculate the user with the minimum distance to the kinect
        float minDist = FLT_MAX;
        int minUser = -1;
        float tmp_minDist = 0.0f;

		for (int i = 0; i < nUsers; ++i){
		    if (userCoM[i].X + userCoM[i].Y + userCoM[i].Z == 0) {
                continue;
		    }
            tmp_minDist = userCoM[i].X*userCoM[i].X + userCoM[i].Y*userCoM[i].Y + userCoM[i].Z*userCoM[i].Z;
		    if(tmp_minDist < minDist && tmp_minDist > 0.0){
                minDist = tmp_minDist;
                minUser = i;
		    }
		    //std::cout << "user: " << i << tmp_minDist << std::endl;
		}

        /// send the joints if a user is tracked
        if (minUser != -1 && g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[minUser]) && aUsers[minUser]) {
			//std::cout << "sending user: " << aUsers[minUser] << std::endl;
			vector<pair<int, Vector3<double> > > & v = packedVector3.getItems();
			v.clear();

			addJoint(aUsers[minUser], XN_SKEL_HEAD           , SKEL_HEAD           , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_NECK           , SKEL_NECK           , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_TORSO          , SKEL_TORSO          , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_WAIST          , SKEL_WAIST          , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_COLLAR    , SKEL_LEFT_COLLAR    , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_SHOULDER  , SKEL_LEFT_SHOULDER  , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_ELBOW     , SKEL_LEFT_ELBOW     , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_WRIST     , SKEL_LEFT_WRIST     , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_HAND      , SKEL_LEFT_HAND      , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_FINGERTIP , SKEL_LEFT_FINGERTIP , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_COLLAR   , SKEL_RIGHT_COLLAR   , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_SHOULDER , SKEL_RIGHT_SHOULDER , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_ELBOW    , SKEL_RIGHT_ELBOW    , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_WRIST    , SKEL_RIGHT_WRIST    , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_HAND     , SKEL_RIGHT_HAND     , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_FINGERTIP, SKEL_RIGHT_FINGERTIP, packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_HIP       , SKEL_LEFT_HIP       , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_KNEE      , SKEL_LEFT_KNEE      , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_ANKLE     , SKEL_LEFT_ANKLE     , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_LEFT_FOOT      , SKEL_LEFT_FOOT      , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_HIP      , SKEL_RIGHT_HIP      , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_KNEE     , SKEL_RIGHT_KNEE     , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_ANKLE    , SKEL_RIGHT_ANKLE    , packedVector3);
			addJoint(aUsers[minUser], XN_SKEL_RIGHT_FOOT     , SKEL_RIGHT_FOOT     , packedVector3);

			sendPackedVector3(packedVector3);
        }

		//if we use openGL, than we have to break up after one send
		//s.t. openGL can draw a new scene
		if(enableOpenGL) {
			break;
		} else {
			Sleep(10);
		}
	}
}
开发者ID:Lammmark,项目名称:tuiframework,代码行数:80,代码来源:KinectDeviceApp.cpp


注:本文中的xn::UserGenerator::GetCoM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。