10 Oct 2012, 23:01
Generic-user-small

Timon Shovel (1 post)

This sketch works for live facerecognition using the webcam (on a ridiculously cheap chinese android 4.0.3. tablet (Cherry M-1013)) using Processing 2.0b3 and Ketai v7.

I just wanted to say how incredibly awesome it is to be able to use a 110 euro tablet as a basis for playing with facedetection. So much respect to you guys (and the Processing people).

We’re going to be playing with it at http://www.setup.nl/content/face-detection-playground

and perhaps utimately for this idea: http://www.setup.nl/content/exploring-tablets-art-frames


  /**
 * <p>Ketai Sensor Library for Android: http://KetaiProject.org</p>
 *
 * <p>Ketai Camera Features:
 * <ul>
 * <li>Interface for built-in camera</li>
 * <li>Face detection in live camera stream</li>
 * </ul>
 * <p>Updated: 2012-03-10 Daniel Sauter/j.duran</p>
 * <p>Updated: 2012-okt-10 Tijmen Schep/Jelle van der Ster</p>
 */

import ketai.camera.*;
import ketai.cv.facedetector.*;


KetaiCamera cam;

int MAX_FACES = 20;
KetaiSimpleFace[] faces = new KetaiSimpleFace[MAX_FACES];

void setup() {
  frameRate(15);
  orientation(LANDSCAPE);
  //imageMode(CENTER);
  
  // resolution and then framerate:
  cam = new KetaiCamera(this, 320, 240, 15);  
}

void draw() {
  background(0);
  image(cam, 0, 0, 320, 240);
  
  faces = KetaiFaceDetector.findFaces(cam, MAX_FACES);
  
   for (int i=0; i < faces.length; i++)
  {
    //We only get the distance between the eyes so we base our bounding box off of that 
    rect(faces[i].location.x, faces[i].location.y, faces[i].distance, faces[i].distance);
  }
}

void onPause()
{
  super.onPause();
  //Make sure to releae the camera when we go
  //  to sleep otherwise it stays locked
  if (cam != null && cam.isStarted())
    cam.stop();
}

void onCameraPreviewEvent()
{
  cam.read();
}

void exit() {
  cam.stop();
}

// start/stop camera preview by tapping the screen
void mousePressed()
{
  if (cam.isStarted())
  {
    cam.stop();
  }
  else
    //cam.setCameraID(1);// changes the camera to the frontfacing one.
    cam.start();
}
void keyPressed() {
  if (key == CODED) {
    if (keyCode == MENU) {
      if (cam.isFlashEnabled())
        cam.disableFlash();
      else
        cam.enableFlash();
    }
  }
}
16 Oct 2012, 10:58
Ds_2009_mpark_pragsmall

Daniel Sauter (46 posts)

Hi Timon,

thanks for letting us know. In a diverse (or fragmented) device market, glad to hear it works on lower-end devices as well.

Best, Daniel

  You must be logged in to comment