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.
-
5This bug still exists as of XE12. – squidpickles Dec 20 '13 at 19:22
6 Answers
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.)

- 54,294
- 25
- 151
- 185

- 6,429
- 1
- 29
- 34
-
30FPS seems a bit too high. I recommend something lower, 5FPS, especially for a battery hungry device like Glass. – swooby Feb 13 '14 at 01:25
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.

- 432
- 3
- 9
-
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... – swooby Feb 13 '14 at 01:21
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]);

- 3,005
- 2
- 36
- 43
-
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: https://github.com/zxing/zxing/commit/9e08da655eb6d5423b286f83aa356230536b13a5 – swooby Feb 13 '14 at 01:13
-
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;
}
}

- 2,963
- 1
- 20
- 23
-
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... – Anthea Feb 05 '16 at 08:21
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.

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