Мы использовали следующий код для того, чтобы сделать скелет отслеживания (отслеживания головы) и воспроизведение видео одновременно:Скелет отслеживания и воспроизведения видео в обработке
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 байт) @ 0x0000000002 ebe695 [0x0000000002ebe640 + 0x55] J С1 SimpleOpenNI.IntVector.size тысяча четыреста семьдесят-один() J (8 байт) @ 0x0000000002ebe314 [0x0000000002ebe280 + 0x94] J SimpleOpenNI.SimpleOpenNI.getUsers() [I + 15 J С1 skeleton_track_simpleopen_video.draw тысяча семьсот семьдесят-семь () V (159 bytes) @ 0x0000000003004ca4 [0x0000000003004600 + 0x6a4] j processing.core.PApplet.handleDraw() V + 161 J 1769 C1 processing.awt.PSurfaceAWT $ 12.callDraw() V (18 bytes) @ 0x000000000300009c [0x0000000002ffff80 + 0x11c] J processing.core.PSurfaceNone $ AnimationThread.run() V + 30 V ~ StubRoutines :: call_stub
Примечательно, что выше код работать без каких-либо ошибок в отсутствие воспроизведения видео (processing.video library).
Возможно ли помочь нам найти проблему в вышеуказанном коде?
Большое спасибо за ваше яркое решение. Да! кажется, что метод getUser() имеет ошибку. –