hi
i recently start to learn processing and i want to play "Brightness Thresholding" ,which is in the example-video, with a video i've already recorded at the same time. i don't know how to combine these two codes. can anyone help me?
code:
Brightness Thresholding
import processing.video.*;
color black = color(0);
color white = color(255);
int numPixels;
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 Capture(this, width, height, 24);
numPixels = video.width * video.height;
noCursor();
smooth();
}
void draw() {
if (video.available()) {
video.read();
video.loadPixels();
int threshold = 127; // Set the threshold value
float pixelBrightness; // Declare variable to store a pixel's color
// Turn each pixel in the video frame black or white depending on its brightness
loadPixels();
for (int i = 0; i < numPixels; i++) {
pixelBrightness = brightness(video.pixels[i]);
if (pixelBrightness > threshold) { // If the pixel is brighter than the
pixels[i] = white; // threshold value, make it white
}
else { // Otherwise,
pixels[i] = black; // make it black
}
}
updatePixels();
// Test a location to see where it is contained. Fetch the pixel at the test
// location (the cursor), and compute its brightness
int testValue = get(mouseX, mouseY);
float testBrightness = brightness(testValue);
if (testBrightness > threshold) { // If the test location is brighter than
fill(black); // the threshold set the fill to black
}
else { // Otherwise,
fill(white); // set the fill to white
}
ellipse(mouseX, mouseY, 20, 20);
}
}
code:
video
import processing.video.*;
AppletLayers layers;
Movie theMov;
void setup() {
size(1080, 1080);
layers = new AppletLayers(this);
theMov = new Movie(this, "ScreenFlow.mov");
/* only use 1 of the following options */
theMov.play(); //plays the movie once
theMov.loop(); //plays the movie over and over
}