Search in sources :

Example 71 with Size

use of android.util.Size in project android_frameworks_base by AOSPA.

the class StaticMetadata method isHighSpeedVideoSupported.

/**
     * Check if high speed video is supported (HIGH_SPEED_VIDEO scene mode is
     * supported, supported high speed fps ranges and sizes are valid).
     *
     * @return true if high speed video is supported.
     */
public boolean isHighSpeedVideoSupported() {
    List<Integer> sceneModes = Arrays.asList(CameraTestUtils.toObject(getAvailableSceneModesChecked()));
    if (sceneModes.contains(CameraCharacteristics.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO)) {
        StreamConfigurationMap config = getValueFromKeyNonNull(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
        if (config == null) {
            return false;
        }
        Size[] availableSizes = config.getHighSpeedVideoSizes();
        if (availableSizes.length == 0) {
            return false;
        }
        for (Size size : availableSizes) {
            Range<Integer>[] availableFpsRanges = config.getHighSpeedVideoFpsRangesFor(size);
            if (availableFpsRanges.length == 0) {
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : Size(android.util.Size) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) Range(android.util.Range)

Example 72 with Size

use of android.util.Size in project android_frameworks_base by AOSPA.

the class StaticMetadata method getAvailableSizesForFormatChecked.

/**
     * Get available sizes for given format and direction, and whether to limit to slow or fast
     * resolutions.
     *
     * @param format The format for the requested size array.
     * @param direction The stream direction, input or output.
     * @param fastSizes whether to include getOutputSizes() sizes (generally faster)
     * @param slowSizes whether to include getHighResolutionOutputSizes() sizes (generally slower)
     * @return The sizes of the given format, empty array if no available size is found.
     */
public Size[] getAvailableSizesForFormatChecked(int format, StreamDirection direction, boolean fastSizes, boolean slowSizes) {
    Key<StreamConfigurationMap> key = CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
    StreamConfigurationMap config = getValueFromKeyNonNull(key);
    if (config == null) {
        return new Size[0];
    }
    Size[] sizes = null;
    switch(direction) {
        case Output:
            Size[] fastSizeList = null;
            Size[] slowSizeList = null;
            if (fastSizes) {
                fastSizeList = config.getOutputSizes(format);
            }
            if (slowSizes) {
                slowSizeList = config.getHighResolutionOutputSizes(format);
            }
            if (fastSizeList != null && slowSizeList != null) {
                sizes = new Size[slowSizeList.length + fastSizeList.length];
                System.arraycopy(fastSizeList, 0, sizes, 0, fastSizeList.length);
                System.arraycopy(slowSizeList, 0, sizes, fastSizeList.length, slowSizeList.length);
            } else if (fastSizeList != null) {
                sizes = fastSizeList;
            } else if (slowSizeList != null) {
                sizes = slowSizeList;
            }
            break;
        case Input:
            sizes = config.getInputSizes(format);
            break;
        default:
            throw new IllegalArgumentException("direction must be output or input");
    }
    if (sizes == null) {
        sizes = new Size[0];
    }
    return sizes;
}
Also used : Size(android.util.Size) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 73 with Size

use of android.util.Size in project android_frameworks_base by AOSPA.

the class CameraTestUtils method getSupportedSizeForFormat.

/**
     * Get the available output sizes for the user-defined {@code format}.
     *
     * <p>Note that implementation-defined/hidden formats are not supported.</p>
     */
public static Size[] getSupportedSizeForFormat(int format, String cameraId, CameraManager cameraManager) throws CameraAccessException {
    CameraCharacteristics properties = cameraManager.getCameraCharacteristics(cameraId);
    assertNotNull("Can't get camera characteristics!", properties);
    if (VERBOSE) {
        Log.v(TAG, "get camera characteristics for camera: " + cameraId);
    }
    StreamConfigurationMap configMap = properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    Size[] availableSizes = configMap.getOutputSizes(format);
    assertArrayNotEmpty(availableSizes, "availableSizes should not be empty for format: " + format);
    Size[] highResAvailableSizes = configMap.getHighResolutionOutputSizes(format);
    if (highResAvailableSizes != null && highResAvailableSizes.length > 0) {
        Size[] allSizes = new Size[availableSizes.length + highResAvailableSizes.length];
        System.arraycopy(availableSizes, 0, allSizes, 0, availableSizes.length);
        System.arraycopy(highResAvailableSizes, 0, allSizes, availableSizes.length, highResAvailableSizes.length);
        availableSizes = allSizes;
    }
    if (VERBOSE)
        Log.v(TAG, "Supported sizes are: " + Arrays.deepToString(availableSizes));
    return availableSizes;
}
Also used : Size(android.util.Size) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap)

Example 74 with Size

use of android.util.Size in project android_frameworks_base by AOSPA.

the class CameraTestUtils method getPreviewSizeBound.

public static Size getPreviewSizeBound(WindowManager windowManager, Size bound) {
    Display display = windowManager.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    if (height > width) {
        height = width;
        width = display.getHeight();
    }
    if (bound.getWidth() <= width && bound.getHeight() <= height)
        return bound;
    else
        return new Size(width, height);
}
Also used : Size(android.util.Size) Display(android.view.Display)

Example 75 with Size

use of android.util.Size in project android_frameworks_base by AOSPA.

the class StaticMetadata method getPreCorrectedActiveArraySizeChecked.

/**
     * Get and check pre-correction active array size.
     */
public Rect getPreCorrectedActiveArraySizeChecked() {
    Key<Rect> key = CameraCharacteristics.SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE;
    Rect activeArray = getValueFromKeyNonNull(key);
    if (activeArray == null) {
        return new Rect(0, 0, 0, 0);
    }
    Size pixelArraySize = getPixelArraySizeChecked();
    checkTrueForKey(key, "values left/top are invalid", activeArray.left >= 0 && activeArray.top >= 0);
    checkTrueForKey(key, "values width/height are invalid", activeArray.width() <= pixelArraySize.getWidth() && activeArray.height() <= pixelArraySize.getHeight());
    return activeArray;
}
Also used : Rect(android.graphics.Rect) Size(android.util.Size)

Aggregations

Size (android.util.Size)320 ArrayList (java.util.ArrayList)66 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)41 Rect (android.graphics.Rect)40 CaptureRequest (android.hardware.camera2.CaptureRequest)40 Range (android.util.Range)40 Surface (android.view.Surface)35 SimpleCaptureCallback (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)35 Camera (android.hardware.Camera)30 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)26 Point (android.graphics.Point)22 Image (android.media.Image)21 SimpleImageReaderListener (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleImageReaderListener)20 MeteringRectangle (android.hardware.camera2.params.MeteringRectangle)15 CamcorderProfile (android.media.CamcorderProfile)15 Pair (android.util.Pair)15 CameraTestUtils.getDataFromImage (com.android.mediaframeworktest.helpers.CameraTestUtils.getDataFromImage)15 SurfaceTexture (android.graphics.SurfaceTexture)10 Parameters (android.hardware.Camera.Parameters)10 CaptureResult (android.hardware.camera2.CaptureResult)10