Play / Pause Webcam
in
Core Library Questions
•
1 year ago
Hello,
when starting my script I want to capture an image from my webcam.
When pressing my mouse I want the image to be "freezed". When clicking the mouse again it should play again.
Right now it starts playing, but as soon as I stopped the capturing for the first time it doesn't play again.
- import processing.video.*;
- Capture myCapture;
- boolean photo = true;
- void setup()
- {
- size(screen.width, screen.height);
- myCapture = new Capture(this, width, height, 30);
- }
- void captureEvent(Capture myCapture) {
- myCapture.read();
- }
- void draw() {
- image(myCapture, 0, 0);
- filter(GRAY);
- }
- void mouseReleased() {
- if (photo == true) {
- myCapture.stop();
- photo = false;
- }
- else if (photo == false) {
- myCapture.read();
- photo=true;
- }
- }
1