0

I have been trying to launch face detection on Google Glass. It is supposed to run realtime as I want to trigger a custom method if there are faces on camera sight. Unfortunately it always detects zero faces. I want to start the detection as soon as my application starts, therefore I start face recognition on surface creation:

@Override
public void surfaceCreated(SurfaceHolder holder) {
    camera = Camera.open();
    this.setCameraParameters(camera);
    try {
        camera.setPreviewDisplay(this.getHolder());
    } catch (IOException e1) {
        Log.e("surface created", e1.getMessage());
    }
    camera.startPreview();
    try {
        camera.setPreviewDisplay(holder);
        CameraManager manager = new CameraManager(this, camera);
        manager.startFaceRecognition();
    } catch (Exception e) {
        this.releaseCamera();
    }
}

The implementation of manager.startFaceRecognition:

public void startFaceRecognition() {
    ...
    camera.setFaceDetectionListener(new FaceDetectionTriggeringListener());
}

It is the same camera object as I pass it to constructor. The implementation of face detection listener:

public class FaceDetectionTriggeringListener implements FaceDetectionListener {

    @Override
    public void onFaceDetection(Face[] faces, Camera camera) {
        if (faces.length > 0) {
            Log.d("onFaceDetection", Integer.toString(faces.length));
        }
        for (Face face : faces) {
            Log.d("onFaceDetection", Integer.toString(face.score));
        }
    }
}

In the last code part faces.length is always zero and nothing is logged. I have tried logging faces.length, it really outputs zero. I have tried different faces including my project manager and pictures from google searches. Please note that I want to do this in realtime and I do not need ultimate accuracy. I have tried methods that include picture transcoding, but they are too slow and uses too much CPU and, as a consequence, this gets Glass hot and drains battery heavily. The goal is to write something like this:

if (faces.length > 0){
    Foo.bar();
}

Is there any solution to this problem? Alternative solutions are accepted in case they can work in realtime.

Karolis Ryselis
  • 679
  • 4
  • 15
  • Be aware that Google forbis face recognition in its policies: [Google Policies](https://developers.google.com/glass/policies#c_what_you_cant_do_in_your_glassware) – Manuel Allenspach Mar 31 '14 at 10:38
  • @Manu, I suppose that face recognition and face detection are different things. I am aware of the Google policies, thank you for pointing it out. Google's Android API offers face detection and I would like to use it. – Karolis Ryselis Mar 31 '14 at 10:45
  • Oh, I misunderstood your question. You are right, face detection is a whole other thing :) – Manuel Allenspach Mar 31 '14 at 10:46

0 Answers0