1
val imageCaptureConfig = ImageCaptureConfig.Builder().apply {
            setLensFacing(CameraX.LensFacing.FRONT)
            setCaptureMode(CaptureMode.MAX_QUALITY)
            setBufferFormat(ImageFormat.YUV_420_888)
            setTargetResolution(Size(3264, 2448))
            // We request aspect ratio but no resolution to match preview config but letting
            // CameraX optimize for whatever specific resolution best fits requested capture mode
            setTargetAspectRatio(Rational(3,4))
            // Set initial target rotation, we will have to call this again if rotation changes
            // during the lifecycle of this use case
            setTargetRotation(viewFinder.display.rotation)
        }.build()
imageCapture.takePicture(object : ImageCapture.OnImageCapturedListener() {
             override fun onCaptureSuccess(image: ImageProxy?, rotationDegrees: Int) {
                        println("captureSuccess h: ${image?.height} w: ${image?.width}")
                    }
             override fun onError(imageCaptureError: ImageCapture.ImageCaptureError, message: String, cause: Throwable?) {
                        println(message)
             }
          })

以上是我为从三星 S8 美国版捕获图像设置的代码,我想要最大输出分辨率为 3264*2448 的 YUV 格式。但是,我得到的结果是 1440*1080 。我试过 S9 和 S8 亚洲版,代码在两部手机上都可以正常工作。奇怪的是,当我将格式设置为 JPEG 时,它可以在这款手机上使用。

我也尝试过 S7 和像素 2,像素 2 可以以最大支持的分辨率输出 YUV(不是上面的代码),但 S7 不能,也给了我 1080*1440。

这是一个 CameraX 错误吗?如果是,除了使用回到Camera2之外还有其他解决方法吗?

谢谢!

4

1 回答 1

0

我没有特定的设备来验证这一点,但相机可以产生比 YUV 更好的 Jpeg 分辨率的情况并不少见。另一方面,请参阅相关问题的答案。

于 2019-10-04T03:49:30.267 回答