Processing Kinect Tracking - Change .jpg file to .gif -

Hi, I’m currently having trouble trying to change a jpg which is moving with the tracker into a gif file - so multiple images can be shown whilst moving around a screen.

Alternatively I’m trying to load more than one image, would this be to do with image arrays? So the image changed and left a trail of new images on a loop.

I’m not sure if I have explained this well but I have attached my code. Any help would be greatly appreciated! Thank you

import org.openkinect.freenect.*;
import org.openkinect.freenect2.*;
import org.openkinect.processing.*;
import org.openkinect.tests.*;
import org.openkinect.freenect.*;

import org.openkinect.processing.*;

// The kinect stuff is happening in another class
KinectTracker tracker;
Kinect kinect;

int[] paint_x = new int[10000];
int[] paint_y = new int[10000];
int index =0;
PImage art;



PImage bg;
int y;


void setup() {
  size(1450, 825);
   
 kinect = new Kinect(this);
  tracker = new KinectTracker();
  art = loadImage("Desktop/SECONDTRACKPROTOTYPE/artone.jpg");
   bg = loadImage("Desktop/SECONDTRACKPROTOTYPE/WhiteCanvas.jpg");
}

void draw() {
  background(bg);
  
  
  line (0, y, width, y);
  
  y ++;
  if (y>height) {
    y=0;
  }


  // Run the tracking analysis
  tracker.track();
  // Show the image
  //tracker.display();

  // Let's draw the raw location
  PVector v1 = tracker.getPos();
  fill(50, 100, 250, 200);
  noStroke();
  ellipse(v1.x, v1.y, 20, 20);

  // Let's draw the "lerped" location
  PVector v2 = tracker.getLerpedPos();
  fill(50, 100, 250, 200);
  noStroke();
  ellipse(v2.x, v2.y, 100, 100);
  paint_x[index]=int(v2.x);
  paint_y[index]=int(v2.y);
  index ++;
  // Display some info
  int t = tracker.getThreshold();
  fill(0);
  
    
    for(int i=0;i<paint_x.length; i++){
      image (art, paint_x[i], paint_y[i]);
    }
}

// Adjust the threshold with key presses
void keyPressed() {
  int t = tracker.getThreshold();
  if (key == CODED) {
    if (keyCode == UP) {
      t+=5;
      tracker.setThreshold(t);
    } else if (keyCode == DOWN) {
      t-=5;
      tracker.setThreshold(t);
    }
  }
}
1 Like

i try to get the idea, ignoring the code,

do you want to use a animated GIF in processing?

String infile = "hit-the-fan.gif";
PImage img;

void setup() {
  img = loadImage(infile);
}

void draw() {
  image(img, 0, 0);
}

the animation will not show.

please ignore that if i understand you wrong.

1 Like