我正在进行基于backgorund和前景视频的实时投影。前景视频应该被投射到在kinect前面跳舞的人身上。
目前,我正在努力扩展此设置。显然,处理草图的输出需要全屏。视频的分辨率为1280x720。
这是源代码:
import processing.video.*;
import SimpleOpenNI.*;
// Member
SimpleOpenNI context;
int[] userMap;
PImage rgbImage;
PImage userImage;
color pixelColor;
Movie foreground;
Movie background;
void setup() {
size(640, 480);
//frame.setResizable(true);
// initialize kinect
context = new SimpleOpenNI(this);
context.enableRGB();
context.enableDepth();
context.enableUser();
// initialize user image and videos
userImage = createImage(width, height, RGB);
foreground = new Movie(this, "foreground.mp4");
foreground.loop();
//foreground.play();
background = new Movie (this, "background.mp4");
background.loop();
//background.play();
//println("foreground length : " + foreground.pixels.length);
// background length is 0 on the very first frame
//println("background length : " + background.pixels.length);
}
void draw() {
// draw foreground
image(foreground, 0, 0);
context.update();
rgbImage=context.rgbImage();
userMap=context.userMap();
for(int y=0;y<context.depthHeight();y++){
for(int x=0;x<context.depthWidth();x++){
// use silhuette to cut out foreground movie
int index=x+y*640;
if(userMap[index]!=0){
pixelColor=rgbImage.pixels[index];
userImage.pixels[index]=color(0,255, 0 , 0);
}else{
//userImage.pixels[index] = color(255);
// the first frame of the second movie is not read on the very first frame !!!
if(frameCount > 1){
// -> index out of bounds exception if frameCount == 0
userImage.pixels[index] = background.pixels[index];
}
}
}
}
// display the result
userImage.updatePixels();
image(userImage,0,0);
}
// read both movies
void movieEvent(Movie m){
if(m == foreground){
foreground.read();
}
if (m == background){
background.read();
}
}
将此扩展到HD FullScreen的最合理或最佳方法是什么? kinect的比例是4:3,这让它有点不舒服。