We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've written a program to process a webcam with a Luma key. For some reason saveFrame()
only saves the original video from the Webcam, instead of the processed video. How can I fix this?
import processing.video.*;
Capture cam;
void setup() {
fullScreen();
frameRate(5);
String[] cameras = Capture.list();
background(0);
cam = new Capture(this, cameras[0]);
cam.start();
}
void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0, width, height);
loadPixels();
for (int loc = 1; loc < pixels.length; loc++) {
float r = red(pixels[loc]);
float g = green(pixels[loc]);
float b = blue(pixels[loc]);
float preAlpha = (r+g+b)/3;
if (preAlpha < 70) {
preAlpha = 0;
}
float alpha = preAlpha/5;
pixels[loc] = color(r, g, b, alpha);
}
updatePixels();
}
void mousePressed() {
saveFrame();
}
Answers
https://processing.org/reference/mousePressed_.html
Try to use the boolean vatiable to start the record.
I only want saveframe to occur once, the problem is that it is saving the original video, not the processed video
It still isn't capturing the final image, just the input from the camera
Move the lines 7-10 of gotoloops code to the bottom of draw()
Still isn't fixing it, I can show an example of what I mean when I get home
Ok so I utilized PGraphics and now it works!