Пример #1
0
int main(int argc, char** argv)
{
  ros::init(argc, argv, "skeleton_tracker");
  ros::NodeHandle np("~");

  string filepath;
  bool is_a_recording;
  np.getParam("load_filepath", filepath); 
  np.param<bool>("load_recording", is_a_recording, false);      

  g_skeleton_tracker.init();
  g_kinect_controller.init(filepath.c_str(), is_a_recording);
  
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glutInitWindowSize(GL_WIN_SIZE_X, GL_WIN_SIZE_Y);
  glutCreateWindow ("NITE Skeleton Tracker");

  glutKeyboardFunc(glutKeyboard);
  glutDisplayFunc(glutDisplay);
  glutIdleFunc(glutIdle);

  glDisable(GL_DEPTH_TEST);
  glEnable(GL_TEXTURE_2D);

  glEnableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);  
  
  glutMainLoop();
  
  g_kinect_controller.shutdown();
  
  return 0;
}
Пример #2
0
void glutDisplay (void)
{
	xn::SceneMetaData sceneMD;
	xn::DepthMetaData depthMD;
  
  g_kinect_controller.getContext().WaitAndUpdateAll();
  g_skeleton_tracker.processKinect(g_kinect_controller);
  g_kinect_controller.getDepthGenerator().GetMetaData(depthMD);
  g_kinect_controller.getUserGenerator().GetUserPixels(0, sceneMD);  
	
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

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

	glOrtho(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
  
  glDisable(GL_TEXTURE_2D);
  
  kinect_display_drawDepthMapGL(depthMD, sceneMD);
	kinect_display_drawSkeletonGL(g_kinect_controller.getUserGenerator(),
                                g_kinect_controller.getDepthGenerator());  
  
	glutSwapBuffers();
}
Пример #3
0
void glutIdle (void)
{
  	g_kinect_controller.getContext().WaitAndUpdateAll();
  	g_skeleton_tracker.processKinect(g_kinect_controller);

	glutSetWindow(depth_window);
	glutPostRedisplay();

	glutSetWindow(rgb_window);
	glutPostRedisplay();
}
Пример #4
0
int main(int argc, char** argv)
{
  ros::init(argc, argv, "skeleton_tracker");
  //SkeletonTracker skd;
  ros::NodeHandle n;
  ros::NodeHandle np("~");
  string filepath;
  bool is_a_recording;
  np.getParam("load_filepath", filepath); 
  np.param<bool>("load_recording", is_a_recording, false);   
  
  g_skeleton_tracker.init();
  g_kinect_controller.init(filepath.c_str(), is_a_recording);

    // TODO... read these values from ini file
  const int fps = 30;
  const int width = 640;
  const int height = 480;

  g_attention_map.init(fps, width, height);

  glutInit(&argc, argv);
 
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glutInitWindowSize(GL_WIN_SIZE_X, GL_WIN_SIZE_Y);
  
  depth_window = glutCreateWindow ("Skeleton Depth");
  glutDisplayFunc(glutDepthDisplay);

  glDisable(GL_DEPTH_TEST);
  glEnable(GL_TEXTURE_2D);
  glEnableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY); 

  glutKeyboardFunc(glutKeyboard);

  rgb_window = glutCreateWindow ("Skeleton RGB");
  glutDisplayFunc(glutRgbDisplay);
  
  glDisable(GL_DEPTH_TEST);
  glEnable(GL_TEXTURE_2D);
  glEnableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);  
  
  glutIdleFunc(glutIdle);
  glutMainLoop();
  
  g_kinect_controller.shutdown();

  ros::spin();
  return 0;
}
void getSkeleton (void)
{
	xn::SceneMetaData sceneMD;
	xn::DepthMetaData depthMD;
  
  g_kinect_controller.getContext().WaitAndUpdateAll();
  g_skeleton_tracker.processKinect(g_kinect_controller);
  g_kinect_controller.getDepthGenerator().GetMetaData(depthMD);
  g_kinect_controller.getUserGenerator().GetUserPixels(0, sceneMD);  
	
	
/* ADDED */
	char strLabel[50] = "";
	XnUserID aUsers[15];
	XnUInt16 nUsers = 15;
	(g_kinect_controller.getUserGenerator()).GetUsers(aUsers, nUsers);
	for (int i = 0; i < nUsers; ++i)
	{
		if ((g_kinect_controller.getUserGenerator()).GetSkeletonCap().IsTracking(aUsers[i]))
		{
      // LEFT
			XnSkeletonJointPosition joint1, joint2;
			(g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_ELBOW, joint1);
			(g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_HAND, joint2);

			if (joint1.fConfidence < 0.5 || joint2.fConfidence < 0.5)
			{
				return;
			}

			XnPoint3D pt[2];
			pt[0] = joint1.position;
			pt[1] = joint2.position;

			g_kinect_controller.getDepthGenerator().ConvertRealWorldToProjective(2, pt, pt);
			std_msgs::Int32MultiArray l_array;
      l_array.data.clear();
      l_array.data.push_back(pt[1].X);
      l_array.data.push_back(pt[1].Y);
			l_hand_pub.publish(l_array);

      // RIGHT
      (g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_ELBOW, joint1);
      (g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_HAND, joint2);

      if (joint1.fConfidence < 0.5 || joint2.fConfidence < 0.5)
      {
        return;
      }

      pt[0] = joint1.position;
      pt[1] = joint2.position;

      g_kinect_controller.getDepthGenerator().ConvertRealWorldToProjective(2, pt, pt);
      std_msgs::Int32MultiArray r_array;
      r_array.data.clear();
      r_array.data.push_back(pt[1].X);
      r_array.data.push_back(pt[1].Y);
      r_hand_pub.publish(r_array);
    }
  }
}
void glutDisplay (void)
{
	xn::SceneMetaData sceneMD;
	xn::DepthMetaData depthMD;
  
  g_kinect_controller.getContext().WaitAndUpdateAll();
  g_skeleton_tracker.processKinect(g_kinect_controller);
  g_kinect_controller.getDepthGenerator().GetMetaData(depthMD);
  g_kinect_controller.getUserGenerator().GetUserPixels(0, sceneMD);  
	
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

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

	glOrtho(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
  
  glDisable(GL_TEXTURE_2D);
  
  kinect_display_drawDepthMapGL(depthMD, sceneMD);
	kinect_display_drawSkeletonGL(g_kinect_controller.getUserGenerator(),
                                g_kinect_controller.getDepthGenerator());  
	
/* ADDED */
	char strLabel[50] = "";
	XnUserID aUsers[15];
	XnUInt16 nUsers = 15;
	(g_kinect_controller.getUserGenerator()).GetUsers(aUsers, nUsers);
	for (int i = 0; i < nUsers; ++i)
	{
		if ((g_kinect_controller.getUserGenerator()).GetSkeletonCap().IsTracking(aUsers[i]))
		{
      // LEFT
			XnSkeletonJointPosition joint1, joint2;
			(g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_ELBOW, joint1);
			(g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_HAND, joint2);

			if (joint1.fConfidence < 0.5 || joint2.fConfidence < 0.5)
			{
				return;
			}

			XnPoint3D pt[2];
			pt[0] = joint1.position;
			pt[1] = joint2.position;

			g_kinect_controller.getDepthGenerator().ConvertRealWorldToProjective(2, pt, pt);
			std_msgs::Int32MultiArray l_array;
      l_array.data.clear();
      l_array.data.push_back(pt[1].X);
      l_array.data.push_back(pt[1].Y);
			l_hand_pub.publish(l_array);

      // RIGHT
      (g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_ELBOW, joint1);
      (g_kinect_controller.getUserGenerator()).GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_HAND, joint2);

      if (joint1.fConfidence < 0.5 || joint2.fConfidence < 0.5)
      {
        return;
      }

      pt[0] = joint1.position;
      pt[1] = joint2.position;

      g_kinect_controller.getDepthGenerator().ConvertRealWorldToProjective(2, pt, pt);
      std_msgs::Int32MultiArray r_array;
      r_array.data.clear();
      r_array.data.push_back(pt[1].X);
      r_array.data.push_back(pt[1].Y);
      r_hand_pub.publish(r_array);
    }
  }
  
	glutSwapBuffers();
}