How to use a previewview in camerax?

谁说胖子不能爱 提交于 2020-05-16 02:31:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!