Skip to content

Commit

Permalink
Add alternative takePicture method to support custom thread executor.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 687351452
  • Loading branch information
MediaPipe Team authored and copybara-github committed Oct 18, 2024
1 parent a460350 commit 24bc37c
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,24 @@ public void startCamera(
* @param onImageSavedCallback Callback to be called for the newly captured image.
*/
public void takePicture(File outputFile, OnImageSavedCallback onImageSavedCallback) {
takePicture(outputFile, onImageSavedCallback, imageCaptureExecutorService);
}

/**
* Captures a new still image and saves to a file along with application specified metadata. This
* method works when {@link CameraXPreviewHelper#startCamera(Activity, ImageCapture.Builder,
* CameraFacing, Size)} has been called previously enabling image capture. The callback will be
* called only once for every invocation of this method.
*
* @param outputFile Save location for captured image.
* @param onImageSavedCallback Callback to be called for the newly captured image.
* @param executorService Executor service to handle image capture.
*/
public void takePicture(
File outputFile, OnImageSavedCallback onImageSavedCallback, ExecutorService executorService) {
if (isImageCaptureEnabled) {
OutputFileOptions outputFileOptions = new OutputFileOptions.Builder(outputFile).build();
imageCapture.takePicture(
outputFileOptions, imageCaptureExecutorService, onImageSavedCallback);
imageCapture.takePicture(outputFileOptions, executorService, onImageSavedCallback);
}
}

Expand Down

0 comments on commit 24bc37c

Please sign in to comment.