Is there any documentation you guys can help me drive me in the direction? I've only VERY recently implemented AndroidX as I was using the old Camera framework.
I've only found one lead and it was a dead end. I guess I would like to be notified when the camera is focusing and/or when it is focused.
Edit: This is my code block where I setup and configure my camera:
Size screen = new Size(txView.getWidth(), txView.getHeight()); //size of the screen
Preview preview = new Preview.Builder()
// We request aspect ratio but no resolution
.setTargetResolution(screen)
// Set initial target rotation
.setTargetRotation(getWindowManager().getDefaultDisplay().getRotation())
.build();
ImageCapture imageCapture = new ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY)
// We request aspect ratio but no resolution to match preview config, but letting
// CameraX optimize for whatever specific resolution best fits our use cases
.setTargetResolution(screen)
// Set initial target rotation, we will have to call this again if rotation changes
// during the lifecycle of this use case
.setTargetRotation(getWindowManager().getDefaultDisplay().getRotation())
.build();
ImageAnalysis imageAnalyzer = new ImageAnalysis.Builder()
.setTargetResolution(screen)
.setTargetRotation(getWindowManager().getDefaultDisplay().getRotation())
.build();
CameraSelector cameraSelector =
new CameraSelector.Builder()
.requireLensFacing(CameraSelector.LENS_FACING_BACK)
.build();
int count = 0;
cameraProviderFuture.addListener(new Runnable() {
@Override
public void run() {
try {
ProcessCameraProvider cameraProvider = cameraProviderFuture.get();
cameraProvider.unbindAll();
androidx.camera.core.Camera camera = cameraProvider.bindToLifecycle(
MainActivity.this,
cameraSelector,
preview,
imageAnalyzer,
imageCapture
);
preview.setSurfaceProvider(txView.createSurfaceProvider(camera.getCameraInfo()));
onCreateTime = System.currentTimeMillis()/1000;
} catch (Exception e) {
}
}
}, ContextCompat.getMainExecutor(this));
Thank you all!