我可以使用 cameraX 只捕捉图像的顶部吗?
Can i capture only top of image with cameraX?
我想用 cameraX 捕捉图像的顶部我知道我们可以在图像上应用比例,但是当我这样做时,比例会应用到图像的中心
我查看了 ImageCaptureConfig.Builder 中的不同方法,但没有发现任何相关内容
val imageCaptureConfig = ImageCaptureConfig.Builder()
.apply {
setTargetAspectRatio(Rational(3, 1)) // I want this but on the top of the image
setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY)
}.build()
您将需要在 ImageCapture
用例中执行此代码。查看官方 Android Camera X 示例项目,了解他们如何裁剪:https://github.com/android/camera/blob/master/CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt#L205
我想用 cameraX 捕捉图像的顶部我知道我们可以在图像上应用比例,但是当我这样做时,比例会应用到图像的中心
我查看了 ImageCaptureConfig.Builder 中的不同方法,但没有发现任何相关内容
val imageCaptureConfig = ImageCaptureConfig.Builder()
.apply {
setTargetAspectRatio(Rational(3, 1)) // I want this but on the top of the image
setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY)
}.build()
您将需要在 ImageCapture
用例中执行此代码。查看官方 Android Camera X 示例项目,了解他们如何裁剪:https://github.com/android/camera/blob/master/CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt#L205