Finding eye position on camera using camera2 api android

424 Views Asked by At

Below are my code snippet to get faces on camera using camera2 api. In that I am able to get eye position only for few devices. Rest of them returning NULL values. Is there a way to find eye position in camera using camera2 api?

Integer mode = result.get(CaptureResult.STATISTICS_FACE_DETECT_MODE);

Face[] faces = result.get(CaptureResult.STATISTICS_FACES);
if(faces != null && mode != null) {
        if (faces.length > 0) {
            Rect rect = faces[0].getBounds();
            Log.e("tag", "faces : leftEye" + faces[0].getLeftEyePosition());
            Log.e("tag", "faces : RightEye" + faces[0].getRightEyePosition());
        }
 }
1

There are 1 best solutions below

0
San On

Face detection is a feature that needs to be supported by the underlying camera module and is not related with Android frameworks. Hence your code works in certain devices and fails in rest. I believe Android framework doesn't have any explicit API for Face Detection.