Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将Kinect输入放大(检测到silhuette)以匹配16:9分辨率_Java_Processing_Kinect_Openni - Fatal编程技术网

Java 将Kinect输入放大(检测到silhuette)以匹配16:9分辨率

Java 将Kinect输入放大(检测到silhuette)以匹配16:9分辨率,java,processing,kinect,openni,Java,Processing,Kinect,Openni,我正在基于背景和前景视频进行实时投影。前景视频应该投射到在kinect前面跳舞的人身上 目前,我正在努力扩展这个设置。显然,处理草图的输出需要全屏显示。视频的分辨率为1280x720 这是源代码: import processing.video.*; import SimpleOpenNI.*; // Member SimpleOpenNI context; int[] userMap; PImage rgbImage; PImage userImage; color pixelColor;

我正在基于背景和前景视频进行实时投影。前景视频应该投射到在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();
  }
}
导入处理。视频。*;
导入SimplePenni。*;
//成员
simplepenni语境;
int[]用户映射;
PImage rgbImage;
PImage用户图像;
彩色像素;
电影前景;
电影背景;
无效设置(){
尺寸(640480);
//frame.setresizeable(true);
//初始化kinect
上下文=新的SimplePenni(此);
enablegb();
enableDepth();
context.enableUser();
//初始化用户图像和视频
userImage=createImage(宽度、高度、RGB);
前台=新电影(此为“前台.mp4”);
loop();
//前台播放();
背景=新电影(此为“background.mp4”);
background.loop();
//background.play();
//println(“前景长度:+前景.像素.长度”);
//第一帧的背景长度为0
//println(“背景长度:“+background.pixels.length”);
}
作废提款(){
//画前景
图像(前景,0,0);
update();
rgbImage=context.rgbImage();
userMap=context.userMap();
对于(int y=0;如果frameCount=0,则y索引超出范围异常
userImage.pixels[index]=background.pixels[index];
}
}
}
}
//显示结果
userImage.updatePixels();
图像(userImage,0,0);
}
//读两部电影
无效电影事件(电影m){
如果(m==前景){
read();
}
如果(m==背景){
background.read();
}
}

将其放大到高清全屏的最合理或最好的方法是什么?kinect的比例是4:3,这让它有点不舒服。

只需将图像重新缩放到所需的分辨率?这将是一个肮脏的解决方案,但我希望避免silhuette上的任何失真。在kinect可用之前,我可能会接受它在解决方案中使用16:9的比例。如果您不希望更改纵横比,则需要进行等距调整,然后将图像裁剪到所需的大小。谢谢,我没有考虑这种方法。我会在有时间时尽快更新此方法。