I’m a beginner, can you tell me the details please?
The background image is regenerated, but I can’t see the image of people being recognized and floating people.
And the video that you ran before that runs together.
How should I fix it?
import processing.serial.*;
import processing.video.*;
Serial serial;
Movie movie, R1, BG;
import SimpleOpenNI.*;
SimpleOpenNI kinect;
float headX, headY, oldHeadY;
float right_handX, right_handY, right_handZ, oldright_handZ;
float right_kneeX, right_kneeY, right_kneeZ, oldright_kneeY, oldright_kneeZ;
float left_kneeX, left_kneeY, left_kneeZ, oldleft_kneeY, oldleft_kneeZ;
float left_handX, left_handY, left_handZ, oldleft_handZ;
float left_footX, left_footY, left_footZ, oldleft_footY, oldleft_footZ;
PImage[] jump = new PImage[22];
PImage[] ready = new PImage[30];
PImage[] breath = new PImage[21];
PImage[] run = new PImage[23];
float imX, imY;
int readyC, breathC, jumpC, runC ;
void setup() {
size(1920, 1080);
for (int i = 0; i < ready.length; i ++) {
ready[i] = loadImage("ready_" + i + ".png");
}
for (int i = 0; i < breath.length; i ++) {
breath[i] = loadImage("breath_" + i + ".png");
}
for (int i = 0; i < jump.length; i ++) {
jump[i] = loadImage("jump_" + i + ".png");
}
for (int i = 0; i < run.length; i ++) {
run[i] = loadImage("run_" + i + ".png");
}
imX = 700;
imY = 250;
readyC = 0;
breathC = 0;
jumpC = 0;
runC = 0;
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableUser();
kinect.enableRGB();
stroke(255, 0, 0);
fill(0, 255, 0);
R1 = new Movie(this, "real_1.mov");
BG = new Movie(this, "BG.mov");
movie = R1;
movie.loop();
}
void draw() {
if (movie.available()) {
movie.read();
background(movie);
}
if (movie != R1) {
if (movie.time() > movie.duration() - 0.1){
movie.stop();
delay(10);
movie.loop();
image(ready[readyC], imX, imY);
image(breath[breathC], imX, imY);
image(jump[jumpC], imX, imY);
image(run[runC], imX, imY);
kinect.update();
image(BG, 0, 0);
int[] userList = kinect.getUsers();
if (userList.length > 0) {
//drawSkeleton(userList[0]);
PVector p = new PVector();
kinect.getJointPositionSkeleton(userList[0], SimpleOpenNI.SKEL_HEAD, p);
kinect.convertRealWorldToProjective(p, p);
ellipse(p.x, p.y, 10, 10);
headX = p.x;
headY = p.y;
PVector h = new PVector();
kinect.getJointPositionSkeleton(userList[0], SimpleOpenNI.SKEL_RIGHT_HAND, h);
kinect.convertRealWorldToProjective(h, h);
ellipse(h.x, h.y, 10, 10);
right_handX = h.x;
right_handY = h.y;
right_handZ = h.z;
PVector e = new PVector();
kinect.getJointPositionSkeleton(userList[0], SimpleOpenNI.SKEL_RIGHT_KNEE, e);
kinect.convertRealWorldToProjective(e, e);
ellipse(e.x, e.y, 10, 10);
right_kneeX = e.x;
right_kneeY = e.y;
right_kneeZ = e.z;
PVector ee = new PVector();
kinect.getJointPositionSkeleton(userList[0], SimpleOpenNI.SKEL_LEFT_KNEE, ee);
kinect.convertRealWorldToProjective(ee, ee);
ellipse(ee.x, ee.y, 10, 10);
left_kneeX = ee.x;
left_kneeY = ee.y;
left_kneeZ = ee.z;
PVector d = new PVector();
kinect.getJointPositionSkeleton(userList[0], SimpleOpenNI.SKEL_LEFT_HAND, d);
kinect.convertRealWorldToProjective(d, d);
ellipse(d.x, d.y, 10, 10);
left_handX = d.x;
left_handY = d.y;
left_handZ = d.z;
PVector f = new PVector();
kinect.getJointPositionSkeleton(userList[0], SimpleOpenNI.SKEL_LEFT_FOOT, f);
kinect.convertRealWorldToProjective(f, f);
ellipse(f.x, f.y, 10, 10);
left_footX = f.x;
left_footY = f.y;
left_footZ = f.z;
}
//jump
if (oldHeadY - headY > 15) {
if(oldright_kneeY - right_kneeY > 8) {
if(left_kneeY - right_kneeY < 10) {
if (oldleft_kneeZ - left_kneeZ > -30) {
jumpC ++;
jumpC %= jump.length;
}
}
}
}
//ready
else if (oldright_handZ - right_handZ > 30) {
if( oldright_kneeZ - right_kneeZ > 20) {
if( left_handZ - right_handZ > 20) {
if( oldleft_footZ - left_footZ < 10) {
readyC ++;
readyC %= ready.length;
}
}
}
}
//run
else if (oldleft_handZ - left_handZ > 25) {
if (oldright_kneeY - right_kneeY > 20) {
if (oldleft_kneeZ - left_kneeZ < 10) {
runC ++;
runC %= run.length;
}
}
} else {
breathC ++;
breathC %= breath.length;
}
oldHeadY = headY;
oldright_handZ = right_handZ;
oldright_kneeY = right_kneeY;
oldright_kneeZ = right_kneeZ;
oldleft_kneeY = left_kneeY;
oldleft_kneeZ = left_kneeZ;
oldleft_handZ = left_handZ;
oldleft_footY = left_footY;
oldleft_footZ = left_footZ;
}
}
}
void movieEvent (Movie m) {
if (movie == R1) {
if (movie.time() > movie.duration() - 0.1){
movie = BG;}
movie.play();
}
}
void onNewUser(SimpleOpenNI curkinect, int userId) {
curkinect.startTrackingSkeleton(userId);
}
void drawSkeleton(int userId) {
kinect.drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_LEFT_SHOULDER);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_LEFT_ELBOW);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, SimpleOpenNI.SKEL_LEFT_HAND);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_NECK, SimpleOpenNI.SKEL_RIGHT_SHOULDER);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_RIGHT_ELBOW);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, SimpleOpenNI.SKEL_RIGHT_HAND);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, SimpleOpenNI.SKEL_TORSO);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, SimpleOpenNI.SKEL_TORSO);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_LEFT_HIP);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, SimpleOpenNI.SKEL_LEFT_KNEE);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, SimpleOpenNI.SKEL_LEFT_FOOT);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_TORSO, SimpleOpenNI.SKEL_RIGHT_HIP);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, SimpleOpenNI.SKEL_RIGHT_KNEE);
kinect.drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, SimpleOpenNI.SKEL_RIGHT_FOOT);
}```