gpt4 book ai didi

android - 使用 Android Camera2,应用会无限期地卡在 STATE_WAITING_PRECAPTURE 或 STATE_WAITING_NON_PRECAPTURE

转载 作者:行者123 更新时间:2023-11-29 23:56:52 26 4
gpt4 key购买 nike

我正在使用 Android Camera2 API .我想知道什么时候是合适的时间:

  1. 最初显示TakePicture 按钮(即相机已准备好拍摄一张照片)。
  2. 再次显示此按钮(如果拍照过程失败,当然还有完成时),因为我在单击它(拍摄照片)时将其隐藏。

我在 lockFocus() 中尝试了 takePicture.setVisibility(View.GONE) ,在 中尝试了 takePicture.setVisibility(View.VISIBLE) >解锁焦点()。虽然这在大多数情况下都有效,但有时按钮会消失并且再也不会出现(我猜是在拍照过程失败时),尤其是在非常快速地单击它时(只要它出现在屏幕上)。此时没有错误,也没有发生崩溃。

代码取自googlesamples/android-Camera2Basic .

更新:

我在 onCaptureSequenceCompleted 中尝试了 takePicture.setVisibility(View.VISIBLE)。该按钮确实出现,但在单击它时不会重新启动捕获图片的过程(参见 this seven-second video )。发生这种情况时,不会调用 onCaptureFailed。但是,它会无限期地卡在 STATE_WAITING_PRECAPTURESTATE_WAITING_NON_PRECAPTURE 因为 aeState 这不会'满足if条件。

           case STATE_WAITING_PRECAPTURE: {
// CONTROL_AE_STATE can be null on some devices
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
if (aeState == null ||
aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE ||
aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED) {
mState = STATE_WAITING_NON_PRECAPTURE;
}
break;
}
case STATE_WAITING_NON_PRECAPTURE: {
// CONTROL_AE_STATE can be null on some devices
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
mState = STATE_PICTURE_TAKEN;
captureStillPicture();
}
break;
}

最佳答案

我觉得应该是这样的

 case STATE_WAITING_PRECAPTURE:
{
JQLog.d(TAG, "STATE_WAITING_PRECAPTURE");
// CONTROL_AE_STATE can be null on some devices
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
if (aeState == null
|| aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE
|| aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED
|| aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
state = STATE_WAITING_NON_PRECAPTURE;
}
break;
}

关于android - 使用 Android Camera2,应用会无限期地卡在 STATE_WAITING_PRECAPTURE 或 STATE_WAITING_NON_PRECAPTURE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50282659/

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