Search in sources :

Example 76 with CameraCharacteristics

use of android.hardware.camera2.CameraCharacteristics in project android_frameworks_base by AOSPA.

the class Camera2SurfaceViewTestCase method openDevice.

/**
     * Open a camera device and get the StaticMetadata for a given camera id.
     *
     * @param cameraId The id of the camera device to be opened.
     */
protected void openDevice(String cameraId) throws Exception {
    mCamera = CameraTestUtils.openCamera(mCameraManager, cameraId, mCameraListener, mHandler);
    mCollector.setCameraId(cameraId);
    CameraCharacteristics properties = mCameraManager.getCameraCharacteristics(cameraId);
    mStaticInfo = new StaticMetadata(properties, CheckLevel.ASSERT, /*collector*/
    null);
    StreamConfigurationMap configMap = properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    mSupportRAW10 = configMap.isOutputSupportedFor(ImageFormat.RAW10);
    if (mStaticInfo.isColorOutputSupported()) {
        mOrderedPreviewSizes = getSupportedPreviewSizes(cameraId, mCameraManager, getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
        mOrderedVideoSizes = getSupportedVideoSizes(cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
        mOrderedStillSizes = getSupportedStillSizes(cameraId, mCameraManager, null);
        if (mSupportRAW10) {
            mOrderedRAW10Sizes = getSortedSizesForFormat(cameraId, mCameraManager, ImageFormat.RAW10, null);
        }
        mOrderedYUV420888Sizes = getSortedSizesForFormat(cameraId, mCameraManager, ImageFormat.YUV_420_888, null);
        // Use ImageFormat.YUV_420_888 for now. TODO: need figure out what's format for preview
        // in public API side.
        mMinPreviewFrameDurationMap = mStaticInfo.getAvailableMinFrameDurationsForFormatChecked(ImageFormat.YUV_420_888);
    }
}
Also used : CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) StaticMetadata(com.android.mediaframeworktest.helpers.StaticMetadata)

Example 77 with CameraCharacteristics

use of android.hardware.camera2.CameraCharacteristics in project android_frameworks_base by AOSPA.

the class CameraTestUtils method getSupportedSizeForClass.

/**
     * Get the available output sizes for the given class.
     *
     */
public static Size[] getSupportedSizeForClass(Class klass, 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(klass);
    assertArrayNotEmpty(availableSizes, "availableSizes should not be empty for class: " + klass);
    Size[] highResAvailableSizes = configMap.getHighResolutionOutputSizes(ImageFormat.PRIVATE);
    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 78 with CameraCharacteristics

use of android.hardware.camera2.CameraCharacteristics in project android_frameworks_base by AOSPA.

the class FlashlightController method getCameraId.

private String getCameraId() throws CameraAccessException {
    String[] ids = mCameraManager.getCameraIdList();
    for (String id : ids) {
        CameraCharacteristics c = mCameraManager.getCameraCharacteristics(id);
        Boolean flashAvailable = c.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
        Integer lensFacing = c.get(CameraCharacteristics.LENS_FACING);
        if (flashAvailable != null && flashAvailable && lensFacing != null && lensFacing == CameraCharacteristics.LENS_FACING_BACK) {
            return id;
        }
    }
    return null;
}
Also used : CameraCharacteristics(android.hardware.camera2.CameraCharacteristics)

Example 79 with CameraCharacteristics

use of android.hardware.camera2.CameraCharacteristics in project android_frameworks_base by ResurrectionRemix.

the class Camera2SurfaceViewTestCase method openDevice.

/**
     * Open a camera device and get the StaticMetadata for a given camera id.
     *
     * @param cameraId The id of the camera device to be opened.
     */
protected void openDevice(String cameraId) throws Exception {
    mCamera = CameraTestUtils.openCamera(mCameraManager, cameraId, mCameraListener, mHandler);
    mCollector.setCameraId(cameraId);
    CameraCharacteristics properties = mCameraManager.getCameraCharacteristics(cameraId);
    mStaticInfo = new StaticMetadata(properties, CheckLevel.ASSERT, /*collector*/
    null);
    StreamConfigurationMap configMap = properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    mSupportRAW10 = configMap.isOutputSupportedFor(ImageFormat.RAW10);
    if (mStaticInfo.isColorOutputSupported()) {
        mOrderedPreviewSizes = getSupportedPreviewSizes(cameraId, mCameraManager, getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
        mOrderedVideoSizes = getSupportedVideoSizes(cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
        mOrderedStillSizes = getSupportedStillSizes(cameraId, mCameraManager, null);
        if (mSupportRAW10) {
            mOrderedRAW10Sizes = getSortedSizesForFormat(cameraId, mCameraManager, ImageFormat.RAW10, null);
        }
        mOrderedYUV420888Sizes = getSortedSizesForFormat(cameraId, mCameraManager, ImageFormat.YUV_420_888, null);
        // Use ImageFormat.YUV_420_888 for now. TODO: need figure out what's format for preview
        // in public API side.
        mMinPreviewFrameDurationMap = mStaticInfo.getAvailableMinFrameDurationsForFormatChecked(ImageFormat.YUV_420_888);
    }
}
Also used : CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) StreamConfigurationMap(android.hardware.camera2.params.StreamConfigurationMap) StaticMetadata(com.android.mediaframeworktest.helpers.StaticMetadata)

Example 80 with CameraCharacteristics

use of android.hardware.camera2.CameraCharacteristics in project android_frameworks_base by ResurrectionRemix.

the class FlashlightController method getCameraId.

private String getCameraId() throws CameraAccessException {
    String[] ids = mCameraManager.getCameraIdList();
    for (String id : ids) {
        CameraCharacteristics c = mCameraManager.getCameraCharacteristics(id);
        Boolean flashAvailable = c.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
        Integer lensFacing = c.get(CameraCharacteristics.LENS_FACING);
        if (flashAvailable != null && flashAvailable && lensFacing != null && lensFacing == CameraCharacteristics.LENS_FACING_BACK) {
            return id;
        }
    }
    return null;
}
Also used : CameraCharacteristics(android.hardware.camera2.CameraCharacteristics)

Aggregations

CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)104 CameraAccessException (android.hardware.camera2.CameraAccessException)42 CameraManager (android.hardware.camera2.CameraManager)37 Size (android.util.Size)37 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)29 Camera (android.hardware.Camera)25 Rect (android.graphics.Rect)20 CameraMetadataNative (android.hardware.camera2.impl.CameraMetadataNative)20 CaptureRequest (android.hardware.camera2.CaptureRequest)18 Parameters (android.hardware.Camera.Parameters)15 ArrayList (java.util.ArrayList)13 ZoomData (android.hardware.camera2.legacy.ParameterUtils.ZoomData)10 MeteringRectangle (android.hardware.camera2.params.MeteringRectangle)10 ServiceSpecificException (android.os.ServiceSpecificException)10 Range (android.util.Range)10 Point (android.graphics.Point)8 NonNull (android.annotation.NonNull)6 Activity (android.app.Activity)5 CameraInfo (android.hardware.Camera.CameraInfo)5 CameraInfo (android.hardware.CameraInfo)5