当前位置: 首页>>代码示例>>Java>>正文


Java Camera.startPreview方法代码示例

本文整理汇总了Java中android.hardware.Camera.startPreview方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.startPreview方法的具体用法?Java Camera.startPreview怎么用?Java Camera.startPreview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera的用法示例。


在下文中一共展示了Camera.startPreview方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: takePhoto

import android.hardware.Camera; //导入方法依赖的package包/类
public void takePhoto(){
    Camera.ShutterCallback shutterCallback = new Camera.ShutterCallback() {
        public void onShutter() {
            Log.d(TAG, "onShutter: ");
        }
    };

    Camera.PictureCallback jpegCallback = new Camera.PictureCallback() {
        public void onPictureTaken(final byte[] data, final Camera camera) {
            camera.startPreview();
            Log.d(TAG, "onPictureTaken: ");
            pictureTakenCallBack.saveAsBitmap(data);
        }
    };

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        camera.enableShutterSound(false);
    }

    camera.takePicture(shutterCallback, null, jpegCallback);
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:22,代码来源:CameraEngine.java

示例2: setUpSurfaceTextureInternal

import android.hardware.Camera; //导入方法依赖的package包/类
private void setUpSurfaceTextureInternal(final Camera camera, byte[] data) {
    if (null == camera) {
        log.error("setup camera failed, camera is null");
        return;
    }

    int[] textures = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    mSurfaceTexture = new SurfaceTexture(textures[0]);

    try {
        camera.addCallbackBuffer(data);
        camera.setPreviewTexture(mSurfaceTexture);
        camera.setPreviewCallbackWithBuffer(GPUImageRenderer.this);
        camera.startPreview();
    } catch (Exception e) {
        log.error("setup camera failed, " + e.getMessage());
    }
    log.debug("setUpSurfaceTextureInternal " + camera + " " + data.length);
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:21,代码来源:GPUImageRenderer.java

示例3: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
	Camera theCamera = camera;
	if (theCamera != null && !previewing) {
		theCamera.startPreview();
		previewing = true;
		autoFocusManager = new AutoFocusManager(context, camera);
	}
}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:12,代码来源:CameraManager.java

示例4: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
  Camera theCamera = camera;
  if (theCamera != null && !previewing) {
    theCamera.startPreview();
    previewing = true;
    autoFocusManager = new AutoFocusManager(context, camera);
  }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:12,代码来源:CameraManager.java

示例5: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    Camera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.setDisplayOrientation(90);
        theCamera.startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, camera);
    }
}
 
开发者ID:crisfg86,项目名称:Zxing-Custom,代码行数:13,代码来源:CameraManager.java

示例6: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
@ReactMethod
public void startPreview(ReadableMap options) {
    RCTCamera instance = RCTCamera.getInstance();
    if (instance == null) return;

    Camera camera = instance.acquireCameraInstance(options.getInt("type"));
    if (camera == null) return;

    camera.startPreview();
}
 
开发者ID:entria,项目名称:react-native-camera-face-detector,代码行数:11,代码来源:RCTCameraModule.java

示例7: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 *
 * Must be called from camera thread.
 */
public void startPreview() {
    Camera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(camera, settings);
        ambientLightManager = new AmbientLightManager(context, this, settings);
        ambientLightManager.start();
    }
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:16,代码来源:CameraManager.java

示例8: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    Camera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(context, camera);
    }
}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:12,代码来源:CameraManager.java

示例9: startPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Asks the camera hardware to begin drawing preview frames to the screen.
 */
public synchronized void startPreview() {
    Camera theCamera = camera;
    if (theCamera != null && !previewing) {
        theCamera.startPreview();
        previewing = true;
        autoFocusManager = new AutoFocusManager(camera);
    }
}
 
开发者ID:snice,项目名称:androidscan,代码行数:12,代码来源:CameraManager.java

示例10: setPreviewSize

import android.hardware.Camera; //导入方法依赖的package包/类
private boolean setPreviewSize(int width, int height, CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  params.setPreviewSize(width, height);
  fragment.setCameraParameters(params);
  camera.startPreview();

  callbackContext.success();
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:16,代码来源:CameraPreview.java

示例11: setStartPreview

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * 设置camera显示取景画面,并预览
 *
 * @param camera
 */
private void setStartPreview(Camera camera, SurfaceHolder holder) {
    try {
        if (null != camera) {
            // 通过surfaceview显示取景画面
            parameters = camera.getParameters(); // 获取各项参数
            //矫正拍照之后图片的旋转的角度
            if (!startFontCamera) {
                parameters.setRotation(270);
            } else {
                parameters.setRotation(getPreviewDegree(CameraActivity.this));
            }
            //            Size largestSize = getBestSupportedSize(parameters
            //                    .getSupportedPreviewSizes());
            //            parameters.setPreviewSize(largestSize.width, largestSize.height);// 设置预览图片尺寸
            Size largestSize = getBestSupportedSize(parameters
                    .getSupportedPictureSizes());// 设置捕捉图片尺寸
            parameters.setPictureSize(largestSize.width, largestSize.height);
            if (startFontCamera) {
                //连续对焦
                parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
            }
            camera.setParameters(parameters);
            camera.setPreviewDisplay(holder);
            // 设置用于显示拍照影像的SurfaceHolder对象
            camera.setDisplayOrientation(getPreviewDegree(CameraActivity.this));
            camera.startPreview();
            camera.cancelAutoFocus();//只有加上了这一句,才会自动对焦。

        } else {
            //
            Toast.makeText(this, "无法打开摄像头,请检查是否给开启了相关权限", Toast.LENGTH_SHORT).show();
        }
    } catch (IOException e) {
    }
}
 
开发者ID:Liuzhiyang94,项目名称:ComponentProjectDemo,代码行数:41,代码来源:CameraActivity.java


注:本文中的android.hardware.Camera.startPreview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。