Created
May 18, 2012 21:39
-
-
Save xraymemory/2727748 to your computer and use it in GitHub Desktop.
Strange timing bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hypermedia.video.*; | |
import java.awt.Rectangle; | |
int MAXFACES = 500; | |
int DX, DY, DW, DH; | |
int TX, TY, TW, TH; | |
int numberOfFacesCaptured = 0; | |
int faceLengthFlag = 0; | |
int cueFlag = 0; | |
int sleepCount = 5000; | |
OpenCV opencv; | |
public void setup() { | |
size(640, 480); | |
// THESE ARE THE OFFSETS CAUSED BY THE ROI | |
// CHANGE THESE ACCORDING TO THE PARAMS | |
// YOU WANT FOR THE ROI CALL | |
DX = width / 4; | |
DY = 50; | |
DW = 300; | |
DH = 300; | |
// coordinates for the text box | |
TX = 150; | |
TY = 400; | |
TW = 300; | |
TH = 100; | |
cueFlag = 0; | |
background(0, 0, 0); | |
/* | |
opencv = new OpenCV(this); | |
opencv.capture(width, height); // open video stream | |
// may need to change this depending on where you have OpenCV installed | |
opencv.cascade("/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"); | |
*/ | |
} | |
public void placeSquare() { | |
stroke(100, 100, 100); | |
fill(100, 100, 100); | |
rect(TX, TY, TW, TH); | |
} | |
public void draw() { | |
if (cueFlag == 0) { | |
opencv = new OpenCV(this); | |
opencv.capture(width, height); // open video stream | |
// may need to change this depending on where you have OpenCV installed | |
opencv.cascade("/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"); | |
} | |
cueFlag = 1; | |
opencv.read(); | |
opencv.ROI(DX, DY, DW, DH); | |
//initialScreen(); | |
// rect(TX, TY, TW, TH); | |
// countdownScreen(); | |
rect(DX, DY, DW, DH); | |
Rectangle[] faces = opencv.detect((float) (1.2), 6, | |
OpenCV.HAAR_DO_CANNY_PRUNING, 100, 100); | |
if (faces.length == 0) { | |
faceLengthFlag = 0; | |
} | |
image(opencv.image().get(DX, DY, DW, DH), DX, DY); | |
if (faces.length > 0) { | |
placeSquare(); | |
long start = System.currentTimeMillis(); | |
while (abs (start - System.currentTimeMillis ()) < 3000) { | |
// wait so the person can get their face centered | |
} | |
opencv.stop(); | |
cueFlag = 0; | |
} | |
noFill(); | |
stroke(0, 0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment