gpt4 book ai didi

android - 如何拍摄手动设置了包括闪光灯在内的所有设置而又不丢失包含全闪光灯的图像的照片?

转载 作者:行者123 更新时间:2023-12-02 12:25:41 27 4
gpt4 key购买 nike

我使用最新的Camera2Basic示例程序作为试验的源:
https://github.com/android/camera-samples.git
基本上,我在像下面这样在takePhoto()函数中调用capture()函数之前,先配置了CaptureRequest:

    private fun prepareCaptureRequest(captureRequest: CaptureRequest.Builder) {
//set all needed camera settings here
captureRequest.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_OFF)

captureRequest.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
//captureRequest.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_CANCEL);
//captureRequest.set(CaptureRequest.CONTROL_AWB_LOCK, true);
captureRequest.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_OFF);
captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
//captureRequest.set(CaptureRequest.CONTROL_AE_LOCK, true);
//captureRequest.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL);
//captureRequest.set(CaptureRequest.NOISE_REDUCTION_MODE, CaptureRequest.NOISE_REDUCTION_MODE_FAST);

//flash
if (mState == CaptureState.PRECAPTURE){
//captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
captureRequest.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF)
}
if (mState == CaptureState.TAKEPICTURE) {
//captureRequest.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_SINGLE)
//captureRequest.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH);
captureRequest.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_SINGLE)
}

val iso = 100
captureRequest.set(CaptureRequest.SENSOR_SENSITIVITY, iso)

val fractionOfASecond = 750.toLong()
captureRequest.set(CaptureRequest.SENSOR_EXPOSURE_TIME, 1000.toLong() * 1000.toLong() * 1000.toLong() / fractionOfASecond)
//val exposureTime = 133333.toLong()
//captureRequest.set(CaptureRequest.SENSOR_EXPOSURE_TIME, exposureTime)

//val characteristics = cameraManager.getCameraCharacteristics(cameraId)
//val configs: StreamConfigurationMap? = characteristics[CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP]
//val frameDuration = 33333333.toLong()
//captureRequest.set(CaptureRequest.SENSOR_FRAME_DURATION, frameDuration)

val focusDistanceCm = 20.0.toFloat() //20cm
captureRequest.set(CaptureRequest.LENS_FOCUS_DISTANCE, 100.0f / focusDistanceCm)

//captureRequest.set(CaptureRequest.COLOR_CORRECTION_MODE, CameraMetadata.COLOR_CORRECTION_MODE_FAST)
captureRequest.set(CaptureRequest.COLOR_CORRECTION_MODE, CaptureRequest.COLOR_CORRECTION_MODE_TRANSFORM_MATRIX)
val colorTemp = 8000.toFloat();
val rggb = colorTemperature(colorTemp)
//captureRequest.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM, colorTransform);
captureRequest.set(CaptureRequest.COLOR_CORRECTION_GAINS, rggb);
}
但是返回的图像永远不会是闪光灯最亮的图像。这是在Google Pixel 2设备上。
由于我只拍摄一张照片,因此我也不确定如何检查某些CaptureResult状态以找到正确的状态,因为只有一种状态。
我已经在这里查看过类似问题的其他解决方案,但是它们要么没有真正解决过,要么以某种方式在我不需要的预览预览中拍摄了照片。
其他奇怪的发现是在不同的设备上拍摄图像(也不总是在正确的时刻),但是在图像的JPEG元数据中没有观察到我设置的手动值。
如果需要,我可以将git fork放在github上。

最佳答案

长时间曝光与闪光灯结合似乎是基本问题,当结果不那么理想时,这意味着预设的时机不是那么理想。您必须根据闪光灯的时间来优化曝光时间的持续时间(只需检查一些照片的EXIF作为示例值)。您可以使用 ImageAnalysis.Analyzer (已从示例应用程序中删除了该亮度,但是旧版本中仍然有一个示例)来测量其亮度。我已经尝试使用默认的摩托罗拉相机应用程序;那里的照片也似乎是在闪光后不久拍摄的,此时亮度已经衰减了(以避免产生刺眼的明亮)。这就是CaptureState.PRECAPTURE,您可以在其中关闭闪光灯。分为两个阶段闪烁是默认设置,这可能会产生更好的结果。
如果您希望它令人眼花bright乱(即使通常不希望这样做),则最好先打开手电筒,使图像再次关闭手电筒(我使用类似的方法,但仅用于条形码扫描) 。这将至少防止任何曝光/闪光时序问题。
如果更改的值未在EXIF中表示,则需要使用ExifInterface进行更新(有一个示例可以更新方向,但是可以更新任何值)。

关于android - 如何拍摄手动设置了包括闪光灯在内的所有设置而又不丢失包含全闪光灯的图像的照片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63938168/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com