本文整理汇总了Java中android.hardware.Camera.Parameters类的典型用法代码示例。如果您正苦于以下问题:Java Parameters类的具体用法?Java Parameters怎么用?Java Parameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parameters类属于android.hardware.Camera包,在下文中一共展示了Parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFocusMode
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@UiThread
private void setFocusMode(Parameters params) {
List<String> focusModes = params.getSupportedFocusModes();
if (LOG.isLoggable(INFO)) LOG.info("Focus modes: " + focusModes);
if (focusModes.contains(FOCUS_MODE_CONTINUOUS_PICTURE)) {
params.setFocusMode(FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (focusModes.contains(FOCUS_MODE_CONTINUOUS_VIDEO)) {
params.setFocusMode(FOCUS_MODE_CONTINUOUS_VIDEO);
} else if (focusModes.contains(FOCUS_MODE_EDOF)) {
params.setFocusMode(FOCUS_MODE_EDOF);
} else if (focusModes.contains(FOCUS_MODE_MACRO)) {
params.setFocusMode(FOCUS_MODE_MACRO);
} else if (focusModes.contains(FOCUS_MODE_AUTO)) {
params.setFocusMode(FOCUS_MODE_AUTO);
} else if (focusModes.contains(FOCUS_MODE_FIXED)) {
params.setFocusMode(FOCUS_MODE_FIXED);
}
}
示例2: turnLightOff
import android.hardware.Camera.Parameters; //导入依赖的package包/类
/**
* 通过设置Camera关闭闪光灯
*
* @param mCamera
*/
public void turnLightOff() {
if (camera == null) {
return;
}
Parameters parameters = camera.getParameters();
if (parameters == null) {
return;
}
List<String> flashModes = parameters.getSupportedFlashModes();
String flashMode = parameters.getFlashMode();
// Check if camera flash exists
if (flashModes == null) {
return;
}
// 闪光灯打开状态
if (!Parameters.FLASH_MODE_OFF.equals(flashMode)) {
// Turn off the flash
if (flashModes.contains(Parameters.FLASH_MODE_OFF)) {
parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
} else {
Log.e(TAG, "FLASH_MODE_OFF not supported");
}
}
}
示例3: configPreviewSize2
import android.hardware.Camera.Parameters; //导入依赖的package包/类
public BarcodeCameraConfig configPreviewSize2(int viewWidth, int viewHeight) {
Parameters params = camera.getParameters();
List<Size> sizes = params.getSupportedPreviewSizes();
if (sizes == null || sizes.size() <= 0) {
return this;
}
Size bestSize = null;
int diff = Integer.MAX_VALUE;
for (Size tmpSize : sizes) {
int newDiff = Math.abs(tmpSize.width - viewWidth) + Math.abs(tmpSize.height - viewHeight);
if (newDiff == 0) {
bestSize = tmpSize;
break;
} else if (newDiff < diff) {
bestSize = tmpSize;
diff = newDiff;
}
}
params.setPreviewSize(bestSize.width, bestSize.height);
camera.setParameters(params);
return this;
}
示例4: onOrientationChanged
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@Override
public void onOrientationChanged(int orientation) {
if (camera.isPresent() && orientation != ORIENTATION_UNKNOWN) {
int newOutputOrientation = getCameraPictureRotation(orientation);
if (newOutputOrientation != outputOrientation) {
outputOrientation = newOutputOrientation;
Camera.Parameters params = camera.get().getParameters();
params.setRotation(outputOrientation);
try {
camera.get().setParameters(params);
}
catch (Exception e) {
Log.e(TAG, "Exception updating camera parameters in orientation change", e);
}
}
}
}
示例5: surfaceChangedUi
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@UiThread
private void surfaceChangedUi(SurfaceHolder holder, int w, int h) {
if (LOG.isLoggable(INFO)) LOG.info("Surface changed: " + w + "x" + h);
if (surface != null && surface != holder.getSurface()) {
LOG.info("Releasing old surface");
surface.release();
}
surface = holder.getSurface();
surfaceWidth = w;
surfaceHeight = h;
if (camera == null) return; // We are stopped
stopPreview();
try {
Parameters params = camera.getParameters();
setPreviewSize(params);
camera.setParameters(params);
logCameraParameters();
} catch (RuntimeException e) {
LOG.log(WARNING, "Error setting preview size", e);
}
startPreview(holder);
}
示例6: setUpSurfaceTexture
import android.hardware.Camera.Parameters; //导入依赖的package包/类
public void setUpSurfaceTexture(final Camera camera) {
runOnDraw(new Runnable() {
@Override
public void run() {
try {
Camera.Parameters param = camera.getParameters();
param.setPreviewSize(1280, 720);//TODO
if (param.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
param.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
camera.setParameters(param);
int[] textures = new int[1];
GLES20.glGenTextures(1, textures, 0);
mSurfaceTexture = new SurfaceTexture(textures[0]);
camera.setPreviewTexture(mSurfaceTexture);
camera.setPreviewCallback(CameraRenderer.this);
camera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
示例7: onSurfaceChanged
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
GLES20.glViewport(0, 0, width, height);
try {
mCamera.setPreviewTexture(mSurfaceTexture);
Camera.Parameters param = mCamera.getParameters();
param.setPreviewSize(1920, 1080);//TODO
if (param.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
param.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
mCamera.setParameters(param);
mCamera.startPreview();
} catch (IOException e) {
e.printStackTrace();
}
}
示例8: CameraPreview
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
Parameters parameters = mCamera.getParameters();
parameters.setRotation(90);
mCamera.setParameters(parameters);
// mCamera.setParameters())
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
示例9: setFlash
import android.hardware.Camera.Parameters; //导入依赖的package包/类
public void setFlash(boolean flag) {
if (this.mCamera != null && CameraUtils.isFlashSupported(this.mCamera)) {
Parameters parameters = this.mCamera.getParameters();
if (flag) {
if (!parameters.getFlashMode().equals("torch")) {
parameters.setFlashMode("torch");
} else {
return;
}
} else if (!parameters.getFlashMode().equals("off")) {
parameters.setFlashMode("off");
} else {
return;
}
this.mCamera.setParameters(parameters);
}
}
示例10: initCamera
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@SuppressLint("NewApi")
private boolean initCamera() {
try {
if (frontCamera == 0) {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
} else {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
}
Parameters camParams = mCamera.getParameters();
mCamera.lock();
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(90);
} catch (RuntimeException ex) {
EMLog.e("video", "init Camera fail " + ex.getMessage());
return false;
}
return true;
}
示例11: configFocusMode
import android.hardware.Camera.Parameters; //导入依赖的package包/类
public BarcodeCameraConfig configFocusMode() {
try {
Parameters parameters = camera.getParameters();
String focusMode = findValue(parameters.getSupportedFocusModes(),
Parameters.FOCUS_MODE_AUTO,
Parameters.FOCUS_MODE_MACRO);
if (focusMode != null) {
parameters.setFocusMode(focusMode);
}
camera.setParameters(parameters);
} catch (Exception e) {
}
return this;
}
示例12: surfaceChanged
import android.hardware.Camera.Parameters; //导入依赖的package包/类
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
try {
if (mCamera != null) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
Camera.Parameters p = mCamera.getParameters();
p.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
requestLayout();
setCameraParams(mCamera, p);
startPreview();
}
} catch (Exception exception) {
Log.e(TAG, "Exception caused by surfaceChanged()", exception);
}
}
示例13: startPreview
import android.hardware.Camera.Parameters; //导入依赖的package包/类
public void startPreview() {
if (mCamera != null) {
// set flash mode
if (msbSupportFlash) {
Camera.Parameters p = mCamera.getParameters();
if (((ActivityQuickRecog)getContext()).isTurnOnFlashChecked()) {
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
} else {
p.setFlashMode(Parameters.FLASH_MODE_OFF);
}
setCameraParams(mCamera, p);
}
// set call back.
mCamera.setPreviewCallback(this);
// start preview.
mCamera.startPreview();
}
((ActivityQuickRecog)getContext()).onStartPreview();
}
示例14: setFlashState
import android.hardware.Camera.Parameters; //导入依赖的package包/类
/** Turns the LED on or off if phone has one. */
public synchronized void setFlashState(boolean state) {
Log.d("flash", "flash called");
// If the camera has already been opened, we apply the change immediately
if (mCamera != null) {
Log.d("flash", "camera not null");
if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
lockCamera();
}
Parameters parameters = mCamera.getParameters();
// We test if the phone has a flash
if (parameters.getFlashMode()==null) {
// The phone has no flash or the choosen camera can not toggle the flash
throw new RuntimeException("Can't turn the flash on !");
} else {
parameters.setFlashMode(state?Parameters.FLASH_MODE_TORCH:Parameters.FLASH_MODE_OFF);
try {
mCamera.setParameters(parameters);
mFlashEnabled = state;
} catch (RuntimeException e) {
mFlashEnabled = false;
throw new RuntimeException("Can't turn the flash on !");
} finally {
if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
unlockCamera();
}
}
}
} else {
mFlashEnabled = state;
}
}
示例15: getSupportedVideoSizes
import android.hardware.Camera.Parameters; //导入依赖的package包/类
@TargetApi(VERSION_CODES.HONEYCOMB)
protected List<Size> getSupportedVideoSizes(int currentSdkInt) {
Parameters params = mNativeCamera.getNativeCameraParameters();
List<Size> supportedVideoSizes;
if (currentSdkInt < Build.VERSION_CODES.HONEYCOMB) {
CLog.e(CLog.CAMERA, "Using supportedPreviewSizes iso supportedVideoSizes due to API restriction");
supportedVideoSizes = params.getSupportedPreviewSizes();
} else if (params.getSupportedVideoSizes() == null) {
CLog.e(CLog.CAMERA, "Using supportedPreviewSizes because supportedVideoSizes is null");
supportedVideoSizes = params.getSupportedPreviewSizes();
} else {
supportedVideoSizes = params.getSupportedVideoSizes();
}
return supportedVideoSizes;
}