Updated video examples to reflect new library and class names

This commit is contained in:
codeanticode
2011-08-18 22:32:09 +00:00
parent 88deee7566
commit 57ad715fcf
23 changed files with 210 additions and 214 deletions

View File

@@ -9,10 +9,9 @@
* See the keyPressed function for more options, like changing the font size.
*/
import processing.opengl.*;
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
boolean cheatScreen;
// All ASCII characters, sorted according to their visual density
@@ -34,7 +33,7 @@ public void setup() {
//size(screen.width, screen.height, OPENGL);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
int count = video.width * video.height;
println(count);
@@ -61,7 +60,7 @@ public void setup() {
}
public void captureEvent(GSCapture c) {
public void captureEvent(Capture c) {
c.read();
}

View File

@@ -9,17 +9,17 @@
*/
import codeanticode.gsvideo.*;
import processing.video.*;
int numPixels;
int[] backgroundPixels;
GSCapture video;
Capture video;
void setup() {
// Change size to 320 x 240 if too slow at 640 x 480
size(640, 480);
video = new GSCapture(this, width, height);
video = new Capture(this, width, height);
video.start();
numPixels = video.width * video.height;
// Create array to store the background image

View File

@@ -9,18 +9,18 @@
*/
import codeanticode.gsvideo.*;
import processing.video.*;
color black = color(0);
color white = color(255);
int numPixels;
GSCapture video;
Capture video;
void setup() {
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
strokeWeight(5);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, width, height);
video = new Capture(this, width, height);
video.start();
numPixels = video.width * video.height;
noCursor();

View File

@@ -8,14 +8,14 @@
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
void setup() {
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, width, height);
video = new Capture(this, width, height);
video.start();
noStroke();
smooth();

View File

@@ -9,9 +9,9 @@
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
boolean cheatScreen;
Tuple[] captureColors;
@@ -27,7 +27,7 @@ public void setup() {
noCursor();
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
int count = (video.width * video.height) / (increment * increment);

View File

@@ -8,10 +8,9 @@
* and arranges them into vertical bars.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
boolean cheatScreen;
Tuple[] captureColors;
@@ -27,7 +26,7 @@ public void setup() {
noCursor();
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
int count = (video.width * video.height) / (increment * increment);

View File

@@ -8,16 +8,16 @@
*/
import codeanticode.gsvideo.*;
import processing.video.*;
int numPixels;
int[] previousFrame;
GSCapture video;
Capture video;
void setup() {
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, width, height);
video = new Capture(this, width, height);
video.start();
numPixels = video.width * video.height;
// Create an array to store the previously captured frame

View File

@@ -8,9 +8,9 @@
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
int column;
int columnCount;
int lastRow;
@@ -23,7 +23,7 @@ void setup() {
size(640, 480, P3D);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
// Also try with other video sizes

View File

@@ -5,16 +5,16 @@
*
* Reading and displaying an image from an attached Capture device.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture cam;
Capture cam;
void setup() {
size(640, 480);
/*
// List functionality still not ready on Linux
String[] cameras = GSCapture.list();
String[] cameras = Capture.list();
if (cameras.length == 0)
{
@@ -24,16 +24,16 @@ void setup() {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++)
println(cameras[i]);
cam = new GSCapture(this, 640, 480, cameras[0]);
cam = new Capture(this, 640, 480, cameras[0]);
}
However, different cameras can be selected by using their device file:
cam = new GSCapture(this, 640, 480, "/dev/video0");
cam = new GSCapture(this, 640, 480, "/dev/video1");
cam = new Capture(this, 640, 480, "/dev/video0");
cam = new Capture(this, 640, 480, "/dev/video1");
etc.
*/
cam = new GSCapture(this, 640, 480);
cam = new Capture(this, 640, 480);
cam.start();
/*

View File

@@ -5,9 +5,9 @@
*
* Reading and displaying an image from an attached Capture device.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture cam;
Capture cam;
void setup() {
size(640, 480);
@@ -15,7 +15,7 @@ void setup() {
/*
// List functionality hasn't been tested on Mac OSX. Uncomment this
// code to try it out.
String[] cameras = GSCapture.list();
String[] cameras = Capture.list();
if (cameras.length == 0)
{
@@ -25,10 +25,10 @@ void setup() {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++)
println(cameras[i]);
cam = new GSCapture(this, 320, 240, cameras[0]);
cam = new Capture(this, 320, 240, cameras[0]);
}
*/
cam = new GSCapture(this, 640, 480);
cam = new Capture(this, 640, 480);
cam.start();
/*

View File

@@ -5,14 +5,14 @@
*
* Reading and displaying an image from an attached Capture device.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture cam;
Capture cam;
void setup() {
size(640, 480);
String[] cameras = GSCapture.list();
String[] cameras = Capture.list();
if (cameras.length == 0)
{
@@ -23,7 +23,7 @@ void setup() {
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
cam = new GSCapture(this, 640, 480, cameras[0]);
cam = new Capture(this, 640, 480, cameras[0]);
cam.start();
/*

View File

@@ -6,11 +6,11 @@
*
* Arrange the pixels from live video into the HSV Color Cone.
*/
import processing.opengl.*;
import codeanticode.gsvideo.*;
import processing.video.*;
import java.awt.Color;
GSCapture video;
Capture video;
int count;
boolean cheatScreen = true;
@@ -40,7 +40,7 @@ public void setup() {
size(640, 480, P3D);
//size(screen.width, screen.height, OPENGL);
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
count = video.width * video.height;
@@ -133,7 +133,7 @@ void draw() {
}
void captureEvent(GSCapture c) {
void captureEvent(Capture c) {
c.read();
c.loadPixels();
}

View File

@@ -7,9 +7,9 @@
* Unwrap each frame of live video into a single line of pixels.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
int count;
int writeRow;
int maxRows;
@@ -21,7 +21,7 @@ void setup() {
size(600, 400);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
maxRows = height * 2;
@@ -44,7 +44,7 @@ void draw() {
}
void captureEvent(GSCapture c) {
void captureEvent(Capture c) {
c.read();
c.loadPixels();
arraycopy(c.pixels, 0, buffer, writeRow * width, width);

View File

@@ -7,7 +7,7 @@
* Each pixel from the video source is drawn as a rectangle with rotation based on brightness.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
// Size of each cell in the grid
@@ -15,7 +15,7 @@ int cellSize = 20;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
GSCapture video;
Capture video;
void setup() {
@@ -26,7 +26,7 @@ void setup() {
colorMode(RGB, 255, 255, 255, 100);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, width, height);
video = new Capture(this, width, height);
video.start();
background(0);

View File

@@ -7,14 +7,14 @@
* Each pixel from the video source is drawn as a rectangle with size based on brightness.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
// Size of each cell in the grid
int cellSize = 15;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
GSCapture video;
Capture video;
void setup() {
@@ -26,7 +26,7 @@ void setup() {
rectMode(CENTER);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, width, height);
video = new Capture(this, width, height);
video.start();
background(0);

View File

@@ -7,10 +7,9 @@
* Unwrap each frame of live video into a single line of pixels along a circle
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
int videoCount;
int currentAngle;
int pixelCount;
@@ -25,7 +24,7 @@ void setup() {
size(600, 600);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 160, 120);
video = new Capture(this, 160, 120);
video.start();
videoCount = video.width * video.height;

View File

@@ -12,19 +12,18 @@
* Created December 2006.
* Updated June 2007 by fry.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSCapture video;
Capture video;
int videoSliceX;
int drawPositionX;
void setup() {
size(600, 240);
// Uses the default video input, see the reference if this causes an error
video = new GSCapture(this, 320, 240);
video = new Capture(this, 320, 240);
video.start();
videoSliceX = video.width / 2;

View File

@@ -6,9 +6,9 @@
* arrow keys.
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSMovie movie;
Movie movie;
int newFrame = 0;
PFont font;
@@ -19,14 +19,14 @@ void setup() {
// 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.
movie = new GSMovie(this, "station.mov");
movie = new Movie(this, "station.mov");
movie.play();
font = loadFont("DejaVuSans-24.vlw");
textFont(font, 24);
}
void movieEvent(GSMovie movie) {
void movieEvent(Movie movie) {
movie.read();
}

View File

@@ -1,37 +1,37 @@
/**
* Loop.
* Built-in video library replaced with gsvideo by Andres Colubri
*
* Move the cursor across the screen to draw.
* Shows how to load and play a QuickTime movie file.
*
* Note: GSVideo uses GStreamer as the underlying multimedia library
* for reading media files, decoding, encoding, etc.
* It is based on a set of Java bindings for GStreamer called
* gstreamer-java originally created by Wayne Meissner and currently
* mantained by a small team of volunteers. GStreamer-java can be
* used from any Java program, and it is available for download at
* the following website:
* http://code.google.com/p/gstreamer-java/
*/
import codeanticode.gsvideo.*;
GSMovie movie;
void setup() {
size(640, 480);
background(0);
// Load and play the video in a loop
movie = new GSMovie(this, "station.mov");
movie.loop();
}
void movieEvent(GSMovie movie) {
movie.read();
}
void draw() {
tint(255, 20);
image(movie, mouseX-movie.width/2, mouseY-movie.height/2);
}
/**
* Loop.
* Built-in video library replaced with gsvideo by Andres Colubri
*
* Move the cursor across the screen to draw.
* Shows how to load and play a QuickTime movie file.
*
* Note: GSVideo uses GStreamer as the underlying multimedia library
* for reading media files, decoding, encoding, etc.
* It is based on a set of Java bindings for GStreamer called
* gstreamer-java originally created by Wayne Meissner and currently
* mantained by a small team of volunteers. GStreamer-java can be
* used from any Java program, and it is available for download at
* the following website:
* http://code.google.com/p/gstreamer-java/
*/
import processing.video.*;
Movie movie;
void setup() {
size(640, 480);
background(0);
// Load and play the video in a loop
movie = new Movie(this, "station.mov");
movie.loop();
}
void movieEvent(Movie movie) {
movie.read();
}
void draw() {
tint(255, 20);
image(movie, mouseX-movie.width/2, mouseY-movie.height/2);
}

View File

@@ -1,50 +1,50 @@
/**
* Pixelate
* by Hernando Barragan.
* Built-in video library replaced with gsvideo by Andres Colubri
*
* 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 codeanticode.gsvideo.*;
int numPixels;
int blockSize = 10;
GSMovie myMovie;
color myMovieColors[];
void setup() {
size(640, 480);
noStroke();
background(0);
myMovie = new GSMovie(this, "station.mov");
myMovie.loop();
numPixels = width / blockSize;
myMovieColors = new color[numPixels * numPixels];
}
// Read new values from movie
void movieEvent(GSMovie m) {
m.read();
m.loadPixels();
for (int j = 0; j < numPixels; j++) {
for (int i = 0; i < numPixels; i++) {
myMovieColors[j*numPixels + i] = m.get(i, j);
}
}
}
// Display values from movie
void draw() {
for (int j = 0; j < numPixels; j++) {
for (int i = 0; i < numPixels; i++) {
fill(myMovieColors[j*numPixels + i]);
rect(i*blockSize, j*blockSize, blockSize-1, blockSize-1);
}
}
}
/**
* Pixelate
* by Hernando Barragan.
* Built-in video library replaced with gsvideo by Andres Colubri
*
* 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 numPixels;
int blockSize = 10;
Movie myMovie;
color myMovieColors[];
void setup() {
size(640, 480);
noStroke();
background(0);
myMovie = new Movie(this, "station.mov");
myMovie.loop();
numPixels = width / blockSize;
myMovieColors = new color[numPixels * numPixels];
}
// Read new values from movie
void movieEvent(Movie m) {
m.read();
m.loadPixels();
for (int j = 0; j < numPixels; j++) {
for (int i = 0; i < numPixels; i++) {
myMovieColors[j*numPixels + i] = m.get(i, j);
}
}
}
// Display values from movie
void draw() {
for (int j = 0; j < numPixels; j++) {
for (int i = 0; i < numPixels; i++) {
fill(myMovieColors[j*numPixels + i]);
rect(i*blockSize, j*blockSize, blockSize-1, blockSize-1);
}
}
}

View File

@@ -13,19 +13,19 @@
*
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSMovie myMovie;
Movie myMovie;
boolean speedSet = false;
public void setup() {
size(320, 240);
background(0);
myMovie = new GSMovie(this, "balloon.ogg");
myMovie = new Movie(this, "balloon.ogg");
myMovie.play();
}
public void movieEvent(GSMovie myMovie) {
public void movieEvent(Movie myMovie) {
myMovie.read();
}

View File

@@ -1,49 +1,49 @@
/**
* Scratch.
* by Andres Colubri
*
* Move the cursor horizontally across the screen to set
* the position in the movie file.
*/
import codeanticode.gsvideo.*;
GSMovie movie;
void setup() {
size(640, 480);
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.
movie = new GSMovie(this, "station.mov");
movie.play();
}
void movieEvent(GSMovie movie) {
movie.read();
}
void draw() {
// A new time position is calculated using the current mouse location:
float f = constrain((float)mouseX / width, 0, 1);
float t = movie.duration() * f;
// If the new time is different enough from the current position,
// then we jump to the new position. But how different? Here the
// difference has been set to 0.1 (1 tenth of a second), but it can
// be smaller. My guess is that the smallest value should correspond
// to the duration of a single frame (for instance 1/24 if the frame rate
// of the video file is 24fps). Setting even smaller values seem to lead
// to choppiness. This will become trickier once the GSMovie.speed()
// and GSMovie.frameRate() methods become functional.
if (0.1 < abs(t - movie.time())) {
// The movie stream must be in play mode in order to jump to another
// position along the stream. Otherwise it won't work.
movie.play();
movie.jump(t);
movie.pause();
}
image(movie, 0, 0, width, height);
}
/**
* Scratch.
* by Andres Colubri
*
* Move the cursor horizontally across the screen to set
* the position in the movie file.
*/
import processing.video.*;
Movie movie;
void setup() {
size(640, 480);
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.
movie = new Movie(this, "station.mov");
movie.play();
}
void movieEvent(Movie movie) {
movie.read();
}
void draw() {
// A new time position is calculated using the current mouse location:
float f = constrain((float)mouseX / width, 0, 1);
float t = movie.duration() * f;
// If the new time is different enough from the current position,
// then we jump to the new position. But how different? Here the
// difference has been set to 0.1 (1 tenth of a second), but it can
// be smaller. My guess is that the smallest value should correspond
// to the duration of a single frame (for instance 1/24 if the frame rate
// of the video file is 24fps). Setting even smaller values seem to lead
// to choppiness. This will become trickier once the Movie.speed()
// and Movie.frameRate() methods become functional.
if (0.1 < abs(t - movie.time())) {
// The movie stream must be in play mode in order to jump to another
// position along the stream. Otherwise it won't work.
movie.play();
movie.jump(t);
movie.pause();
}
image(movie, 0, 0, width, height);
}

View File

@@ -6,21 +6,21 @@
*
*/
import codeanticode.gsvideo.*;
import processing.video.*;
GSMovie movie;
Movie movie;
public void setup() {
size(320, 240);
background(0);
movie = new GSMovie(this, "balloon.ogg");
movie = new Movie(this, "balloon.ogg");
movie.loop();
PFont font = loadFont("DejaVuSans-24.vlw");
textFont(font, 24);
}
public void movieEvent(GSMovie movie) {
public void movieEvent(Movie movie) {
movie.read();
}