From Camera2Basic example, I modified the code to make the program continuously takes still photo every 2 seconds. It runs fine but after a while it enters the same statecallback condition and does not take picture anymore:
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;
}
else
{
Log.e(TAG,"aeState = " + aeState);
}
break;
}
The log keeps printing aeState = 2, which is CONTROL_AE_STATE_CONVERGED. My question is why the code does nothing when the AE is converged? Why not change state to STATE_WAITING_NON_PRECAPTURE?
I mean why not doing this instead?
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_CONVERGED ||
aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE ||
aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED) {
mState = STATE_WAITING_NON_PRECAPTURE;
}
else
{
Log.e(TAG,"aeState = " + aeState);
}
break;
}
ps: Where should I call takePicture() if I want to take photo every 2 seconds? Currently I call it in the CaptureCallback, but look like there some race condition because the CaptureCallback is in the background thread.
Thanks.