How to get Android camera preview data?

后端 未结 3 877
故里飘歌
故里飘歌 2021-01-31 06:13

My camera app displays a camera preview on the screen and also processes it in the background. Here is the relevant code, condensed as much as possible (e.g. no error handling

3条回答
  •  无人及你
    2021-01-31 06:32

    The only problem was that I didn't set the preview width and height:

    params.setPreviewSize(previewWidth, previewHeight);
    mCamera.setParameters(params);
    

    This meant that the height and width I allocated for the array (proportional to previewWidth * previewHeight) tended to be a lot larger than the size of the actual data being returned (proportional to the default preview width and preview height). On some phones, the default was the same size as previewWidth and previewHeight, so there was no issue.

提交回复
热议问题