1

好吧,我正在制作一个在 Processing 中使用 SimpleOpenNI 库的草图,并且我正在骨架上安装一个 3D 设计,但我一直在想,如果另一个人站在 Kinect 前面,那么模型会有所不同,如果人比我高或小,因为我正在做测试,我想知道是否有办法缩放由 SimpleOpenNI 制作的骨架,所以我可以在我的草图中将其作为标准,以便任何站在前面的人将在草图中具有相同的高度,并且 3D 的所有部分将保持在同一位置。我希望你们能给我一个提示,因为这是我第一个使用骨架的项目。谢谢!

4

1 回答 1

2

如果您想以相同的比例绘制 3D 骨架,您可以使用固定相机创建一个 3D 场景,其中骨架在固定位置的表示(这样比例不会改变)并简单地使用关节的方向(旋转矩阵)(不是位置)来更新您的自定义头像/字符表示。

您可以使用 SimpleOpenNI 的方法将方向作为PMatrix3D获得。getJointOrientationSkeleton()然后,您可以使用 Processing 的applyMatrix()来定位您的自定义网格:

PMatrix3D  orientation = new PMatrix3D();
context.getJointOrientationSkeleton(userId,SimpleOpenNI.SKEL_HEAD,orientation);
pushMatrix();
applyMatrix(orientation);//rotate box based on head orientation
box(40);
popMatrix();  

或作为最小样本:

import SimpleOpenNI.*;
SimpleOpenNI  context;
PMatrix3D  orientation = new PMatrix3D();//create a new matrix to store the steadiest orientation (used in rendering)
PMatrix3D  newOrientaton = new PMatrix3D();//create a new matrix to store the newest rotations/orientation (used in getting data from the sensor)
void setup() {
  size(640, 480,P3D);
  context = new SimpleOpenNI(this);
  context.enableUser();//enable skeleton tracking
}
void draw(){
  context.update(); 
  background(0);
  lights();
  translate(width * .5, height * .5,0);
  if(context.isTrackingSkeleton(1)){//we're tracking user #1
        newOrientaton.reset();//reset the raw sensor orientation 
        float confidence = context.getJointOrientationSkeleton(userId,SimpleOpenNI.SKEL_HEAD,newOrientaton);//retrieve the head orientation from OpenNI
        if(confidence > 0.001){//if the new orientation is steady enough (and play with the 0.001 value to see what works best)
          orientation.reset();//reset the matrix and get the new values
          orientation.apply(newOrientaton);//copy the steady orientation to the matrix we use to render the avatar
        }
        //draw a box using the head's orientation
        pushMatrix();
        applyMatrix(orientation);//rotate box based on head orientation
        box(40);
        popMatrix();  
  }
}

由您来组织角色的层次结构并设置具有所需视角的相机。

于 2014-05-31T00:12:38.747 回答