Android ICS API 14 - face recognition using the camera.

An attempt to use Android 4 API 14 face recognition was found in the Camera.Face class.

It’s hard for me to get the values ​​for the coordinates of the face [Left / Right Eye, Mouth].

Im device using Samsung Galaxy Tab 2 [GT-P5100] with Android 4.0.4

I initialize face recognition somewhat like below the code snippet and the value of the camera.getParameters () parameter. getMaxNumDetectedFaces () returns as 3 when running on the above device.

Now, when a face is inserted into the surface frame and detected in the face detection listener, it returns back the values ​​in the [0] .rect.flattenToString () face that determine the position of the face on the surface. However, the remaining values, that is, the face name, left / right eye and mouth, are returned as -1 and zero, respectively.

This behavior is described in the documentation as

This optional field may not be supported on all devices. If not supported, the value will always be null. Additional fields are supported as a set. All of them are valid, or none of them is.

So the question is, am I missing something, or simply because my device cannot support face recognition api in Android, as shown in Camera.Face?

It is worth mentioning that the same device prompts the user to log into a system that is configured through user settings.

FaceDetectionListener faceDetectionListener = new FaceDetectionListener(){ @Override public void onFaceDetection(Face[] faces, Camera camera) { if (faces.length == 0){ prompt.setText(" No Face Detected! "); }else{ prompt.setText(String.valueOf(faces.length) + " Face Detected :) [ " + faces[0].rect.flattenToString() + "Coordinates : Left Eye - " + faces[0].leftEye + "]" ) ; Log.i("TEST", "face coordinates = Rect :" + faces[0].rect.flattenToString()); Log.i("TEST", "face coordinates = Left eye : " + String.valueOf(faces[0].leftEye)); Log.i("TEST", "face coordinates = Right eye - " + String.valueOf(faces[0].rightEye)); Log.i("TEST", "face coordinates = Mouth - " + String.valueOf(faces[0].mouth)); } 

.....

  if (camera != null){ try { camera.setPreviewDisplay(surfaceHolder); camera.startPreview(); prompt.setText(String.valueOf( "Max Face: " + camera.getParameters().getMaxNumDetectedFaces())); camera.startFaceDetection(); previewing = true; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 
+6
source share
1 answer

In the initialization code, you need to install a face recognition listener for the camera.

+1
source

Source: https://habr.com/ru/post/924615/


All Articles