Google Glass preview image scrambled with new XE10 release
Asked Answered
D

6

25

This occurs using a few apks that make use of the camera (e.g., zxing, opencv). It displays a glitched image in the preview but it is still a function of what the camera sees so it appears to be an encoding mismatch. The native camera preview works fine, so the internal apps do not exhibit this problem.

Datura answered 7/10, 2013 at 21:53 Comment(1)
This bug still exists as of XE12.Discommend
D
32

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.)

Deweydewhirst answered 8/10, 2013 at 19:54 Comment(1)
30FPS seems a bit too high. I recommend something lower, 5FPS, especially for a battery hungry device like Glass.Courtund
W
8

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.

Wheelock answered 17/10, 2013 at 18:29 Comment(1)
30FPS seems to be a lot, and the 640x360 preview size is not needed to fix the problem. The problem was the default FPS was too high at 60FPS. See my answer below...Courtund
C
4

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]);
Courtund answered 27/1, 2014 at 15:33 Comment(2)
I don't know why someone voted this down. This is fact the exact code that ZXing accepted as a Pull Request from me to fix the problem: github.com/zxing/zxing/commit/…Courtund
Works for me. Best answer here IMO.Hayrick
P
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;
        }
    }
Plummet answered 29/4, 2014 at 3:25 Comment(1)
did you change zxing lib? What class did you put this code inside? Could you show more? In my implementation I don't have access to the camera class...Bunny
I
0

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.

Integral answered 8/4, 2015 at 16:18 Comment(0)
O
-2

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

Otalgia answered 10/10, 2013 at 2:37 Comment(1)
This does not fix the problem.Courtund

© 2022 - 2024 — McMap. All rights reserved.