We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Working on the Staying alive code from the book Making things see, I've got two poses (pose2 and pose3). So I want start a movie when pose2 is true and load a picture while pose3 is true. When I execute the following code, then it loads the picture even when I don't do the right pose, after user-detection thirdApplet is always executed…
//part of the code
void draw() {
background(0);
context.update();
image(context.depthImage(), 0, 0);
IntVector userList = new IntVector();
context.getUsers(userList);
if (userList.size() > 0) {
int userId = userList.get(0);
if ( context.isTrackingSkeleton(userId)) {
// check to see if the user
// is in the second pose
if (pose2.check(userId)) {
// if they are, set the color yellow
stroke(255,255,0);
// open second frame with movie
if(f==null)f = new PFrame();
} else {
// check to see if the user
// is in the third pose
if (pose3.check(userId)) {
//if they are, set the color yellow
stroke(255,255,0);
// open second frame with the image
if(g==null)g = new PFrame2();
} else {
// otherwise set the color to red
// and don’t start a thing
stroke(255, 0, 0);
}
// draw the skeleton in whatever color we chose
drawSkeleton(userId);
}
}
}
}
public class PFrame extends JFrame {
public PFrame() {
setBounds(2048,480,1920,1080);
frame1 = new secondApplet();
add(frame1);
frame1.init();
show();
setTitle("This is war");
}
}
public class PFrame2 extends JFrame {
public PFrame2() {
setBounds(2048,480,1920,1080);
frame2 = new thirdApplet();
add(frame2);
frame2.init();
show();
setTitle("This is hope");
}
}
public class secondApplet extends PApplet {
public void setup() {
size(1920, 1080);
//noLoop();
myMovie = new Movie(this, "/Users/nomac/Documents/Kinect project/sketch_140326/data/war.mov");
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
m.read();
}
public void draw() {
myMovie.play();
// add this from forum.processing.org/two/discussion/comment/6789
image(myMovie, 0, 0, 1920, 1080);
}
}
public class thirdApplet extends PApplet {
public void setup() {
size(1920, 1080);
img = loadImage("/Users/nomac/Documents/Kinect project/sketch_140326/data/hope.jpg");
}
public void draw() {
image(img, 0, 0, 1920, 1080);
}
}
Answers
This must work, it's inside the other code:
For some reason, when user detect (without doing the pose), the thirdApplet is executed. Anybody an idea?
Felt so stupid: it was the pose3-discription who triggered the thirdApplet. Now changed it to:
and the code above works. Case closed ;-)