Hur man skapar en behandling kontrolleras webbkamera med Fotoeffekter & overlay (2 / 2 steg)
Steg 2: Slutförde webcam med Fotoöverlägg effekt och logotyp
kodning:
import processing.video.*;
int w = 640;
int h = 480;
int fps = 25;
int jag = 0;
PImage img;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img8;
PImage img9;
Fånga cam;
void setup()
{
storlek (screen.width, screen.height, P3D);
frameRate(fps);
cam = nya fånga (här, w, h);
}
void draw()
{
släpp blue moon logog här
om (cam.available() == true) {
cam.Read();
IMG = loadImage ("person-1.tif");
img2 = loadImage ("person-2.tif");
img3 = loadImage ("person-3.tif");
img4 = loadImage ("person-4.tif");
img5 = loadImage ("person-5.tif");
img6 = loadImage ("person-6.tif");
img7 = loadImage ("person-7.tif");
img8 = loadImage ("person-8.tif");
img9 = loadImage ("bluemoon_2.png");
}
bild (cam, bredd/3, höjd/3, bredd/3, höjd/3);
Tint(17);
noTint();
bild (img, 0, 0, bredd/3, höjd/3);
bild (img2, bredd/3, 0, bredd/3, höjd/3);
bild (img3, 2 * bredd/3, 0, bredd/3, höjd/3);
bild (img4, 0, 266, bredd/3, höjd/3);
bild (img5, 2 * bredd/3, 266, bredd/3, höjd/3);
bild (img6, 0, 532, bredd/3, höjd/3);
bild (img7, bredd/3, 532, bredd/3, höjd/3);
bild (img8, 2 * bredd/3, 532, bredd/3, höjd/3);
bild (img9, bredd/3, 266, bredd/3, höjd/3);
om (keyPressed == true) {
om (nyckel == "a") {
filter (oskärpa, 3);
filter (FÄRGREDUKTION, 12);
om (jag < 8) {
i ++;
}
annat jag = 1;
PImage img = få (bredd/3, höjd/3, bredd/3, höjd/3);
img.Save("person-"+i);
}
}
}