Search in sources :

Example 46 with CameraInfo

use of android.hardware.Camera.CameraInfo in project android_packages_apps_Camera by CyanogenMod.

the class PhotoModule method initializeFocusManager.

/**
     * The focus manager is the first UI related element to get initialized,
     * and it requires the RenderOverlay, so initialize it here
     */
private void initializeFocusManager() {
    // Create FocusManager object. startPreview needs it.
    mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
    // otherwise create a new instance
    if (mFocusManager != null) {
        mFocusManager.removeMessages();
    } else {
        CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
        boolean mirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
        String[] defaultFocusModes = mActivity.getResources().getStringArray(R.array.pref_camera_focusmode_default_array);
        mFocusManager = new FocusOverlayManager(mPreferences, defaultFocusModes, mInitialParams, this, mirror, mActivity.getMainLooper());
    }
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Example 47 with CameraInfo

use of android.hardware.Camera.CameraInfo in project android_packages_apps_Camera by CyanogenMod.

the class VideoModule method showAlert.

private void showAlert() {
    Bitmap bitmap = null;
    if (mVideoFileDescriptor != null) {
        bitmap = Thumbnail.createVideoThumbnailBitmap(mVideoFileDescriptor.getFileDescriptor(), mPreviewFrameLayout.getWidth());
    } else if (mCurrentVideoFilename != null) {
        bitmap = Thumbnail.createVideoThumbnailBitmap(mCurrentVideoFilename, mPreviewFrameLayout.getWidth());
    }
    if (bitmap != null) {
        // MetadataRetriever already rotates the thumbnail. We should rotate
        // it to match the UI orientation (and mirror if it is front-facing camera).
        CameraInfo[] info = CameraHolder.instance().getCameraInfo();
        boolean mirror = (info[mCameraId].facing == CameraInfo.CAMERA_FACING_FRONT);
        bitmap = Util.rotateAndMirror(bitmap, 0, mirror);
        mReviewImage.setImageBitmap(bitmap);
        mReviewImage.setVisibility(View.VISIBLE);
    }
    Util.fadeOut(mShutterButton);
    Util.fadeIn((View) mReviewDoneButton);
    Util.fadeIn(mReviewPlayButton);
    mMenu.setVisibility(View.GONE);
    mOnScreenIndicators.setVisibility(View.GONE);
    enableCameraControls(false);
    showTimeLapseUI(false);
}
Also used : Bitmap(android.graphics.Bitmap) CameraInfo(android.hardware.Camera.CameraInfo)

Example 48 with CameraInfo

use of android.hardware.Camera.CameraInfo in project android_frameworks_base by AOSPA.

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)

Example 49 with CameraInfo

use of android.hardware.Camera.CameraInfo in project android_frameworks_base by AOSPA.

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 50 with CameraInfo

use of android.hardware.Camera.CameraInfo in project VideoRecorder by qdrzwd.

the class Util method determineDisplayOrientation.

public static int determineDisplayOrientation(Activity activity, int defaultCameraId) {
    int displayOrientation = 0;
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
        CameraInfo cameraInfo = new CameraInfo();
        Camera.getCameraInfo(defaultCameraId, cameraInfo);
        int degrees = getRotationAngle(activity);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            displayOrientation = (cameraInfo.orientation + degrees) % 360;
            displayOrientation = (360 - displayOrientation) % 360;
        } else {
            displayOrientation = (cameraInfo.orientation - degrees + 360) % 360;
        }
    }
    return displayOrientation;
}
Also used : CameraInfo(android.hardware.Camera.CameraInfo)

Aggregations

CameraInfo (android.hardware.Camera.CameraInfo)58 Camera (android.hardware.Camera)6 SuppressLint (android.annotation.SuppressLint)5 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)5 ServiceSpecificException (android.os.ServiceSpecificException)5 WindowManager (android.view.WindowManager)3 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