1

スケルトン トラッキング (ヘッド トラッキング) とビデオの再生を同時に行うために、次のコードを使用しました。

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);
   kinect.enableDepth();
  kinect.enableUser();
    movie1.play();
} 

void draw(){
  image(movie1, 0, 0, width, height);
  kinect.update();
  kinectDepth = kinect.depthImage();
  image(kinectDepth,0,0); 
  userID = kinect.getUsers();

  for(int i=0;i<userID.length;i++)
  {
    if(kinect.isTrackingSkeleton(userID[i]))
    {
      confidence = kinect.getJointPositionSkeleton(userID[i],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(userID[i]);

      } 
    }
  } 
} 

/*---------------------------------------------------------------
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();
}

上記のコードを実行するように関連付けると、ログ ファイルに次のエラーが生成されました。

Java フレーム: (J=コンパイル済み Java コード、j=解釈済み、Vv=VM コード) J 1472 SimpleOpenNI.SimpleOpenNIJNI.IntVector_size(JLSimpleOpenNI/IntVector;)J (0 バイト) @ 0x0000000002ebe695 [0x0000000002ebe640+0x55] J 1471 C1 SimpleOpenNI.IntVector .size()j(8バイト) @ 0x0000000002ebe314 [0x0000000002ebe280+0x94] j Simpleopenni.simpleopenni.getusers()[i+15 J 1777 C1 Skeleton_track_simpleopen_video.draw .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 ライブラリ) を再生していなくてもエラーなしで実行されたことは注目に値します。

上記のコードの問題を見つけるのを手伝ってもらえますか?

4

1 に答える 1