本文整理匯總了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;
}