Udostępnij za pośrednictwem


Camera.Face.Rect Property

Definition

Caution

deprecated

Bounds of the face.

[Android.Runtime.Register("rect")]
[System.Obsolete("deprecated")]
public Android.Graphics.Rect? Rect { get; set; }
[<Android.Runtime.Register("rect")>]
[<System.Obsolete("deprecated")>]
member this.Rect : Android.Graphics.Rect with get, set

Property Value

Attributes

Remarks

Bounds of the face. (-1000, -1000) represents the top-left of the camera field of view, and (1000, 1000) represents the bottom-right of the field of view. For example, suppose the size of the viewfinder UI is 800x480. The rect passed from the driver is (-1000, -1000, 0, 0). The corresponding viewfinder rect should be (0, 0, 400, 240). It is guaranteed left < right and top < bottom. The coordinates can be smaller than -1000 or bigger than 1000. But at least one vertex will be within (-1000, -1000) and (1000, 1000).

The direction is relative to the sensor orientation, that is, what the sensor sees. The direction is not affected by the rotation or mirroring of #setDisplayOrientation(int). The face bounding rectangle does not provide any information about face orientation.

Here is the matrix to convert driver coordinates to View coordinates in pixels.

Matrix matrix = new Matrix();
            CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
            // Need mirror for front camera.
            boolean mirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
            matrix.setScale(mirror ? -1 : 1, 1);
            // This is the value for android.hardware.Camera.setDisplayOrientation.
            matrix.postRotate(displayOrientation);
            // Camera driver coordinates range from (-1000, -1000) to (1000, 1000).
            // UI coordinates range from (0, 0) to (width, height).
            matrix.postScale(view.getWidth() / 2000f, view.getHeight() / 2000f);
            matrix.postTranslate(view.getWidth() / 2f, view.getHeight() / 2f);

Java documentation for android.hardware.Camera.Face.rect.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also