Google Glass preview image scrambled with new XE10 release

依然范特西╮ 提交于 2019-11-27 11:49:19
Tony Allevato

For now, please try adding the following workaround after you acquire the Camera but before you setup and start the preview:

Camera.Parameters params = camera.getParameters();
params.setPreviewFpsRange(30000, 30000);
camera.setParameters(params);

(Or just add the setPreviewFpsRange call to your existing parameters if you're setting others as well.)

For anyone using ZXing on their Glass, you can build a version from the source code with the above fix.

Add the following method into CameraConfigurationManager.java

  public void googleGlassXE10WorkAround(Camera mCamera) {
        Camera.Parameters params = mCamera.getParameters();
        params.setPreviewFpsRange(30000, 30000);
        params.setPreviewSize(640,360);
        mCamera.setParameters(params);
  }

And call this method immediately after anywhere you see Camera.setParameters() in the ZXing code. I just put it in two places in the CameraConfigurationManager and it worked.

I set the Preview Size to be 640x360 to match the Glass resolution.

30 FPS preview is pretty high. If you want to save some battery and CPU, consider the slowest supported FPS to be sufficient:

List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
int[] minimumPreviewFpsRange = supportedPreviewFpsRanges.get(0);
parameters.setPreviewFpsRange(minimumPreviewFpsRange[0], minimumPreviewFpsRange[1]);

The bug still exists as of XE16 and XE16.11 but this code gets past the glitch and shows a normal camera preview, note the three parameter setting lines and their values. I have also tested this at 5000 (5FPS) and it works, and at 60000 (60FPS) and it does not work:

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        if (mCamera == null) return;

        Camera.Parameters camParameters = mCamera.getParameters();
        camParameters.setPreviewFpsRange(30000, 30000);
        camParameters.setPreviewSize(1920, 1080);
        camParameters.setPictureSize(2592, 1944);
        mCamera.setParameters(camParameters);
        try {
            mCamera.startPreview();
        } catch (Exception e) {
            mCamera.release();
            mCamera = null;
        }
    }

This still is an issue as of XE22 (!) Lowering the frames per second to 30 or lower does the trick:

 parameters.setPreviewFpsRange(30000, 30000);

And indeed, don't forget to set the parameters:

camera.setParameters(parameters);

I have found no clear explanation as to why this causes trouble, since 60 fps is included in the supported fps range. The video can record 720p, but I never saw a source add the fps to this.

Chandra

You can set the params.setPreviewSize(1200,800). You can change the values around this range until you can clear color noise.

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