2

I am new to Glass GDK development and I have a problem with scanning a barcode. I have followed this(http://blog.wombatsoftware.de/2014/01/running-zxing-qr-code-engine-on-google.html) post but my barcode scanner still doesn't work. it looks like a photo attached. I had a look also on BarcodeEye project but I don't understand how can I integrate it with my project. Can you please help me?

CameraConfiguration

   public void googleGlassInit(Camera camera) {
      Camera.Parameters params = camera.getParameters();
      params.setPreviewFpsRange(30000, 30000);
      params.setPreviewSize(640,360);
      camera.setParameters(params);
    }
    void setTorch(Camera camera, boolean newSetting) {
        Camera.Parameters parameters = camera.getParameters();
        doSetTorch(parameters, newSetting, false);
        camera.setParameters(parameters);
        googleGlassInit(camera); // added this line
       // googleGlassXE10WorkAround(camera);
    }
...

MainActivity.java

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
         intent.setPackage("com.google.zxing.client.android");
         intent.putExtra("SCAN_MODE","QR_CODE_MODE");
         startActivityForResult(intent,0);  

        }

        //when a QR code is read, it will send a result code 
            protected void onActivityResult(int requestCode, int resultCode,
            Intent data) {
             if (requestCode == 0 && resultCode == RESULT_OK){
                String contents = data.getStringExtra("SCAN_RESULT");
                Card card1 = new Card(this);
                card1.setText(contents);
                card1.setFootnote("zxing");
                View card1View = card1.getView();
                setContentView(card1View);
            //    setDisplayCard(card1);

            }
            super.onActivityResult(requestCode, resultCode, data);

    }

enter image description here


lucy
  • 65
  • 8

2 Answers2

0

Google Glass unfortunately does not actually support all of the frame rate / resolution combinations that it implies that it does within the supported camera parameters it exposes. If you choose settings that are not actually supported, you get a display like this often.

This got a lot better in XE16.2 but still happens for high resolutions.

You can take some inspiration from the camera config in this port of the Barcode Scanner app from the original project to Glass, which works:

https://github.com/zxing/zxing/blob/master/glass/src/com/google/zxing/client/glass/CameraConfigurationManager.java

1280 x 720 at 10fps seems fine.

Sean Owen
  • 66,182
  • 23
  • 141
  • 173
0

In CameraConfiguraionManager you also need to add googleGlassInit(camera) in setDesiredCameraParameters.

parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
camera.setParameters(parameters);
googleGlassInit(camera); // added this line

Camera.Parameters afterParameters = camera.getParameters();
Camera.Size afterSize = afterParameters.getPreviewSize();

I hope this help you! This works for me :)

PD: I also use 640x360 so that shouldn't be a problem.

Bae
  • 892
  • 3
  • 12
  • 26
  • I added it also there, but still the same. – lucy May 13 '14 at 14:08
  • now I can see the camera normally , but I don't see the yellow dots on red line of the scanner. It doesn'T do anything when I put camera to the barcode. Do you know what can ba a reason? – lucy May 15 '14 at 14:16
  • @lucy : I haven't change anything else that CameraConfigurationManager and i am able to see yellow dots on red line :S. Although you don't see those yellow dots, Can you get to scan QR codes?. If my answer didn't work for your two days ago, what did you do for today it's work? – Bae May 15 '14 at 15:34
  • no, it doesn't scan anything. just shows the scanner. I added ` ` this code to my manifest file , and then uninstalled the zxing scanner from my glass and tried again.it worked. – lucy May 15 '14 at 15:47