问题
i can't find out in CameraX how to use the PreviewView .
i get this problem e/camera unable to configure camera 0 timeout
回答1:
Could you post your code sample please? I had the same timeout error, but even after setting the implementation mode it still remains..
回答2:
i find out that the code miss this method previewView.setsetImplementationMode
that is not mention in android guide document
PreviewView previewView = view.findViewById(R.id.preview_view);
previewView.setImplementationMode(PreviewView.ImplementationMode.SURFACE_VIEW);
Preview preview = new Preview.Builder().setTargetAspectRatio(AspectRatio.RATIO_16_9).
setTargetRotation(previewView.getDisplay().getRotation()).setTargetName("Preview").build();
preview.setSurfaceProvider(previewView.getPreviewSurfaceProvider());
CameraSelector cameraSelector =
new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();
cameraProvider.unbindAll();
cameraProvider.bindToLifecycle(this, cameraSelector, imageCapture(), imageAnalyser(), preview);
I hope it help .
回答3:
Here is an article that explains PreviewView
and how to use it. It's valid up to version 1.0.0-alpha10 of camera-view, I'll try to keep it up to date.
来源:https://stackoverflow.com/questions/60301296/how-to-use-a-previewview-in-camerax