We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
DETECT CLOSING EYES (Read 1730 times)
DETECT CLOSING EYES
Aug 7th, 2009, 2:18am
 
Shocked My project :detect closing eyes.
I imported OPENCV library
I am using a Peter KIRN 's tutorials for detecting eyes. on the site createdigitalmotion
This works well within Processing
Now I would like find a method for detecting closing eyes:by HLS?detecting boards eyes?help Tongue
                       
import hypermedia.video.*;
OpenCV opencv;
// contrast/brightness values
int contrast_value    = 0;
int brightness_value  = 0;
void setup() {  
 size( 320, 240 );
 opencv = new OpenCV( this );
 opencv.capture( width, height );
                  // open video stream
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );
// load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"    opencv.cascade( "C:\\Program Files\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml" );
// print usage  
println( "Drag mouse on X-axis inside this sketch window to change contrast" );
println( "Drag mouse on Y-axis inside this sketch window to change brightness" );
}
public void stop() {  
  opencv.stop();
  super.stop();
}
void draw() {
  // grab a new frame  
  // and convert to gray
  opencv.cascade( "C:\\Program Files\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml" );
  opencv.read();
  opencv.convert( GRAY );
  opencv.contrast( contrast_value );
  opencv.brightness( brightness_value );
  // display the image  
  image( opencv.image(), 0, 0 );
  // draw face area(s)  
  noFill();
  stroke(255,0,0);
  // proceed face detection
  Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
  if ( faces.length > 0 ) {
    opencv.ROI( faces[0].x, faces[0].y+(faces[0].height/5), faces[0].width, faces[0].height/3 );
  opencv.cascade( "C:\\Program Files\\OpenCV\\data\\haarcascades\\haarcascade_eye.xml");
  Rectangle[] eyes = opencv.detect();
  opencv.ROI(null);
  for( int i=0; i<faces.length; i++ ) {
   rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
   }
   stroke(0,255,0);
   fill(0);
   for( int i=0; i<eyes.length; i++ ) {
   rect( eyes[i].x+faces[0].x, eyes[i].y+faces[0].y+(faces[0].height/5), eyes[i].width, eyes[i].height );
       }
}
delay(100);
}
/** * Changes contrast/brigthness values */
void mouseDragged() {  
 contrast_value   = (int) map( mouseX, 0, width, -128, 128 );
 brightness_value = (int) map( mouseY, 0, width, -128, 128 );
}
Re: DETECT CLOSING EYES
Reply #1 - Aug 10th, 2009, 2:28pm
 
you're using 2 cascades: one detects the face the other detects the eye.

the quickest way to do the job would be to:

1) look for faces
2) if a face is found look for eyes
3) if the eye is found store in a variable that eyes are open, else store that eyes are closed
Page Index Toggle Pages: 1