Yes, It has 2 modes but I am in video mode in the recording I sent you. I added that white image shutter button on the start of the row component in video mode myself. It wasn't out of box. I believe the front cam image is being provided using the greenscreen effect? I am trying to understand why we do not get illegal exception since we have attached more than 2 use cases to useCaseGroupBuilder. Attaching code for more clarity.
if (effectMode == EffectMode.GREEN_SCREEN) {
// Concurrent camera setup for green screen effect
var primaryCameraSelector: CameraSelector? = null
var secondaryCameraSelector: CameraSelector? = null
// Iterate through available concurrent camera infos to find suitable primary
// (front-facing) and secondary (back-facing) cameras.
for (cameraInfos in cameraProvider.availableConcurrentCameraInfos) {
primaryCameraSelector = cameraInfos.first {
it.lensFacing == CameraSelector.LENS_FACING_FRONT
}.cameraSelector
secondaryCameraSelector = cameraInfos.first {
it.lensFacing == CameraSelector.LENS_FACING_BACK
}.cameraSelector
if (primaryCameraSelector == null || secondaryCameraSelector == null) {
// If either a primary or secondary selector wasn't found, reset both
// to move on to the next list of CameraInfos.
primaryCameraSelector = null
secondaryCameraSelector = null
} else {
// If both primary and secondary camera selectors were found, we can
// conclude the search.
break
}
}
if (primaryCameraSelector != null && secondaryCameraSelector != null) {
//preview and video use cases have already been added before. Adding effect and image capture use case
useCaseGroupBuilder.addEffect(greenScreenEffect)
useCaseGroupBuilder.addUseCase(imageCaptureUseCase)
val segmentedSelfieUseCaseGroupBuilder = UseCaseGroup.Builder()
.addUseCase(imageAnalysisUseCase)
val primary = ConcurrentCamera.SingleCameraConfig(
primaryCameraSelector,
segmentedSelfieUseCaseGroupBuilder.build(),
lifecycleOwner,
)
val secondary = ConcurrentCamera.SingleCameraConfig(
secondaryCameraSelector,
useCaseGroupBuilder.build(),
lifecycleOwner,
)
cameraProvider.unbindAll()
val concurrentCamera = cameraProvider.bindToLifecycle(
listOf(primary, secondary),
)
return@launch
}
}