Skip to content

Instantly share code, notes, and snippets.

@resophonic
Created February 27, 2012 17:08
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 resophonic/1925490 to your computer and use it in GitHub Desktop.
Save resophonic/1925490 to your computer and use it in GitHub Desktop.
antarctica_pyramids_v1
import hypermedia.video.*;
import java.awt.Rectangle;
float fI;
float fO;
float fOrvs;
OpenCV opencv;
// contrast/brightness values
int circlesize;
int contrast_value = 0;
int brightness_value = 0;
void setup() {
size(750, 500);
background(255);
opencv = new OpenCV(this); //start opencv
opencv.capture(width, height); // open capture stream
opencv.cascade(OpenCV.CASCADE_PROFILEFACE); //profile face detection
smooth();
frameRate(30);
}
public void stop() {
opencv.stop();
super.stop();
}
void draw() {
opencv.read(); // grab a new frame
opencv.convert(GRAY); //grayscale
opencv.contrast(contrast_value);
opencv.brightness(brightness_value);
opencv.flip(OpenCV.FLIP_HORIZONTAL);
// detection
Rectangle[] faces = opencv.detect(1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40);
//image( opencv.image(), 0, 0 ); <- show video
//draw circles
for(int i=0; i<faces.length; i++) {
background(255);
fI = faces[i].x;
fO = faces[i].y;
fOrvs = faces[i].y*-1;
//delay(250);
noStroke();
PFont f;
f = loadFont("FuturaLT-BoldOblique-20.vlw");
textFont(f);
fill(0);
textAlign(CENTER);
String s = (":THERE TWO TYPES OF PEOPLE:\n:THEY WHO SEE SIGNS:\n:THEY WHO ARE LUCKY:");
text(s, faces[i].width, faces[i].height);
}
//distance change
if(keyPressed && (key==CODED)) {
if(keyCode == SHIFT) {
background(255);
}
}
}
//brightness/contrast
void mouseDragged() {
contrast_value = (int) map(mouseX, 0, width, -128, 12);
brightness_value = (int) map(mouseY, 0, width, -128, 128);
}
//data value x/y
void mousePressed() {
noStroke();
PFont f;
f = loadFont("HelveticaNeueLT-UltraLight-20.vlw");
textFont(f);
fill(fO,fI,fO);
textAlign(CENTER);
text(fI/fO,mouseX,mouseY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment