I'm trying to take 10 with an interval of about 1 second using the camera2 API.
I have the following createCaptureSession
to successfully create 10 capture requests, but where do I add the interval?
cameraDevice.createCaptureSession(outputSurfaces, new CameraCaptureSession.StateCallback() {
@Override
public void onConfigured(CameraCaptureSession session) {
try {
for (int i =0; i < 10;i++) {
session.capture(captureBuilder.build(), captureListener, null);
}
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
@Override
public void onConfigureFailed(CameraCaptureSession session) {
System.out.println("ConfigurationFailed");
}
}, mBackgroundHandler);
I have done this using Camare2Basic example. You have to modify
lockFocus()
function add something like this:try { Thread.sleep(CAPTURE_WAITING_TIME_MILISECOND); } catch (InterruptedException e) { e.printStackTrace(); }
on
onImageAvailable
you need to calltakePicture()
if image count is not 10. or it is better to call it onImageSaver
's callback.The interval cannot be exact time. it may change depending on the processing time.
Hope it helps