问题描述
我想使用CameraX库捕获具有固定分辨率(即 1200x1600
)的照片。
I want to capture photos with fixed resolution (i.e. 1200x1600
) using CameraX library.
所以根据我可以为 ImageCaptureConfig
设置目标分辨率:
So according to documentation I can set target resolution for ImageCaptureConfig
:
val imageCaptureConfig = ImageCaptureConfig.Builder()
.setLensFacing(CameraX.LensFacing.BACK)
.setCaptureMode(ImageCapture.CaptureMode.MAX_QUALITY)
.setTargetResolution(Size(1200, 1600))
.setTargetAspectRatio(Rational(3,4))
.build()
文档描述 setTargetResolution
方法如下:
目标分辨率尝试为
图像分辨率建立最小范围。实际图像分辨率将是尺寸上最接近的
可用分辨率,且不小于目标
分辨率(由Camera实现确定)。但是,如果不存在等于或大于目标
分辨率的
分辨率,则将选择小于目标
分辨率的最接近的可用分辨率。
The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.
如果我错了,请纠正我,但如果设备能够拍摄大于 1200x1600
的照片(例如 3024x4032
),输出的照片将至少为 1200x1600
。
Correct me if I am wrong, but if device is able to take photos larger than 1200x1600
(e.g. 3024x4032
), the output photo will be at least 1200x1600
.
不幸的是,在许多设备中(例如 Huawei P20 Pro
, Samsung A5
),输出的照片明显小于 1200x1600
,例如 480x640
。请注意,这些设备能够拍摄非常大的照片。
Unfortunately in many devices (e.g. Huawei P20 Pro
, Samsung A5
) the output photo is significantly smaller than 1200x1600
, e.g. 480x640
. Notice that these devices are able to take really large photos.
我的 ImageCaptureConfig
是否配置错误,或者这是一个错误?
Is my ImageCaptureConfig
badly configured or this is a bug?
推荐答案
这可能是AOSP最近修复的错误。
引用
It could be a bug that have been recently fixed at AOSP.refer https://android.googlesource.com/platform/frameworks/support/+/5c1aed8c4c502a74eb4ee6d30fe2089f4afcaf11
这篇关于设置CameraX的目标分辨率不如文档中所述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!