We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to create a flashlight effect using an actual flashlight. I'm trying to use the brightness values of a webcam feed to create a mask that cuts out parts of another video. For exampe, the white pixels should cut out everything of the other video, and the black pixels should cut out nothing. The values in between should be mapped.
This should create a flashlight effect, that reveals an underlying video, using an actual flashlight in front of the webcam.
Using blendMode(MULTIPLY) creates exactly the effect I want, only that I want the black areas around the light to display an animation/video.
tl;dr: I want to use a video feed as a mask that only affects one other video.
Answers
You can use mask() or a shader. For the first, see the reference. For the second, see the examples that come with Processing (Topics\Shaders\ImageMask). Whether it's a static image, a video or a webcam feed is irrelevant, because in effect these are all 'an image'.
http://forum.processing.org/two/discussion/8599/webcam-feed-as-alpha-mask
I'm trying to use mask() , but I can't get it to work. I am very new to processing, so don't really know what to do to make it work. Here is my code:
import processing.video.*;
Capture cam;
PImage video, maskImage; PImage photo;
void setup() { size(640, 480); background(255, 0, 0);
cam = new Capture(this, 640, 480); cam.start();
photo = loadImage("https://backgroundss.files.wordpress.com/2013/08/spiral-rainbow-background.jpg"); // maskImage = loadImage("mask.jpg"); video.mask(cam);
}
void draw() { if(cam.available()) { cam.read(); }
image(cam, 0, 0);
}
I would be grateful for any help.
Processing forum rules and advices
Format your code.
Apparently, video isn't initialized. AFAIK (I don't have a webcam), you can treat cam like a PImage, no need for an extra variable.
Have you got further with this? I'm trying to do something similar.
tks