Using Webcam for Animation?
in
Core Library Questions
•
1 year ago
Hello,
in my sketch I want to capture an image with my webcam (just one single image not an image capturing all the time).
After that I want to place an animation on top of it. So in the sketch below you should take a picture and then an ellipse moves over the screen and over the image.
My Problem: For an animation I think I need to call "background" all the time. When doing this my captured image from the webcam is gone, as the background lays over it. Is there any simple way to work around this problem?
This would be great!!
- import processing.video.*;
- boolean animation = false;
- int ellipseX = 0;
- Capture myCapture;
- void setup() {
- size (800, 600);
- smooth();
- noStroke();
- myCapture = new Capture(this, width/3, height/3, 30);
- ellipseMode(CENTER);
- }
- void draw() {
- if (animation) animation();
- }
- void foto() {
- image(myCapture, 0, 0, width, height);
- filter(GRAY);
- }
- void mouseReleased() {
- foto();
- animation = true;
- }
- void animation() {
- ellipseX +=5;
- if (ellipseX > width) {
- ellipseX = 0;
- }
- ellipse (ellipseX, 100, 20, 20);
- }
- void captureEvent(Capture myCapture) {
- myCapture.read();
- }
1