使用不带TextureView的ImageReader时,Camera2 API自动对焦不起作用

时间:2018-09-05 10:52:02

标签: android

使用ImageReader获取最新图像(Camera 2 API)时,如果我将TextureView用作表面,则ImageReader会获得具有自动聚焦的输出图像。 但是,如果没有TextureView作为曲面,则自动对焦不起作用(在ImageReader上获得模糊的图像)。 为什么将TextureView作为表面会影响自动对焦?

  surfaceTexture = textureView.surfaceTexture
  surfaceTexture!!.setDefaultBufferSize(mPreviewSize!!.width, mPreviewSize!!.height)
  // This is the output Surface we need to start preview.
  val surface = Surface(surfaceTexture)

  // We set up a CaptureRequest.Builder with the output Surface.
  mPreviewRequestBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)
  mPreviewRequestBuilder!!.addTarget(mImageReader!!.surface)
  mPreviewRequestBuilder!!.addTarget(surface)
  // Here, we create a CameraCaptureSession for camera preview.
  mCameraDevice!!.createCaptureSession(
    listOf(mImageReader!!.surface, surface),
    object : CameraCaptureSession.StateCallback() {

}

0 个答案:

没有答案