Calibrate Projector with Masked Video

edited April 2015 in Library Questions

Hi, i have created this simple patch that mask the Users body with a video while he/she dances and now i want to place the real human dancer to do some test with my code. Do you have any suggestions about how to do this? Plus i want to know about the resolution and how this affects the dancer if he/she dances fast will the fps with the projector be affected, or it just has to do with pc/mac hardware configuration ?) My code is this (Optimization or better coding techniques are always welcome :) ) *remember to replace the video: blue.mp4 with your own.

/**
 * Loop. 
 * 
 * Shows how to load and play a movie file and mask a user with blend mode
 *
 */

import processing.video.*;
import SimpleOpenNI.*;
SimpleOpenNI context;
Movie movie;

PImage userImage;
int[] userMap;
PImage rgbImage;
color pixelColor;

void setup() {
  size(640, 360);
  background(0);
  // Load and play the video in a loop
  movie = new Movie(this, "blue.mp4");
  movie.loop();
  context=new SimpleOpenNI(this);
  context.enableRGB();
  context.enableDepth();
  context.enableUser();
  context.setMirror(true);
  userImage=createImage(640,480,RGB);
}

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

void draw() {
  //if (movie.available() == true) {
  //  movie.read(); 
  //}
  image(movie, 0, 0, width, height);

   context.update();
  rgbImage=context.rgbImage();


  userMap=context.userMap();
  for(int y=0;y<context.depthHeight();y++){
    for(int x=0;x<context.depthWidth();x++){
      int index=x+y*640;
      if(userMap[index]!=0){
          pixelColor=rgbImage.pixels[index];
        userImage.pixels[index]=color(255,255,255);
      }else{
        userImage.pixels[index]=color(0,0,0,255);
      }


    }
  }
  userImage.updatePixels();
  userImage.blend(movie, 0,0,userImage.height, userImage.width, 0,0,userImage.width,userImage.height,MULTIPLY);
  image(userImage,0,0);
}

Answers

  • edited April 2015

    thanx for the code formatting tip!

  • Is the real human dancing in front of a green screen or something? What exactly do you want to do : put the human in the video or the video behind the human? Your are a Max user?

  • The project is similar to this one http://princemio.net/portfolio/kinect_projector_dance/ but instead of graphic animations I use the body of the dancer as a mask and a video that loops all the time, there is no green wall/screen just a normal white wall in a dark room that the scetch will be projected and I want to know how to calibrate the distance of the kinect the distance of the projector that will project on the wall and how you calculate thing. Sso for example how does the body of the dancer will have the same size with mask projection on the wall ? Like on the link above? I have found the keynote library for this so far but I don't know how to pass the calibration file to my code afterwards. Thank you for your time !

Sign In or Register to comment.