これは実際には奇妙な動作ですが、この部分の下に到達するには、ソースからSimpleOpenNIライブラリをコンパイルする必要があるかもしれません。getUsers()
メソッドが無効なメモリ参照を行っています。
これは、単にいくつかのテストをして物事を進めたい場合には実用的ではないかもしれません。 getUsers()
メソッドを使用しないことをお勧めします。おそらくgetNumberOfUsers()
を使用して逃げることができます:
import processing.video.*;
import SimpleOpenNI.*;
import java.util.*;
SimpleOpenNI kinect;
PImage kinectDepth;
int[] userID;
color[] userColor = new color[]{ color(255,0,0), color(0,255,0), color(0,0,255),
color(255,255,0), color(255,0,255), color(0,255,255)};
PVector headPosition = new PVector();
float headSize = 200;
float confidenceLevel = 0.5;
float confidence;
PVector confidenceVector = new PVector();
Movie movie1;
void setup()
{
size(640, 480);
movie1 = new Movie(this, "moon.mP4");
kinect = new SimpleOpenNI(this,"/Users/George/Downloads/gaf/as/CityWall/oni/test2.oni");
kinect.enableDepth();
kinect.enableUser();
movie1.loop();
}
void draw(){
kinect.update();
kinectDepth = kinect.depthImage();
image(kinectDepth,0,0);
//userID = kinect.getUsers();
for(int i=0;i<kinect.getNumberOfUsers();i++)
{
if(kinect.isTrackingSkeleton(i+1))
{
confidence = kinect.getJointPositionSkeleton(i+1,SimpleOpenNI.SKEL_HEAD,confidenceVector);
if(confidence > confidenceLevel)
{
// change draw color based on hand id#
stroke(userColor[(i)]);
// fill the ellipse with the same color
fill(userColor[(i)]);
// draw the rest of the body
drawSkeleton(i+1);
}
}
}
image(movie1, 0, 0, movie1.width/4, movie1.height/4);
}
/*---------------------------------------------------------------
Draw the skeleton of a tracked user. Input is userID
----------------------------------------------------------------*/
void drawSkeleton(int userId){
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_HEAD,headPosition);
kinect.convertRealWorldToProjective(headPosition,headPosition);
ellipse(headPosition.x,headPosition.y,30,30);
}
void onNewUser(SimpleOpenNI curContext, int userId){
println("New User Detected - userId: " + userId);
curContext.startTrackingSkeleton(userId);
}
void onLostUser(SimpleOpenNI curContext, int userId){
println("User Lost - userId: " + userId);
}
void onVisibleUser(SimpleOpenNI curContext, int userId){
} //void onVisibleUser(SimpleOpenNI curContext, int userId)
void movieEvent(Movie m) {
m.read();
}
心の中で裸これは、そのIDが何であるかを追跡されていませんが、どのように多くのユーザーを教えてくれます。 getNumberOfUsers()
の代わりに、intを使用することもできます.15にしようとすると、OpenNIがサポートする最大数のユーザーになる可能性があります。これは、あなたが常にkinect.isTrackingSkeleton
かどうかをチェックしているので機能します。
明るい解決策をありがとうございました。はい! getUser()メソッドにバグがあるようです。 –