2017-01-12 7 views
1

에서 비디오를 재생 우리는 골격 추적 (머리 추적)을 수행하기 위해 동시에 비디오를 재생하는 다음 코드를 사용해골 추적 및 처리

자바 프레임 :; J (J = 컴파일 된 자바 코드, J = 해석, VV는 = VM 코드) J 1472 SimpleOpenNI.SimpleOpenNIJNI.IntVector_size (JLSimpleOpenNI/IntVector을) 우리가 위의 코드를 실행하는 연결하면 파일 (0 바이트) @ 0x0000000002 0x0000000002ebe314 [0x0000000002ebe280 + 0x94]의 SimpleOpenNI.SimpleOpenNI.getUsers J() [I 15 J 1,777 C1 skeleton_track_simpleopen_video.draw을 + (@ ebe695 [0x0000000002ebe640 + 0x55] J 1,471 C1 SimpleOpenNI.IntVector.size() J (8 바이트)) V (159 바이트) @ 0x0000000003004ca4 [0x0000000003004600 + 0x6a4] j processing.core.PApplet.handleDraw() V + 161 J 1769 C1 processing.awt.PSurfaceAWT $ 12.callDraw() V (18 바이트) @ 0x000000000300009c [0x0000000002ffff80 + 0x11c] J processing.core.PSurfaceNone $ AnimationThread.run() V + 30 V ~ StubRoutines :: call_stub는

그것은 놀라운 위의 코드는 오류없이 실행했다고 비디오가 재생되지 않을 때 (processing.video 라이브러리).

위의 코드에서 문제를 찾는데 도움이 될 수 있습니까?

답변

0

실제로 이상한 동작이지만,이 코드의 맨 아래로 가면 소스에서 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(); 
} 

demo

베어 마음이 사용자가 추적 얼마나 많은 당신을 말할 것이다, 그러나 그들의 ID는없는 것입니다. getNumberOfUsers() 대신 int를 사용할 수도 있습니다. 15 개는 OpenNI가 지원할 수있는 최대 사용자 수입니다. 이것은 kinect.isTrackingSkeleton 일 경우 항상 확인하기 때문에 효과가 있습니다.

+0

밝은 해결책을 가져 주셔서 감사합니다. 예! getUser() 메소드에 버그가있는 것 같습니다. –