Search in sources :

Example 1 with WeightedRectangle

use of android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle in project platform_frameworks_base by android.

the class ParameterUtils method convertFaceFromLegacy.

/**
     * Convert an api1 face into an active-array based api2 face.
     *
     * <p>Out-of-ranges scores and ids will be clipped to be within range (with a warning).</p>
     *
     * @param face a non-{@code null} api1 face
     * @param activeArraySize active array size of the sensor (e.g. max jpeg size)
     * @param zoomData the calculated zoom data corresponding to this request
     *
     * @return a non-{@code null} api2 face
     *
     * @throws NullPointerException if the {@code face} was {@code null}
     */
public static Face convertFaceFromLegacy(Camera.Face face, Rect activeArray, ZoomData zoomData) {
    checkNotNull(face, "face must not be null");
    Face api2Face;
    Camera.Area fakeArea = new Camera.Area(face.rect, /*weight*/
    1);
    WeightedRectangle faceRect = convertCameraAreaToActiveArrayRectangle(activeArray, zoomData, fakeArea);
    Point leftEye = face.leftEye, rightEye = face.rightEye, mouth = face.mouth;
    if (leftEye != null && rightEye != null && mouth != null && leftEye.x != -2000 && leftEye.y != -2000 && rightEye.x != -2000 && rightEye.y != -2000 && mouth.x != -2000 && mouth.y != -2000) {
        leftEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        rightEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        mouth = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        api2Face = faceRect.toFace(face.id, leftEye, rightEye, mouth);
    } else {
        api2Face = faceRect.toFace();
    }
    return api2Face;
}
Also used : Area(android.hardware.Camera.Area) Area(android.hardware.Camera.Area) Camera(android.hardware.Camera) Point(android.graphics.Point) Face(android.hardware.camera2.params.Face)

Example 2 with WeightedRectangle

use of android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle in project android_frameworks_base by DirtyUnicorns.

the class ParameterUtils method convertFaceFromLegacy.

/**
     * Convert an api1 face into an active-array based api2 face.
     *
     * <p>Out-of-ranges scores and ids will be clipped to be within range (with a warning).</p>
     *
     * @param face a non-{@code null} api1 face
     * @param activeArraySize active array size of the sensor (e.g. max jpeg size)
     * @param zoomData the calculated zoom data corresponding to this request
     *
     * @return a non-{@code null} api2 face
     *
     * @throws NullPointerException if the {@code face} was {@code null}
     */
public static Face convertFaceFromLegacy(Camera.Face face, Rect activeArray, ZoomData zoomData) {
    checkNotNull(face, "face must not be null");
    Face api2Face;
    Camera.Area fakeArea = new Camera.Area(face.rect, /*weight*/
    1);
    WeightedRectangle faceRect = convertCameraAreaToActiveArrayRectangle(activeArray, zoomData, fakeArea);
    Point leftEye = face.leftEye, rightEye = face.rightEye, mouth = face.mouth;
    if (leftEye != null && rightEye != null && mouth != null && leftEye.x != -2000 && leftEye.y != -2000 && rightEye.x != -2000 && rightEye.y != -2000 && mouth.x != -2000 && mouth.y != -2000) {
        leftEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        rightEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        mouth = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        api2Face = faceRect.toFace(face.id, leftEye, rightEye, mouth);
    } else {
        api2Face = faceRect.toFace();
    }
    return api2Face;
}
Also used : Area(android.hardware.Camera.Area) Area(android.hardware.Camera.Area) Camera(android.hardware.Camera) Point(android.graphics.Point) Face(android.hardware.camera2.params.Face)

Example 3 with WeightedRectangle

use of android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle in project android_frameworks_base by DirtyUnicorns.

the class LegacyResultMapper method getMeteringRectangles.

private static MeteringRectangle[] getMeteringRectangles(Rect activeArray, ZoomData zoomData, List<Camera.Area> meteringAreaList, String regionName) {
    List<MeteringRectangle> meteringRectList = new ArrayList<>();
    if (meteringAreaList != null) {
        for (Camera.Area area : meteringAreaList) {
            WeightedRectangle rect = ParameterUtils.convertCameraAreaToActiveArrayRectangle(activeArray, zoomData, area);
            meteringRectList.add(rect.toMetering());
        }
    }
    if (DEBUG) {
        Log.v(TAG, "Metering rectangles for " + regionName + ": " + ListUtils.listToString(meteringRectList));
    }
    return meteringRectList.toArray(new MeteringRectangle[0]);
}
Also used : WeightedRectangle(android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle) ArrayList(java.util.ArrayList) MeteringRectangle(android.hardware.camera2.params.MeteringRectangle) Camera(android.hardware.Camera)

Example 4 with WeightedRectangle

use of android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle in project android_frameworks_base by AOSPA.

the class ParameterUtils method convertFaceFromLegacy.

/**
     * Convert an api1 face into an active-array based api2 face.
     *
     * <p>Out-of-ranges scores and ids will be clipped to be within range (with a warning).</p>
     *
     * @param face a non-{@code null} api1 face
     * @param activeArraySize active array size of the sensor (e.g. max jpeg size)
     * @param zoomData the calculated zoom data corresponding to this request
     *
     * @return a non-{@code null} api2 face
     *
     * @throws NullPointerException if the {@code face} was {@code null}
     */
public static Face convertFaceFromLegacy(Camera.Face face, Rect activeArray, ZoomData zoomData) {
    checkNotNull(face, "face must not be null");
    Face api2Face;
    Camera.Area fakeArea = new Camera.Area(face.rect, /*weight*/
    1);
    WeightedRectangle faceRect = convertCameraAreaToActiveArrayRectangle(activeArray, zoomData, fakeArea);
    Point leftEye = face.leftEye, rightEye = face.rightEye, mouth = face.mouth;
    if (leftEye != null && rightEye != null && mouth != null && leftEye.x != -2000 && leftEye.y != -2000 && rightEye.x != -2000 && rightEye.y != -2000 && mouth.x != -2000 && mouth.y != -2000) {
        leftEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        rightEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        mouth = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        api2Face = faceRect.toFace(face.id, leftEye, rightEye, mouth);
    } else {
        api2Face = faceRect.toFace();
    }
    return api2Face;
}
Also used : Area(android.hardware.Camera.Area) Area(android.hardware.Camera.Area) Camera(android.hardware.Camera) Point(android.graphics.Point) Face(android.hardware.camera2.params.Face)

Example 5 with WeightedRectangle

use of android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle in project android_frameworks_base by ResurrectionRemix.

the class ParameterUtils method convertFaceFromLegacy.

/**
     * Convert an api1 face into an active-array based api2 face.
     *
     * <p>Out-of-ranges scores and ids will be clipped to be within range (with a warning).</p>
     *
     * @param face a non-{@code null} api1 face
     * @param activeArraySize active array size of the sensor (e.g. max jpeg size)
     * @param zoomData the calculated zoom data corresponding to this request
     *
     * @return a non-{@code null} api2 face
     *
     * @throws NullPointerException if the {@code face} was {@code null}
     */
public static Face convertFaceFromLegacy(Camera.Face face, Rect activeArray, ZoomData zoomData) {
    checkNotNull(face, "face must not be null");
    Face api2Face;
    Camera.Area fakeArea = new Camera.Area(face.rect, /*weight*/
    1);
    WeightedRectangle faceRect = convertCameraAreaToActiveArrayRectangle(activeArray, zoomData, fakeArea);
    Point leftEye = face.leftEye, rightEye = face.rightEye, mouth = face.mouth;
    if (leftEye != null && rightEye != null && mouth != null && leftEye.x != -2000 && leftEye.y != -2000 && rightEye.x != -2000 && rightEye.y != -2000 && mouth.x != -2000 && mouth.y != -2000) {
        leftEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        rightEye = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        mouth = convertCameraPointToActiveArrayPoint(activeArray, zoomData, leftEye, /*usePreviewCrop*/
        true);
        api2Face = faceRect.toFace(face.id, leftEye, rightEye, mouth);
    } else {
        api2Face = faceRect.toFace();
    }
    return api2Face;
}
Also used : Area(android.hardware.Camera.Area) Area(android.hardware.Camera.Area) Camera(android.hardware.Camera) Point(android.graphics.Point) Face(android.hardware.camera2.params.Face)

Aggregations

Camera (android.hardware.Camera)10 Point (android.graphics.Point)5 Area (android.hardware.Camera.Area)5 WeightedRectangle (android.hardware.camera2.legacy.ParameterUtils.WeightedRectangle)5 Face (android.hardware.camera2.params.Face)5 MeteringRectangle (android.hardware.camera2.params.MeteringRectangle)5 ArrayList (java.util.ArrayList)5