三星 Galaxy S5 相机闪光灯问题 [英] Samsung Galaxy S5 Camera Flash Problems

查看:16
本文介绍了三星 Galaxy S5 相机闪光灯问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款具有自定义相机功能的应用.相机在 Galaxy S3、S4、HTC、Nexus 上运行良好,但在 S5 上,所有需要闪光灯的照片都变暗了.照片在预览中看起来很好,闪光灯闪光,但传感器捕捉到的总是太暗,好像闪光灯从未闪光过,或者闪光灯闪光和拍摄图像发生在不同的时间.闪光灯可以设置为自动或常亮,效果相同.我试过 FOCUS_MODE_CONTINUOUS_PICTURE 和 FOCUS_MODE_AUTO,结果相同.

I am working on an app with custom Camera functionality. The Camera is working fine on the Galaxy S3, S4, HTC, Nexus, but on the S5, all of the photos that require flash come out dark. The photo looks fine in the preview, the flash fires, but what is captured by the sensor is always too dark, as if the flash never fired off, or the firing of the flash and the capturing of the image happened at different times. The flash can be either set to auto or to always on, with the same effect. I've tried FOCUS_MODE_CONTINUOUS_PICTURE and FOCUS_MODE_AUTO, with the same result.

还有人有什么建议可以尝试吗?

Does anyone have any suggestions what else to try?

谢谢你,加里

推荐答案

这里似乎有两个不相关的错误,一个在 Nexus 4 上,另一个在三星 S5 上.它们似乎都表现为同一个问题,在弱光条件下使用闪光灯拍摄的照片看起来非常暗,但根本原因却截然不同.

It seems like there are 2 unrelated bugs here, one on the Nexus 4, the other on the Samsung S5. They both seem to manifest as the same issue, pictures taken in low light conditions with the flash on appear extremely dark, but have very different root causes.

在结合闪光灯使用连续对焦时,Nexus 4 会中断.这似乎是一个 相对众所周知的问题,唯一的解决方案似乎是改用 FOCUS_MODE_AUTOFOCUS_MODE_CONTINUOUS_PICTURE.根本原因似乎与在闪光灯有机会触发之前过早拍照有关.

The Nexus 4 breaks when using continuous focus in conjunction with the flash. This seems like a relatively well known issue and the only solution seems to be to use FOCUS_MODE_AUTO instead of FOCUS_MODE_CONTINUOUS_PICTURE. The root cause seems to be related to taking the picture too early, before the flash gets a chance to fire.

据我所知,Nexus 4 是唯一需要这种特殊外壳的设备(即,它报告支持 FOCUS_MODE_CONTINUOUS_PICTURE 但严重损坏).

As far as I know, the Nexus 4 is the only device that needs this kind of special casing (i.e. it reports supporting FOCUS_MODE_CONTINUOUS_PICTURE but breaks horribly with it).

// dummy method, replace with wherever you setup camera params
public void onCameraOpened(Camera camera) {
    Camera.Parameters params = camera.getParameters();

    setFocusModeParameter(
        params,
        Build.MODEL.equals("Nexus 4")
            ? new String[] {
                Camera.Parameters.FOCUS_MODE_AUTO
            }
            : new String[] {
                Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE,
                Camera.Parameters.FOCUS_MODE_AUTO,
            }
    );

    camera.setParameters(params);
}

public static void setFocusModeParameter(Camera.Parameters params, String... preferences) {
    List<String> supported_focus_modes = params.getSupportedFocusModes();
    if (supported_focus_modes == null) {
        return;
    }

    for (String pref : preferences) {
        if (supported_focus_modes.contains(pref)) {
            params.setFocusMode(pref);
            return;
        }
    }
}

三星 S5

与 Nexus 4 不同,三星 S5 似乎落后于闪光灯,导致画面变暗.据我所知,打开隐藏的零快门延迟参数(以稳健部分中描述的安全方式)似乎对以下设备没有不良影响:Nexus 4、Nexus 5、Samsung S3、Samsung S4、SamsungGalaxy Tab S (SM-T700).

Samsung S5

Unlike the Nexus 4, the Samsung S5 seems to lag behind the flash which causes a dark picture. As far as I can tell, turning on the hidden zero shutter lag parameter (in the safe manner described in the robust section) seems to have no ill effects on the following devices: Nexus 4, Nexus 5, Samsung S3, Samsung S4, Samsung Galaxy Tab S (SM-T700).

尝试设置以下隐藏摄像头参数,似乎可以解决我的S5上的问题.

Try setting the following hidden camera parameter, which seems to solve the problem on my S5.

Camera.Parameters params = camera.getParameters();
params.set("zsl", "on");
camera.setParameters(params);

更强大的解决方案

如果上面的解决方案有效,我将使用一种更可靠的方法来检测 zsl 参数何时可用:

// dummy method, replace with whatever sets up camera parameters
public void onCameraOpened(Camera camera) {
    Camera.Parameters params = camera.getParameters();
    setHiddenParameter(params, "zsl-values", "zsl", "on");
    camera.setParameters(params);
}

public static void setHiddenParameter(Camera.Parameters params, String values_key, String key, String value) {
    if (params.get(key) == null) {
        return;
    }

    String possible_values_str = params.get(values_key);
    if (possible_values_str == null) {
        return;
    }

    String[] possible_values = possible_values_str.split(",");
    for (String possible : possible_values) {
        if (possible.equals(value)) {
            params.set(key, value);
            return;
        }
    }
}

说明

这部分只是为了记录兔子洞找到这个参数,希望比我了解更多的人可以扩展.

Explanations

This part is only here to document the rabbit hole to find this parameter, hopefully someone that knows more than me can expand on this.

症状:

  • 在三星 S5 上,在极暗条件下使用闪光灯设置为 FLASH_MODE_ONFLASH_MODE_AUTO 拍照会导致照片变暗或全黑.
  • 这似乎在我测试过的任何其他设备(Nexus 4、Nexus 5、Samsung S3、Samsung S4)上都没有发生
  • 如果我在一个完全黑暗的房间里靠近物体(约 3 英尺)拍照,我会得到一张极其黑暗的照片,只有少数东西可见.
  • 如果我在一个完全黑暗的房间内的开放空间(>5 英尺)前拍照,我会得到一张全黑的照片.
  • On the Samsung S5, taking pictures in extremely dark conditions with the flash set to FLASH_MODE_ON or FLASH_MODE_AUTO leads to dark or completely black photos.
  • This does not seem to happen on any other device I have tested (Nexus 4, Nexus 5, Samsung S3, Samsung S4)
  • If I take pictures standing close to the objects (~3 ft) in a completely dark room, I get a extremely dark picture with only a few things visible.
  • If I take pictures in front of an open space (>5 ft) in a completely dark room, I get a completely black picture.

我尝试的第一件事是搞乱焦点相关设置,理由是开放空间会导致焦点花费更长的时间,从而搞乱使用闪光灯拍照的时间.FOCUS_MODE_AUTOFOCUS_MODE_CONTINUOUS_PICTURE 似乎都无济于事.

The first thing I tried was messing with focus related settings, reasoning that the open space would cause the focus to take longer, thus messing with the timing of taking the picture with the flash. Neither FOCUS_MODE_AUTO nor FOCUS_MODE_CONTINUOUS_PICTURE seemed to help the situation.

我还尝试在调用 camera.takePicture(...) 之前锁定自动曝光和自动白平衡调整,以确保这些进程不会导致闪光灯计时关闭,但确实如此似乎也没有帮助.

I also tried locking the auto-exposure and auto-whitebalance adjustments before calling camera.takePicture(...) to make sure those process weren't throwing the flash timing off, but that did not seem to help either.

不过感觉还是时间问题,所以我开始比较我的应用使用的参数与原生相机应用之间的参数差异.

It still felt like a timing issue though, so I started comparing the difference in parameters between the parameters my app was using vs. the native camera app.

12-10 15:49:08.659: W/QCameraParameters(265): [FW_DBG] setFirmwareMode: none
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] Requested preview size 1920 x 1080
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] dualrecording-hint : 0 m_FaceAE=1 Camera ID=0
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] Requested video size 1920 x 1080
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] Requested picture size 2048 x 1152
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] Requested FOV 62.000000
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] requested jpeg thumbnail size 512 x 288
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] set optimal jpeg thumbnail size 512 x 288
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] rotation val = 90
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] m_bNoDisplayMode = 0
12-10 15:49:08.659: W/QCameraParameters(265): setZslMode : m_nDualMode=0, mHdrMode=0, mTakeLowlight=0, m_bRecordingHint=0, mAutoLLS=0, m_nDualRecordingHint=0
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] ZSL = ON
12-10 15:49:08.659: I/QCameraParameters(265): [PARM_DBG] Requested FpsRange Values:(15000, 30000)
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] flash mode = on
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] AEC lock = false
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] AWB lock = false
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] mHdrMode 0 mTakeLowlight 0
12-10 15:49:08.659: E/QCameraParameters(265): SAMSUNG APPS HDR MODE
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] live snapshot size 2048 x 1152
12-10 15:49:08.659: E/QCameraParameters(265): [syscamera][setRthdrModes::2831][str::off][prev_str::off]
12-10 15:49:08.659: E/QCameraParameters(265): [syscamera][setPafModes::2863][str::on][prev_str::on]
12-10 15:49:08.659: E/QCameraParameters(265): [syscamera][setDrcModes::2891][str::on][prev_str::on]
12-10 15:49:08.659: W/QCameraParameters(265): updateParameters : X - mCameraId=0, final_rc=0, line=4465
12-10 15:49:08.659: W/QCameraParameters(265): [PARM_DBG] setNumOfSnapshot : nBurstNum = 1, nExpnum = 1

我的应用

12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] Requested preview size 1920 x 1080
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] dualrecording-hint : 0 m_FaceAE=1 Camera ID=0
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] Requested video size 1920 x 1080
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] Requested picture size 2048 x 1152
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] Requested FOV 62.000000
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] requested jpeg thumbnail size 512 x 288
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] set optimal jpeg thumbnail size 512 x 288
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] m_bNoDisplayMode = 0
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] ZSL = off
12-10 15:48:33.109: I/QCameraParameters(265): [PARM_DBG] Requested FpsRange Values:(10000, 30000)
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] flash mode = on
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] AEC lock = false
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] AWB lock = false
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] mHdrMode 0 mTakeLowlight 0
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] live snapshot size 2048 x 1152
12-10 15:48:33.109: E/QCameraParameters(265): [syscamera][setPafModes::2863][str::off][prev_str::off]
12-10 15:48:33.109: E/QCameraParameters(265): [syscamera][setDrcModes::2891][str::off][prev_str::off]
12-10 15:48:33.109: W/QCameraParameters(265): updateParameters : X - mCameraId=0, final_rc=0, line=4465
12-10 15:48:33.109: W/QCameraParameters(265): [PARM_DBG] setNumOfSnapshot : nBurstNum = 1, nExpnum = 1

本机与我的应用

AEC(自动曝光)和 AWB(白平衡)线是相同的,所以这与我之前尝试过的一致.一个区别是 ZSL 参数,我以前从未听说过.

Native vs. My App

The AEC (auto exposure) and AWB (white balance) lines are the same, so that's consistent with what I've tried before. The one difference is the ZSL parameter, which I've never heard of before.

谷歌搜索 ZSL 发现这个 SO answer:

Googling for ZSL finds this SO answer:

要实现零快门延迟,相机驱动程序必须维护一个包含全分辨率帧的小型圆形缓冲池.图像以传感器速率捕获并发送到预览和循环缓冲池(作为原始拜耳或处理/半处理 YUV).当用户按下快门时,循环池中的最新缓冲区被提取、处理和压缩为JPEG.在较旧的手机摄像头上,传感器无法以足够高的帧速率捕获全分辨率帧,因此无法实现 ZSL.

To achieve zero shutter lag, the camera driver must maintain a small circular buffer pool containing full resolution frames. Images are captured at sensor rate and are sent to preview and to the circular buffer pool (either as raw Bayer or as processed/semi-processed YUV). When the use presses the shutter, the newest buffer in the circular pool is extracted, processed and compressed as JPEG. On older mobile phone cameras, the sensor is not able to capture full resolution frames at a high enough frame rate, and therefore ZSL cannot be implemented.

因此,快门延迟似乎导致闪光灯闪光和拍摄照片之间的时间不匹配.打开 ZSL 似乎完全消除了这个问题.考虑到没有它会破坏 Flash 行为,它可能应该默认打开,但我不会屏住呼吸.

So it seems like the shutter lag causes a timing mismatch between when the flash fires and when the picture is captured. Turning on ZSL seems to eliminate the issue entirely. It should probably be on by default given that flash behaviour is broken without it, but I'm not going to hold my breath on that one.

这篇关于三星 Galaxy S5 相机闪光灯问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆