我正在使用Android Camera2 API。我想知道什么时候适合:
我在takePicture.setVisibility(View.GONE)
和lockFocus()
takePicture.setVisibility(View.VISIBLE)
中尝试了unlockFocus()
。
虽然这在大多数时间都有效,但有时按钮会消失并且再也不会出现(当我拍摄照片的过程失败时),特别是当它非常快速地点击它时(一旦它出现在屏幕上)。此时没有错误也没有发生崩溃。
代码取自googlesamples/android-Camera2Basic。
更新
我在takePicture.setVisibility(View.VISIBLE)
内尝试了onCaptureSequenceCompleted
。该按钮确实出现,但点击它时不会重新启动捕获图片的过程(参见this seven-second video)。发生这种情况时,不会调用onCaptureFailed
。但是,由于 STATE_WAITING_PRECAPTURE
不满足STATE_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;
}
答案 0 :(得分:0)
我认为应该是这样
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;
}