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());
}
}
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);
}
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);
}
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;
}
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;
}
Aggregations