Calibrate works?

This commit is contained in:
jan 2016-07-10 00:36:44 -07:00
commit cc711c6343
1104 changed files with 636510 additions and 75 deletions

View file

@ -0,0 +1,77 @@
/**
* Frames
* by Andres Colubri.
*
* Moves through the video one frame at the time by using the
* arrow keys. It estimates the frame counts using the framerate
* of the movie file, so it might not be exact in some cases.
*/
import processing.video.*;
Movie mov;
int newFrame = 0;
void setup() {
size(640, 360);
background(0);
// Load and set the video to play. Setting the video
// in play mode is needed so at least one frame is read
// and we can get duration, size and other information from
// the video stream.
mov = new Movie(this, "transit.mov");
// Pausing the video at the first frame.
mov.play();
mov.jump(0);
mov.pause();
}
void movieEvent(Movie m) {
m.read();
}
void draw() {
background(0);
image(mov, 0, 0, width, height);
fill(255);
text(getFrame() + " / " + (getLength() - 1), 10, 30);
}
void keyPressed() {
if (key == CODED) {
if (keyCode == LEFT) {
if (0 < newFrame) newFrame--;
} else if (keyCode == RIGHT) {
if (newFrame < getLength() - 1) newFrame++;
}
}
setFrame(newFrame);
}
int getFrame() {
return ceil(mov.time() * 30) - 1;
}
void setFrame(int n) {
mov.play();
// The duration of a single frame:
float frameDuration = 1.0 / mov.frameRate;
// We move to the middle of the frame by adding 0.5:
float where = (n + 0.5) * frameDuration;
// Taking into account border effects:
float diff = mov.duration() - where;
if (diff < 0) {
where += diff - 0.25 * frameDuration;
}
mov.jump(where);
mov.pause();
}
int getLength() {
return int(mov.duration() * mov.frameRate);
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
/**
* Loop.
*
* Shows how to load and play a QuickTime movie file.
*
*/
import processing.video.*;
Movie movie;
void setup() {
size(640, 360);
background(0);
// Load and play the video in a loop
movie = new Movie(this, "transit.mov");
movie.loop();
}
void movieEvent(Movie m) {
m.read();
}
void draw() {
//if (movie.available() == true) {
// movie.read();
//}
image(movie, 0, 0, width, height);
}

Binary file not shown.

View file

@ -0,0 +1,51 @@
/**
* Pixelate
* by Hernando Barragan.
*
* Load a QuickTime file and display the video signal
* using rectangles as pixels by reading the values stored
* in the current video frame pixels array.
*/
import processing.video.*;
int numPixelsWide, numPixelsHigh;
int blockSize = 10;
Movie mov;
color movColors[];
void setup() {
size(640, 360);
noStroke();
mov = new Movie(this, "transit.mov");
mov.loop();
numPixelsWide = width / blockSize;
numPixelsHigh = height / blockSize;
println(numPixelsWide);
movColors = new color[numPixelsWide * numPixelsHigh];
}
// Display values from movie
void draw() {
if (mov.available() == true) {
mov.read();
mov.loadPixels();
int count = 0;
for (int j = 0; j < numPixelsHigh; j++) {
for (int i = 0; i < numPixelsWide; i++) {
movColors[count] = mov.get(i*blockSize, j*blockSize);
count++;
}
}
}
background(255);
for (int j = 0; j < numPixelsHigh; j++) {
for (int i = 0; i < numPixelsWide; i++) {
fill(movColors[j*numPixelsWide + i]);
rect(i*blockSize, j*blockSize, blockSize, blockSize);
}
}
}

Binary file not shown.

View file

@ -0,0 +1,48 @@
/**
* Reverse playback example.
*
* The Movie.speed() method allows to change the playback speed.
* Use negative values for backwards playback. Note that not all
* video formats support backwards playback. This depends on the
* underlying gstreamer plugins used by gsvideo. For example, the
* theora codec does support backward playback, but not so the H264
* codec, at least in its current version.
*
*/
import processing.video.*;
Movie mov;
boolean speedSet = false;
boolean once = true;
void setup() {
size(640, 360);
background(0);
mov = new Movie(this, "transit.mkv");
mov.play();
}
void movieEvent(Movie m) {
m.read();
if (speedSet == true) {
speedSet = false;
}
}
void draw() {
if (speedSet == false && once == true) {
// Setting the speed should be done only once,
// this is the reason for the if statement.
speedSet = true;
once = false;
mov.jump(mov.duration());
// -1 means backward playback at normal speed.
mov.speed(-1.0);
// Setting to play again, since the movie stop
// playback once it reached the end.
mov.play();
}
image(mov, 0, 0, width, height);
}

Binary file not shown.

View file

@ -0,0 +1,39 @@
/**
* Scratch
* by Andres Colubri.
*
* Move the cursor horizontally across the screen to set
* the position in the movie file.
*/
import processing.video.*;
Movie mov;
void setup() {
size(640, 360);
background(0);
mov = new Movie(this, "transit.mov");
// Pausing the video at the first frame.
mov.play();
mov.jump(0);
mov.pause();
}
void draw() {
if (mov.available()) {
mov.read();
// A new time position is calculated using the current mouse location:
float f = map(mouseX, 0, width, 0, 1);
float t = mov.duration() * f;
mov.play();
mov.jump(t);
mov.pause();
}
image(mov, 0, 0);
}

Binary file not shown.

View file

@ -0,0 +1,33 @@
/**
* Speed.
*
* Use the Movie.speed() method to change
* the playback speed.
*
*/
import processing.video.*;
Movie mov;
void setup() {
size(640, 360);
background(0);
mov = new Movie(this, "transit.mov");
mov.loop();
}
void movieEvent(Movie movie) {
mov.read();
}
void draw() {
image(mov, 0, 0);
float newSpeed = map(mouseX, 0, width, 0.1, 2);
mov.speed(newSpeed);
fill(255);
text(nfc(newSpeed, 2) + "X", 10, 30);
}

Binary file not shown.