条形码扫描仪在Glass GDK上不起作用 [英] Barcode Scanner doesn't work on Glass GDK
问题描述
我是Glass GDK开发的新手,扫描条形码时遇到问题.我已经关注过此内容( http://blog.wombatsoftware.de/2014/01/running-zxing-qr-code-engine-on-google.html )发布,但我的条形码扫描仪仍然无法正常工作.它看起来像一张附有照片的照片. 我也查看了 BarcodeEye项目,但我不知道如何集成它与我的项目.你能帮我吗?
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
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
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);
}
推荐答案
在CameraConfiguraionManager
中,您还需要在setDesiredCameraParameters
中添加googleGlassInit(camera)
.
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:我也使用640x360,所以应该不会有问题.
PD: I also use 640x360 so that shouldn't be a problem.
这篇关于条形码扫描仪在Glass GDK上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!