Skip to content

Instantly share code, notes, and snippets.

@todocono
Last active December 1, 2022 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todocono/ce62487bd2c6f2f743ac8c4661b6097d to your computer and use it in GitHub Desktop.
Save todocono/ce62487bd2c6f2f743ac8c4661b6097d to your computer and use it in GitHub Desktop.
import processing.video.*;
//String[] cameras = Capture.list();
Capture cam;
float alpha =0;
void setup() {
size(1280, 960);
//printArray(cameras);
cam = new Capture(this, "pipeline:autovideosrc"); // use if camera trouble: cam = new Capture(this, 640, 480, cameras[0],30);
cam.start();
rectMode(CENTER);
noStroke();
}
void draw() {
if (cam.available()) {
cam.read();
}
pushMatrix(); //top left
scale(-1, 1);
image(cam, -640, 0);
popMatrix();
tint(255, 0, 0);
image(cam, 640, 0); //top right
tint(255, 255, 255);
//image(cam, 0, 480); //bottom left
float sizeRect = map(mouseX, 0, width, 1, 100);
for (int x1=0; x1<cam.width; x1+=sizeRect) {
for (int y1=0; y1<cam.height; y1+=sizeRect) {
color c1 = get(x1, y1);
fill(c1);
rect(x1, y1+480, sizeRect, sizeRect);
}
}
//image(cam, 0, 480); //bottom left
float sizeCircle = map(mouseY, 0, height, 1, 100);
for (int i=0; i<100; i++) {
int x2 = floor(random(width));
int y2 = floor(random(height));
color c2 = get(x2, y2);
fill(c2);
circle(x2+640, y2+480, sizeCircle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment