Search in sources :

Example 1 with CameraInfo

use of android.hardware.Camera.CameraInfo in project Signal-Android by WhisperSystems.

the class CameraView method getCameraInfo.

@NonNull
private CameraInfo getCameraInfo() {
    final CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    return info;
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo) NonNull(android.support.annotation.NonNull)

Example 2 with CameraInfo

use of android.hardware.Camera.CameraInfo in project Signal-Android by WhisperSystems.

the class CameraView method getCameraPictureRotation.

public int getCameraPictureRotation(int orientation) {
    final CameraInfo info = getCameraInfo();
    final int rotation;
    orientation = (orientation + 45) / 90 * 90;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        rotation = (info.orientation - orientation + 360) % 360;
    } else {
        rotation = (info.orientation + orientation) % 360;
    }
    return rotation;
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Example 3 with CameraInfo

use of android.hardware.Camera.CameraInfo in project platform_frameworks_base by android.

the class CamcorderProfile method get.

/**
     * Returns the camcorder profile for the first back-facing camera on the
     * device at the given quality level. If the device has no back-facing
     * camera, this returns null.
     * @param quality the target quality level for the camcorder profile
     * @see #get(int, int)
     */
public static CamcorderProfile get(int quality) {
    int numberOfCameras = Camera.getNumberOfCameras();
    CameraInfo cameraInfo = new CameraInfo();
    for (int i = 0; i < numberOfCameras; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
            return get(i, quality);
        }
    }
    return null;
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Example 4 with CameraInfo

use of android.hardware.Camera.CameraInfo in project platform_frameworks_base by android.

the class CameraProfile method getJpegEncodingQualityParameter.

/**
     * Returns a pre-defined still image capture (jpeg) quality level
     * used for the given quality level in the Camera application for
     * the first back-facing camera on the device. If the device has no
     * back-facing camera, this returns 0.
     *
     * @param quality The target quality level
     */
public static int getJpegEncodingQualityParameter(int quality) {
    int numberOfCameras = Camera.getNumberOfCameras();
    CameraInfo cameraInfo = new CameraInfo();
    for (int i = 0; i < numberOfCameras; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
            return getJpegEncodingQualityParameter(i, quality);
        }
    }
    return 0;
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Example 5 with CameraInfo

use of android.hardware.Camera.CameraInfo in project platform_frameworks_base by android.

the class CameraDeviceUserShim method connectBinderShim.

public static CameraDeviceUserShim connectBinderShim(ICameraDeviceCallbacks callbacks, int cameraId) {
    if (DEBUG) {
        Log.d(TAG, "Opening shim Camera device");
    }
    /*
         * Put the camera open on a separate thread with its own looper; otherwise
         * if the main thread is used then the callbacks might never get delivered
         * (e.g. in CTS which run its own default looper only after tests)
         */
    CameraLooper init = new CameraLooper(cameraId);
    CameraCallbackThread threadCallbacks = new CameraCallbackThread(callbacks);
    // TODO: Make this async instead of blocking
    int initErrors = init.waitForOpen(OPEN_CAMERA_TIMEOUT_MS);
    Camera legacyCamera = init.getCamera();
    // Check errors old HAL initialization
    LegacyExceptionUtils.throwOnServiceError(initErrors);
    // Disable shutter sounds (this will work unconditionally) for api2 clients
    legacyCamera.disableShutterSound();
    CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    Camera.Parameters legacyParameters = null;
    try {
        legacyParameters = legacyCamera.getParameters();
    } catch (RuntimeException e) {
        throw new ServiceSpecificException(ICameraService.ERROR_INVALID_OPERATION, "Unable to get initial parameters: " + e.getMessage());
    }
    CameraCharacteristics characteristics = LegacyMetadataMapper.createCharacteristics(legacyParameters, info);
    LegacyCameraDevice device = new LegacyCameraDevice(cameraId, legacyCamera, characteristics, threadCallbacks);
    return new CameraDeviceUserShim(cameraId, device, characteristics, init, threadCallbacks);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) CameraCharacteristics(android.hardware.camera2.CameraCharacteristics) Camera(android.hardware.Camera) CameraInfo(android.hardware.Camera.CameraInfo)

Aggregations

CameraInfo (android.hardware.Camera.CameraInfo)56 Camera (android.hardware.Camera)6 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)5 ServiceSpecificException (android.os.ServiceSpecificException)5 SuppressLint (android.annotation.SuppressLint)3 WindowManager (android.view.WindowManager)2 IOException (java.io.IOException)2 TargetApi (android.annotation.TargetApi)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Face (android.hardware.Camera.Face)1 FaceDetectionListener (android.hardware.Camera.FaceDetectionListener)1 MediaRecorder (android.media.MediaRecorder)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 AppDataDirGuesser (com.google.testing.littlemock.AppDataDirGuesser)1