Skip to content

Commit b90a70d

Browse files
Wu-cheng LiAndroid (Google) Code Review
authored andcommitted
Merge "Improve camera face detection javadoc." into ics-mr1
2 parents 4b7494e + 8c13670 commit b90a70d

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

core/java/android/hardware/Camera.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,21 @@ public final void setFaceDetectionListener(FaceDetectionListener listener)
11111111
* Parameters#getMaxNumDetectedFaces()} returns a number larger than 0.
11121112
* If the face detection has started, apps should not call this again.
11131113
*
1114-
* When the face detection is running, {@link Parameters#setWhiteBalance(String)},
1114+
* <p>When the face detection is running, {@link Parameters#setWhiteBalance(String)},
11151115
* {@link Parameters#setFocusAreas(List)}, and {@link Parameters#setMeteringAreas(List)}
1116-
* have no effect.
1116+
* have no effect. The camera uses the detected faces to do auto-white balance,
1117+
* auto exposure, and autofocus.
1118+
*
1119+
* <p>If the apps call {@link #autoFocus(AutoFocusCallback)}, the camera
1120+
* will stop sending face callbacks. The last face callback indicates the
1121+
* areas used to do autofocus. After focus completes, face detection will
1122+
* resume sending face callbacks. If the apps call {@link
1123+
* #cancelAutoFocus()}, the face callbacks will also resume.</p>
1124+
*
1125+
* <p>After calling {@link #takePicture(Camera.ShutterCallback, Camera.PictureCallback,
1126+
* Camera.PictureCallback)} or {@link #stopPreview()}, and then resuming
1127+
* preview with {@link #startPreview()}, the apps should call this method
1128+
* again to resume face detection.</p>
11171129
*
11181130
* @throws IllegalArgumentException if the face detection is unsupported.
11191131
* @throws RuntimeException if the method fails or the face detection is
@@ -1163,14 +1175,31 @@ public Face() {
11631175
* camera field of view, and (1000, 1000) represents the bottom-right of
11641176
* the field of view. For example, suppose the size of the viewfinder UI
11651177
* is 800x480. The rect passed from the driver is (-1000, -1000, 0, 0).
1166-
* The corresponding viewfinder rect should be (0, 0, 400, 240). The
1167-
* width and height of the rect will not be 0 or negative. The
1168-
* coordinates can be smaller than -1000 or bigger than 1000. But at
1169-
* least one vertex will be within (-1000, -1000) and (1000, 1000).
1178+
* The corresponding viewfinder rect should be (0, 0, 400, 240). It is
1179+
* guaranteed left < right and top < bottom. The coordinates can be
1180+
* smaller than -1000 or bigger than 1000. But at least one vertex will
1181+
* be within (-1000, -1000) and (1000, 1000).
11701182
*
11711183
* <p>The direction is relative to the sensor orientation, that is, what
11721184
* the sensor sees. The direction is not affected by the rotation or
1173-
* mirroring of {@link #setDisplayOrientation(int)}.</p>
1185+
* mirroring of {@link #setDisplayOrientation(int)}. The face bounding
1186+
* rectangle does not provide any information about face orientation.</p>
1187+
*
1188+
* <p>Here is the matrix to convert driver coordinates to View coordinates
1189+
* in pixels.</p>
1190+
* <pre>
1191+
* Matrix matrix = new Matrix();
1192+
* CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
1193+
* // Need mirror for front camera.
1194+
* boolean mirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
1195+
* matrix.setScale(mirror ? -1 : 1, 1);
1196+
* // This is the value for android.hardware.Camera.setDisplayOrientation.
1197+
* matrix.postRotate(displayOrientation);
1198+
* // Camera driver coordinates range from (-1000, -1000) to (1000, 1000).
1199+
* // UI coordinates range from (0, 0) to (width, height).
1200+
* matrix.postScale(view.getWidth() / 2000f, view.getHeight() / 2000f);
1201+
* matrix.postTranslate(view.getWidth() / 2f, view.getHeight() / 2f);
1202+
* </pre>
11741203
*
11751204
* @see #startFaceDetection()
11761205
*/

0 commit comments

Comments
 (0)