Error: It looks like you're mixing active and static modes !?
in
Contributed Library Questions
•
9 months ago
Hello everybody,
I don't know what's the problem with the error in headline. The web says about this special error, to control the curly brackets. But I've controlled them all, so far as I know.
Maybe you can help me? What's exactly the problem?
Thanks in advance.
Following the code:
- import SimpleOpenNI.*;
- import org.json.*;
- import processing.video.*;
- SimpleOpenNI kinect;
- int BeamerWidth = 1024;
- int BeamerHeight = 768;
- int currentVid=0;
- boolean tracking;
- //PVector jointNeck = new PVector();
- float steering;
- //float ux;
- final static byte videosNum = 2;
- final static Movie[] allVideos = new Movie[videosNum];
- void setup() {
- size(BeamerWidth, BeamerHeight);
- smooth();
- background(0);
- for (int i=0; i<videosNum; i++)
- allVideos[i] = new Movie (this, "probesequenz0"+(i+1)+".ogg");
- kinect = new SimpleOpenNI (this);
- kinect.enableDepth();
- kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_UPPER);
- }
- void draw() {
- steering = steer();
- }
- // A new time position is calculated using the current mouse location:
- float f = constrain((float)jointRightHand.x / width, 0, 1);
- float destination = allVideos[currentVid].duration() * f;
- float current = allVideos[currentVid].time();
- println("current: " + current + ", destination: " + destination);
- if (current < destination)
- allVideos[currentVid].speed(1);
- else
- allVideos[currentVid].speed(-1);
- allVideos[currentVid].play();
- println("speed: " + 15.0*abs(destination-current)/abs(destination+current)+1);
- image(allVideos[currentVid], 0, 0, width, height);
- rect(0, 0, allVideos[currentVid].time()/allVideos[currentVid].duration()*width, 10);
- frame.setTitle("scratch (" + round(frameRate) + " fps)");
- if (keyPressed) {
- if (key == '1') {
- currentVid=1;
- }
- else {
- currentVid=0;
- }
- }
- float steer ()
- {
- kinect.update();
- tracking = false;
- for (int i = 1; i<6; i++)
- {
- if ( kinect.isTrackingSkeleton(i) )
- {
- tracking = true;
- PVector jointRightHand = new PVector();
- PVector jointLeftHand = new PVector();
- kinect.getJointPositionSkeleton(i, SimpleOpenNI.SKEL_RIGHT_HAND, jointRightHand);
- kinect.getJointPositionSkeleton(i, SimpleOpenNI.SKEL_LEFT_HAND, jointLeftHand);
- if (jointLeftHand.z > jointRightHand.z) return (-jointRightHand.x);
- return (-jointLeftHand.x);
- }
- }
- return(0.0);
- }
- void onNewUser (int userID) {
- println ("start pose detection");
- // kinect.startPoseDetection("Psi", userID);
- kinect.requestCalibrationSkeleton(userID, true);
- }
- void onEndCalibration (int userID, boolean successful) {
- if (successful) {
- println(" User Calibrated!!!");
- kinect.startTrackingSkeleton(userID);
- }
- else {
- println(" Failed to calibrate user !!!");
- kinect.startPoseDetection("Psi", userID);
- }
- }
- void onStartPose(String pose, int userID) {
- println("Started pose for user");
- kinect.stopPoseDetection(userID);
- kinect.requestCalibrationSkeleton(userID, true);
- }
- // Called every time a new frame is available to read
- void movieEvent(Movie allVideos) {
- allVideos.read();
- }
Regards
buc
2