tonyt...@google.com
unread,Jan 18, 2021, 10:11:15 PM1/18/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Android CameraX Discussion Group, Vinit Modi, Android CameraX Discussion Group, yang...@nxp.com
You may try Camera2CameraFilter to select the external camera if needed. A basic implementation may looks like below. Note that this is experimental and hasn't been fully verified. Hope it helps!
// Implement a camera filter that selects LENS_FACING_EXTERNAL cameras.
CameraFilter cameraFilter = Camera2CameraFilter.createCameraFilter((cameraInfos) -> {
List<CameraInfo> resultCameraInfos = new ArrayList<>();
for (CameraInfo cameraInfo : cameraInfos) {
Integer lensFacing = Camrea2CameraInfo.from(cameraInfo).getCameraCharacteristic(CameraCharacteristics.LENS_FACING);
if (lensFacing != null && lensFacing == CameraMetadata.LENS_FACING_EXTERNAL) {
resultCameraInfos.add(cameraInfo);
}
}
return resultCameraInfos;
});
// Create a camera selector without specifying lens facing and add the customized camera filter to it. Then use the camera selector to bind to the external camera.
CameraSelector cameraSelector = new CameraSelector.Builder().addCameraFilter(cameraFilter).build();