0

I want to capture the top of an image with cameraX I know we can apply a ratio on image but when I do that the ratio is applied on the center of the image

I look on different method in ImageCaptureConfig.Builder but i found nothing relevant

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()
Drping
  • 53
  • 11
  • I don't think CameraX provides means for cropping captured images. You need to capture the whole image, then crop it to your liking. Search this site for "android crop image". – Aleks G May 28 '19 at 15:11

1 Answers1

1

You will need to do this code in the ImageCapture use case. See the official Android Camera X sample project for how they do cropping: https://github.com/android/camera/blob/master/CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt#L205

Mike A
  • 537
  • 5
  • 9