0

我需要找到一种方法让 kinect 只识别特定范围内的对象。问题是在我们的设置中,场景周围会有可能干扰跟踪的观众。因此,我需要将 kinect 设置为几米的范围,这样它就不会受到超出该范围的物体的干扰。我们使用 SimpleOpenNI 库进行处理。

有没有可能以任何方式实现这样的目标?

非常感谢您提前。

马泰奥

4

1 回答 1

1

您可以获得用户的质心 (CoM),它可以在没有骨架检测的情况下为用户检索 ax,y,z 位置:

OpenNI 用户 CoM

根据 z 位置,您应该能够为您的范围/阈值使用基本的 if 语句。

import SimpleOpenNI.*;

SimpleOpenNI context;//OpenNI context
PVector pos = new PVector();//this will store the position of the user
ArrayList<Integer> users = new ArrayList<Integer>();//this will keep track of the most recent user added
float minZ = 1000;
float maxZ = 1700;

void setup(){
  size(640,480);
  context = new SimpleOpenNI(this);//initialize
  context.enableScene();//enable features we want to use
  context.enableUser(SimpleOpenNI.SKEL_PROFILE_NONE);//enable user events, but no skeleton tracking, needed for the CoM functionality
}
void draw(){
  context.update();//update openni
  image(context.sceneImage(),0,0);
  if(users.size() > 0){//if we have at least a user
    for(int user : users){//loop through each one and process
      context.getCoM(user,pos);//store that user's position
      println("user " + user + " is at: " + pos);//print it in the console
      if(pos.z > minZ && pos.z < maxZ){//if the user is within a certain range
        //do something cool 
      }
    }
  }
}
//OpenNI basic user events
void onNewUser(int userId){
  println("detected" + userId);
  users.add(userId);
}
void onLostUser(int userId){
  println("lost: " + userId);
  users.remove(userId);
}

您可以在我发布的这些研讨会笔记中找到更多解释和有用的提示。

于 2012-12-08T00:13:38.897 回答