0

画像処理初心者です。Simple OpenNI for Processing の getUserPixels() を使用して複数のユーザーを追跡するにはどうすればよいですか? これはパラメータとして何を取りますか? このコードをどのように設定しますか?

4

1 に答える 1

1

アイデアは、検出されたユーザーを追跡することです。

関数はユーザー ピクセルを追跡するのに便利ですが、ユーザーを追跡するためのプロファイルをsceneImage()/sceneMap()有効にすることも好みます。SKEL_PROFILE_NONE

これは、整数 (そのユーザーの ID) を返すonNewUserおよびイベントで機能します。onLostUserこの ID は、合計ユーザーまたは検出された最新のユーザーを追跡するために重要です。ユーザーのIDを取得したら、それを他のSimpleOpenNI機能にプラグインできます。たとえばgetCoM()、ユーザーの「重心」(体の中心のx、y、z位置)を返します。

したがって、上記のユーザー イベントを使用して、ユーザーの内部リストを更新します。

import SimpleOpenNI.*;

SimpleOpenNI context;
ArrayList<Integer> users = new ArrayList<Integer>();//a list to keep track of users

PVector pos = new PVector();//the position of the current user will be stored here

void setup(){
  size(640,480);
  context = new SimpleOpenNI(this);
  context.enableDepth();
  context.enableScene();
  context.enableUser(SimpleOpenNI.SKEL_PROFILE_NONE);//enable basic user features like centre of mass(CoM)
}
void draw(){
  context.update();
  image(context.sceneImage(),0,0);
  if(users.size() > 0){//if there are any users
    for(int user : users){//for each user
      context.getCoM(user,pos);//get the xyz pozition
      text("user " + user + " is at: " + ((int)pos.x+","+(int)pos.y+","+(int)pos.z+",")+"\n",mouseX,mouseY);//and draw it on screen
    }
  }
}
void onNewUser(int userId){
  println("detected" + userId);
  users.add(userId);//a new user was detected add the id to the list
}
void onLostUser(int userId){
  println("lost: " + userId);
  //not 100% sure if users.remove(userId) will remove the element with value userId or the element at index userId
  users.remove((Integer)userId);//user was lost, remove the id from the list
}

HTH

于 2013-02-07T13:22:57.953 に答える