User Center of Mass Tracking

This program uses the depth sensors to track the center of gravity of tracked users. It will display a circle on the user’s center of gravity and display each tracked user’s center of gravity vector position.

import SimpleOpenNI.*;
 
// create kinect object
SimpleOpenNI kinect;

// current position of current user
PVector position = new PVector();

// current kinect image storage
PImage kinectImage;

// create new user list
IntVector userList;

// size of dot to show center of mass position
int dotSize = 10;

// user colors
color[] userColor = new color[]{ 
  color(255,0,0), 
  color(0,255,0), 
  color(0,0,255),
  color(255,255,0), 
  color(255,0,255), 
  color(0,255,255)
};

/*---------------------------------------------------------------
Setup method. enables kinect and tracking. Creates draw window
----------------------------------------------------------------*/
void setup() {
  // create new kinect object
  kinect = new SimpleOpenNI(this);

  // enable depth sensor
  kinect.enableDepth();

  // enable rgb sensor
  kinect.enableRGB();

  // enable tracking but with no joint tracking
  kinect.enableUser();

  // start new user list
  userList = new IntVector();

  // create window size of depth info
  size(kinect.rgbWidth(),kinect.rgbHeight());
}
 
/*---------------------------------------------------------------
Draw method. Updates kinect and displays it. Draws red dots at
tracked user's center of gravity
----------------------------------------------------------------*/
void draw() {
  // update kinect
  kinect.update();

  // get current image from kinect
  kinectImage = kinect.rgbImage();

  //draw current image at (0,0)
  image(kinectImage, 0, 0);
 
  //get list of tracked users
  kinect.getUsers(userList);
 
  //for each tracked user find center of gravity
  for (int i=0; i
	

Leave a Reply

Your email address will not be published. Required fields are marked *