Camera walk?

I’ve posted it before I think that I always wanted a holodeck. But of course this is nothing like that. So for this project I finally got the network camera working at my place in Queens and uploading the images every 15 minutes. I shot some video from a window at ITP and put the two together.

I knew I was going to use the Kinect and initially began using the depthMap and measuring in inches and using the values there to determine distance. That didn’t work for me. I decided to use the Center of Mass or CoM command to determine the position but then depth would be another problem.

Soooo for the purposes of this project I just adjusted the position of the kinect to be overhead to simplify the position.

Adding a fornt facing camera turned out to be more challenging. For some reason, OpenNI takes over all the cameras of the computer and will only want the kinect. Solution? Add another kinect.

I’d like to expand this further with head tracking such as imitating the look around an area or even creating the illusion of depth without 3D glasses.


import SimpleOpenNI.*;
import processing.video.*;

SimpleOpenNI kinect;
SimpleOpenNI kinect2;
Movie movie;
Capture cam;

boolean handsTrackFlag = false;
PVector handVec = new PVector();
imageStream imageStreamObject;

int userId = 0;

void setup() {
size(640, 480);

imageStreamObject = new imageStream();

kinect = new SimpleOpenNI(0,this);
kinect2 = new SimpleOpenNI(1,this);
kinect.enableDepth();
kinect2.enableRGB();
// kinect.enableGesture();
// kinect.enableHands();
kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_NONE);
// kinect.addGesture("RaiseHand");
kinect.setMirror(true);
movie = new Movie(this, "edited.mov");
movie.loop();

//choose a camera only if using Center of Mass code
String[] cameras = Capture.list();

if (cameras.length == 0) {
println("Available cameras: ");
for (int i=0; i<cameras.length; i++) {
println(cameras[i]);
}
}
cam = new Capture(this, 640, 480, cameras[0]);
cam.start();
}

void movieEvent(Movie movie) {
movie.read();
}

void draw() {
kinect.updateAll();
// image(kinect.depthImage(), 0, 0);

//Center of Mass code
IntVector userList = new IntVector();
kinect.getUsers(userList);

for (int i=0; i<userList.size(); i++) {
int userId = userList.get(i);

PVector position = new PVector();
kinect.getCoM(userId, position);

kinect.convertRealWorldToProjective(position, position);
//fill(255, 0, 0);
// ellipse(position.x, position.y, 25, 25);
if (position.y 160 && position.y < 320 ) {
tint(255, 40);
image(movie, 0, 0, 640, 480);
}
else {
// tint(255, 0);
image(kinect2.rgbImage(), 0, 0); //use for CoM
}
}

//Hand Tracking code
/*
if (handsTrackFlag)
{
PVector myPositionScreenCoords = new PVector(); //storage device
//convert the weird kinect coordinates to screen coordinates.
kinect.convertRealWorldToProjective(handVec, myPositionScreenCoords);
fill(255, 0, 0);
ellipse(myPositionScreenCoords.x, myPositionScreenCoords.y, 20, 20);
println("X: " + myPositionScreenCoords.x);
println("Y: "+ myPositionScreenCoords.y);

// Conditions to track hands

if (myPositionScreenCoords.x < 320 && myPositionScreenCoords.y 320 && myPositionScreenCoords.y 320 && myPositionScreenCoords.y > 240) {

imageStreamObject.drawBack();
}
else {
image(kinect.rgbImage(), 640, 0);
}
if (myPositionScreenCoords.x 240) {

imageStreamObject.drawBack();
}
else {
image(kinect.rgbImage(), 640, 0);
}

*/
}
// ----------------------------------------------------------------- // hand events
/*
void onCreateHands(int handId, PVector pos, float time) {

println("onCreateHands - handId: " + handId + ", pos: " + pos + ", time:" + time);
handsTrackFlag = true;
handVec = pos;
}

void onUpdateHands(int handId, PVector pos, float time) {

//println("onUpdateHandsCb - handId: " + handId + ", pos: " + pos + ", time:" + time);
//store the location of the hand in a vector object
handVec = pos;
}

void onDestroyHands(int handId, float time) {

println("onDestroyHandsCb - handId: " + handId + ", time:" + time);
handsTrackFlag = false;
//go back to looking for the guesture that gave you hand.
kinect.addGesture("RaiseHand");
}

// ----------------------------------------------------------------- // gesture events

void onRecognizeGesture(String strGesture, PVector idPosition, PVector endPosition) {

println("onRecognizeGesture - strGesture: " + strGesture + ", idPosition: " + idPosition + ", endPosition:" + endPosition);
//stop looking for the gesture
kinect.removeGesture(strGesture);
//use the location of this guesture tell you where to start tracking the hand
kinect.startTrackingHands(endPosition);
}

void onProgressGesture(String strGesture, PVector position, float progress) {

//println("onProgressGesture - strGesture: " + strGesture + ", position: " + position + ", progress:" + progress);
}
*/

Comments are closed.