실제로 이상한 동작이지만,이 코드의 맨 아래로 가면 소스에서 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() 메소드에 버그가있는 것 같습니다. –