當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。