We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Okay, so I'm going to try and explain this the best I can and hopefully someone can help me. I have a program that basically takes a screen shot of the program window and saves it into the data folder. It then loads that image capture onto the screen where ever I tell it to. The problem that I'm having is that it doesn't load in a new image when I take a second screen shot. The new image is put into the data folder, but it doesn't replace the image that's up already.
import processing.video.*;
Capture cam;
PImage capture;
void setup() {
//window size
size(1280, 720, P3D);
background (0);
noCursor();
//webcam feed
capture = loadImage ("capture.jpg");
imageMode (CENTER);
String[] cameras = Capture.list();
//webcam feed
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
cam = new Capture(this, cameras[0]);
cam.start();
}
}
void draw() {
if (cam.available() == true) {
cam.read();
}
//web cam feed position, size
image(cam, 640, 360, 320, 180);
}
void mousePressed() {
//image capture
saveFrame("data/capture.jpg");
cam.read();
//loads image capture in
image (capture, 200, 200, 480, 270);
image (capture, 1000, 500, 480, 270);
}
Answers
You shouldn't call read() before checking available() as you're doing in mousePressed().
https://forum.Processing.org/two/discussion/19311/webcam-capture-possible-to-crop-a-pimage