android.hardware.Camera.takePicture()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中android.hardware.Camera.takePicture()方法的一些代码示例,展示了Camera.takePicture()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.takePicture()方法的具体详情如下:
包路径:android.hardware.Camera
类名称:Camera
方法名:takePicture

Camera.takePicture介绍

暂无

代码示例

代码示例来源:origin: florent37/CameraFragment

@Override
  public void run() {
    setCameraPhotoQuality(camera);
    camera.takePicture(null, null, new Camera.PictureCallback() {
      @Override
      public void onPictureTaken(byte[] bytes, Camera camera) {
        Camera1Manager.this.onPictureTaken(bytes, camera, callback);
      }
    });
  }
});

代码示例来源:origin: vondear/RxTool

void takePictureInternal() {
  if (!isPictureCaptureInProgress.getAndSet(true)) {
    mCamera.takePicture(null, null, null, new Camera.PictureCallback() {
      @Override
      public void onPictureTaken(byte[] data, Camera camera) {
        isPictureCaptureInProgress.set(false);
        mCallback.onPictureTaken(data);
        camera.cancelAutoFocus();
        camera.startPreview();
      }
    });
  }
}

代码示例来源:origin: google/cameraview

void takePictureInternal() {
  if (!isPictureCaptureInProgress.getAndSet(true)) {
    mCamera.takePicture(null, null, null, new Camera.PictureCallback() {
      @Override
      public void onPictureTaken(byte[] data, Camera camera) {
        isPictureCaptureInProgress.set(false);
        mCallback.onPictureTaken(data);
        camera.cancelAutoFocus();
        camera.startPreview();
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public void onClick(View v) {
  mCamera.takePicture(null, null, mPicture);

代码示例来源:origin: googlesamples/android-vision

/**
 * Initiates taking a picture, which happens asynchronously.  The camera source should have been
 * activated previously with {@link #start()} or {@link #start(SurfaceHolder)}.  The camera
 * preview is suspended while the picture is being taken, but will resume once picture taking is
 * done.
 *
 * @param shutter the callback for image capture moment, or null
 * @param jpeg    the callback for JPEG image data, or null
 */
public void takePicture(ShutterCallback shutter, PictureCallback jpeg) {
  synchronized (mCameraLock) {
    if (mCamera != null) {
      PictureStartCallback startCallback = new PictureStartCallback();
      startCallback.mDelegate = shutter;
      PictureDoneCallback doneCallback = new PictureDoneCallback();
      doneCallback.mDelegate = jpeg;
      mCamera.takePicture(startCallback, null, null, doneCallback);
    }
  }
}

代码示例来源:origin: googlesamples/android-vision

/**
 * Initiates taking a picture, which happens asynchronously.  The camera source should have been
 * activated previously with {@link #start()} or {@link #start(SurfaceHolder)}.  The camera
 * preview is suspended while the picture is being taken, but will resume once picture taking is
 * done.
 *
 * @param shutter the callback for image capture moment, or null
 * @param jpeg    the callback for JPEG image data, or null
 */
public void takePicture(ShutterCallback shutter, PictureCallback jpeg) {
  synchronized (mCameraLock) {
    if (mCamera != null) {
      PictureStartCallback startCallback = new PictureStartCallback();
      startCallback.mDelegate = shutter;
      PictureDoneCallback doneCallback = new PictureDoneCallback();
      doneCallback.mDelegate = jpeg;
      mCamera.takePicture(startCallback, null, null, doneCallback);
    }
  }
}

代码示例来源:origin: googlesamples/android-vision

/**
 * Initiates taking a picture, which happens asynchronously.  The camera source should have been
 * activated previously with {@link #start()} or {@link #start(SurfaceHolder)}.  The camera
 * preview is suspended while the picture is being taken, but will resume once picture taking is
 * done.
 *
 * @param shutter the callback for image capture moment, or null
 * @param jpeg    the callback for JPEG image data, or null
 */
public void takePicture(ShutterCallback shutter, PictureCallback jpeg) {
  synchronized (cameraLock) {
    if (camera != null) {
      PictureStartCallback startCallback = new PictureStartCallback();
      startCallback.mDelegate = shutter;
      PictureDoneCallback doneCallback = new PictureDoneCallback();
      doneCallback.mDelegate = jpeg;
      camera.takePicture(startCallback, null, null, doneCallback);
    }
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testTakePicture() throws Exception {
 camera.takePicture(null, null, null);
 TestShutterCallback shutterCallback = new TestShutterCallback();
 TestPictureCallback rawCallback = new TestPictureCallback();
 TestPictureCallback jpegCallback = new TestPictureCallback();
 camera.takePicture(shutterCallback, rawCallback, jpegCallback);
 assertThat(shutterCallback.wasCalled).isTrue();
 assertThat(rawCallback.wasCalled).isTrue();
 assertThat(jpegCallback.wasCalled).isTrue();
}

代码示例来源:origin: stackoverflow.com

camera.autoFocus(new AutoFocusCallback() {
   @Override
   public void onAutoFocus(boolean success, Camera camera) {
     if(success){
       camera.takePicture(shutterCallback, rawCallback, jpegCallback);
     }
   }
 });

代码示例来源:origin: guoxiaoxing/phoenix

@Override
  public void run() {
    setCameraPhotoQuality(camera);
    camera.takePicture(null, null, new Camera.PictureCallback() {
      @Override
      public void onPictureTaken(byte[] bytes, Camera camera) {
        Camera1Manager.this.onPictureTaken(bytes, camera, callback);
      }
    });
  }
});

代码示例来源:origin: stackoverflow.com

camera.autoFocus(new Camera.AutoFocusCallback() {
 Camera.ShutterCallback shutterCallback = new Camera.ShutterCallback() {
  public void onShutter() {
   // Play your sound here.
  }
 };
 public void onAutoFocus(boolean success, Camera camera) {
  camera.takePicture(shutterCallback, null, photoCallback);
 }
});

代码示例来源:origin: stackoverflow.com

Camera.AutoFocusCallback mAutoFocusCallback = new Camera.AutoFocusCallback() {
  @Override
  public void onAutoFocus(boolean success, Camera camera) {
    camera.takePicture(null, null, mPictureCallbackRaw);
  }
};

Camera.PictureCallback mPictureCallbackRaw = new Camera.PictureCallback() {  
  public void onPictureTaken(byte[] data, Camera c) { 
    // (...)            
  }  
};

public void takeFocusedPicture() {
  mCamera.autoFocus(mAutoFocusCallback);
}

代码示例来源:origin: stackoverflow.com

mCamera.takePicture(null, null, mPictureCallback);

代码示例来源:origin: simplezhli/Tesseract-OCR-Scanner

public void takeShot(Camera.ShutterCallback shutterCallback,
           Camera.PictureCallback rawPictureCallback,
           Camera.PictureCallback jpegPictureCallback ){
  mCamera.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback);
}

代码示例来源:origin: lb377463323/GraphicsTestBed

public void takePicture(){
  if (mCamera != null){
    mCamera.takePicture(null, null, mPictureCallback);
  }
}

代码示例来源:origin: stackoverflow.com

public void butClick(View v){
  preview.camera.autoFocus(new AutoFocusCallback() {
    public void onAutoFocus(boolean success, Camera camera) {
      if(success){
        camera.takePicture(shutterCallback, rawCallback, jpegCallback);
      }
    }
  });
}

代码示例来源:origin: stackoverflow.com

if (getAutoFocusStatus()){
  camera.autoFocus(new AutoFocusCallback() {
    @Override
    public void onAutoFocus(boolean success, Camera camera) {
      if(success) camera.takePicture(shutterCallback, rawCallback, jpegCallback);
    }
  }); 
}else{
  camera.takePicture(shutterCallback, rawCallback, jpegCallback);
}

代码示例来源:origin: stackoverflow.com

public void takePhoto(File photoFile, String workerName, int width, int height, int    quality) {
if (getAutoFocusStatus()){
  camera.autoFocus(new AutoFocusCallback() {
    @Override
    public void onAutoFocus(boolean success, Camera camera) {
      camera.takePicture(shutterCallback, rawCallback, jpegCallback);
    }
  }); 
}else{
  camera.takePicture(shutterCallback, rawCallback, jpegCallback);
}

代码示例来源:origin: stackoverflow.com

private AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback() {
  @Override
  public void onAutoFocus(boolean success, Camera camera) {
    if (success) {
        camera.takePicture(shutterCallback, rawCallback, jpegCallback);
      }
  }
};

代码示例来源:origin: vbier/habpanelviewer

@Override
public void takePicture(IPictureListener iPictureHandler) {
  if (isPreviewRunning()) {
    mCamera.takePicture(null, null, (bytes, camera) -> {
      byte[] data = new byte[bytes.length];
      System.arraycopy(bytes, 0, data, 0, bytes.length);
      iPictureHandler.picture(data);
    });
  } else {
    throw new IllegalStateException(mActivity.getString(R.string.camNotInitialized));
  }
}

相关文章