本文整理了Java中android.hardware.Camera.setDisplayOrientation()
方法的一些代码示例,展示了Camera.setDisplayOrientation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.setDisplayOrientation()
方法的具体详情如下:
包路径:android.hardware.Camera
类名称:Camera
方法名:setDisplayOrientation
暂无
代码示例来源:origin: journeyapps/zxing-android-embedded
private void setCameraDisplayOrientation(int rotation) {
camera.setDisplayOrientation(rotation);
}
代码示例来源:origin: LaiFeng-Android/SopCastComponent
private static void setOrientation(CameraData cameraData, boolean isLandscape, Camera camera) {
int orientation = getDisplayOrientation(cameraData.cameraID);
if(isLandscape) {
orientation = orientation - 90;
}
camera.setDisplayOrientation(orientation);
}
代码示例来源:origin: TommyLemon/APIJSON
/**
* Sets the camera up to take preview images which are used for both preview and decoding.
* We detect the preview format here so that buildLuminanceSource() can build an appropriate
* LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
* and the planar Y can be used for barcode scanning without a copy in some cases.
*/
void setDesiredCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Log.d(TAG, "Setting preview size: " + cameraResolution);
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
setFlash(parameters);
setZoom(parameters);
//setSharpness(parameters);
//modify here
camera.setDisplayOrientation(90);
camera.setParameters(parameters);
}
代码示例来源:origin: yipianfengye/android-zxingLibrary
/**
* Sets the camera up to take preview images which are used for both preview and decoding.
* We detect the preview format here so that buildLuminanceSource() can build an appropriate
* LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
* and the planar Y can be used for barcode scanning without a copy in some cases.
*/
void setDesiredCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Log.d(TAG, "Setting preview size: " + cameraResolution);
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
setFlash(parameters);
setZoom(parameters);
//setSharpness(parameters);
//modify here
camera.setDisplayOrientation(90);
camera.setParameters(parameters);
}
代码示例来源:origin: TommyLemon/Android-ZBLibrary
/**
* Sets the camera up to take preview images which are used for both preview and decoding.
* We detect the preview format here so that buildLuminanceSource() can build an appropriate
* LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
* and the planar Y can be used for barcode scanning without a copy in some cases.
*/
void setDesiredCameraParameters(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Log.d(TAG, "Setting preview size: " + cameraResolution);
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
setFlash(parameters);
setZoom(parameters);
//setSharpness(parameters);
//modify here
camera.setDisplayOrientation(90);
camera.setParameters(parameters);
}
代码示例来源:origin: daniulive/SmarterStreaming
private void setCameraDisplayOrientation(Activity activity, int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360;
} else {
// back-facing
result = (info.orientation - degrees + 360) % 360;
}
Log.i(TAG, "curDegree: " + result);
camera.setDisplayOrientation(result);
}
代码示例来源:origin: daniulive/SmarterStreaming
camera.setDisplayOrientation (result);
代码示例来源:origin: vondear/RxTool
@Override
void setDisplayOrientation(int displayOrientation) {
if (mDisplayOrientation == displayOrientation) {
return;
}
mDisplayOrientation = displayOrientation;
if (isCameraOpened()) {
mCameraParameters.setRotation(calcCameraRotation(displayOrientation));
mCamera.setParameters(mCameraParameters);
final boolean needsToStopPreview = mShowingPreview && Build.VERSION.SDK_INT < 14;
if (needsToStopPreview) {
mCamera.stopPreview();
}
mCamera.setDisplayOrientation(calcDisplayOrientation(displayOrientation));
if (needsToStopPreview) {
mCamera.startPreview();
}
}
}
代码示例来源:origin: stackoverflow.com
parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
mCamera.setParameters(parameters);
mCamera.setDisplayOrientation(90);
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
代码示例来源:origin: stackoverflow.com
camera.setDisplayOrientation(result);
代码示例来源:origin: google/cameraview
@Override
void setDisplayOrientation(int displayOrientation) {
if (mDisplayOrientation == displayOrientation) {
return;
}
mDisplayOrientation = displayOrientation;
if (isCameraOpened()) {
mCameraParameters.setRotation(calcCameraRotation(displayOrientation));
mCamera.setParameters(mCameraParameters);
final boolean needsToStopPreview = mShowingPreview && Build.VERSION.SDK_INT < 14;
if (needsToStopPreview) {
mCamera.stopPreview();
}
mCamera.setDisplayOrientation(calcDisplayOrientation(displayOrientation));
if (needsToStopPreview) {
mCamera.startPreview();
}
}
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
camera.setDisplayOrientation(90);
代码示例来源:origin: googlesamples/android-vision
camera.setDisplayOrientation(displayAngle);
parameters.setRotation(angle);
代码示例来源:origin: googlesamples/android-vision
camera.setDisplayOrientation(displayAngle);
parameters.setRotation(angle);
代码示例来源:origin: googlesamples/android-vision
camera.setDisplayOrientation(displayAngle);
parameters.setRotation(angle);
代码示例来源:origin: dm77/barcodescanner
public void showCameraPreview() {
if(mCameraWrapper != null) {
try {
getHolder().addCallback(this);
mPreviewing = true;
setupCameraParameters();
mCameraWrapper.mCamera.setPreviewDisplay(getHolder());
mCameraWrapper.mCamera.setDisplayOrientation(getDisplayOrientation());
mCameraWrapper.mCamera.setOneShotPreviewCallback(mPreviewCallback);
mCameraWrapper.mCamera.startPreview();
if(mAutoFocus) {
if (mSurfaceCreated) { // check if surface created before using autofocus
safeAutoFocus();
} else {
scheduleAutoFocus(); // wait 1 sec and then do check again
}
}
} catch (Exception e) {
Log.e(TAG, e.toString(), e);
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testDisplayOrientation() {
camera.setDisplayOrientation(180);
assertThat(shadowCamera.getDisplayOrientation()).isEqualTo(180);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetDisplayOrientationUpdatesCameraInfos() {
addBackCamera();
addFrontCamera();
camera = Camera.open(1);
camera.setDisplayOrientation(180);
Camera.CameraInfo cameraQuery = new Camera.CameraInfo();
Camera.getCameraInfo(ShadowCamera.getLastOpenedCameraId(), cameraQuery);
assertThat(cameraQuery.orientation).isEqualTo(180);
}
代码示例来源:origin: vondear/RxTool
private void openCamera() {
if (mCamera != null) {
releaseCamera();
}
mCamera = Camera.open(mCameraId);
mCameraParameters = mCamera.getParameters();
// Supported preview sizes
mPreviewSizes.clear();
for (Camera.Size size : mCameraParameters.getSupportedPreviewSizes()) {
mPreviewSizes.add(new Size(size.width, size.height));
}
// Supported picture sizes;
mPictureSizes.clear();
for (Camera.Size size : mCameraParameters.getSupportedPictureSizes()) {
mPictureSizes.add(new Size(size.width, size.height));
}
// AspectRatio
if (mAspectRatio == null) {
mAspectRatio = Constants.DEFAULT_ASPECT_RATIO;
}
adjustCameraParameters();
mCamera.setDisplayOrientation(calcDisplayOrientation(mDisplayOrientation));
mCallback.onCameraOpened();
}
代码示例来源:origin: google/cameraview
private void openCamera() {
if (mCamera != null) {
releaseCamera();
}
mCamera = Camera.open(mCameraId);
mCameraParameters = mCamera.getParameters();
// Supported preview sizes
mPreviewSizes.clear();
for (Camera.Size size : mCameraParameters.getSupportedPreviewSizes()) {
mPreviewSizes.add(new Size(size.width, size.height));
}
// Supported picture sizes;
mPictureSizes.clear();
for (Camera.Size size : mCameraParameters.getSupportedPictureSizes()) {
mPictureSizes.add(new Size(size.width, size.height));
}
// AspectRatio
if (mAspectRatio == null) {
mAspectRatio = Constants.DEFAULT_ASPECT_RATIO;
}
adjustCameraParameters();
mCamera.setDisplayOrientation(calcDisplayOrientation(mDisplayOrientation));
mCallback.onCameraOpened();
}
内容来源于网络,如有侵权,请联系作者删除!