如何获得SKEL_HEAD kinect的x位置?

问题描述 投票:0回答:1

我正在使用Arduino,Processing和Kinect编写一个安装程序。我想要的是从Processing Kinect User的示例代码中获取x-as SKEL_HEAD。

后来我想把我的头部的x-映射到180度伺服电机。

我现在拥有的是,当Kinect处于活动状态时,我的脑袋上画了一个红圈。

void drawSkeleton(int userId) {
  // to get the 3d joint data
  /*
  PVector jointPos = new PVector();
  context.getJointPositionSkeleton(userId,SimpleOpenNI.SKEL_NECK,jointPos);
  println(jointPos);
  */

  // Get X position of HEAD
  PVector jointPos = new PVector();
  context.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD, jointPos);
  println("jointPos " + jointPos);

  PVector jointPos2d = new PVector();
  context.convertRealWorldToProjective(jointPos,jointPos2d);  


  fill(255,0,0); // Fill the shape
  ellipse(jointPos2d.x, jointPos2d.y, 40,40); // Create the shape
arduino processing kinect
1个回答
0
投票

你的代码应该有效。调用convertRealWorldToProjective应该将3d坐标转换为2d坐标。我想知道的是,如果这是您想要的映射:头部的2d位置而不是Y轴上的头部旋转?

如果你想映射头部的旋转,你应该能够分解头部关节的3D变换矩阵,虽然我不确定它的准确度。如果不起作用,有other ways获得头部方向。

如果映射到伺服位置的2D位置是您所追求的,只要跟踪您追踪的骨架,就应该只是调用map()函数来对齐位置范围(可能是0-640px,具体取决于根据您的伺服设置,您的kinect设置为0-180 - 这些值可能会偏移一点。

绘制俯视图可能会很方便,您可以将平面中头部的位置映射到伺服旋转。这听起来有点像观察场景,其中伺服需要转动,因此物体面向头部2d位置。

© www.soinside.com 2019 - 2024. All rights reserved.