Reputation: 544
I am trying to read barcode with the help if ZXing library for android. in my app when I click a button I am taken to the barcode reader activity where I read the code with the help if ZXing reader. My app can successfully read QR codes at this point but the problem is I have to hold the camera at a certain distance/angle (not fixed btw) every time. So naturally i am going through a mini workout (exaggeration) while i reading a QR code. Also, i tried turning on the flash, but when i do it becomes more difficult task to read one. I have user mobile vison library which is very fast but it does not have flash light support at this moment (or i may not have found how to turn the flash light on).
I am guessing my problem has something to do with the resolution. the barcode is printed from a machine which uses thermal printer with very low resolution. Since i cannot change the resolution of the printer, is there a way to lower the resolution at which ZXing is reading the barcode?
(PS I got the idea of lower resolution form the fact that Mobile Vision let us change the resolution and I had problems with higher resolution reading).
I would prefer to use Mobile Vision if there is a way to turn the flash light on.
my code for barcode reading class looks like this
private ZXingScannerView mScannerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mScannerView = new ZXingScannerView(this);
mScannerView.setAutoFocus(true);
//mScannerView.setFlash(true);
setContentView(mScannerView);
}
@Override
protected void onResume() {
super.onResume();
mScannerView.setResultHandler(this);
mScannerView.startCamera();
}
@Override
protected void onPause() {
super.onPause();
mScannerView.stopCamera();
}
@Override
public void handleResult(Result result) {
if (result.getText() != null) {
Intent qrCodeIntent = new Intent();
qrCodeIntent.putExtra("barcode", result.getText());
setResult(CommonStatusCodes.SUCCESS, qrCodeIntent);
Log.v("Code", result.getText());
Log.v("Code Format", result.getBarcodeFormat().toString());
mScannerView.stopCamera();
finish();
}
}
Upvotes: 4
Views: 10615
Reputation: 6931
I am getting faster experience by setting the following things. I need QR code scan. So, I set IntentIntegrator.QR_CODE.
IntentIntegrator integrator = new IntentIntegrator(activity);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
integrator.setPrompt("Scan");
integrator.setCameraId(0);
integrator.setBeepEnabled(true);
integrator.setBarcodeImageEnabled(false);
integrator.setOrientationLocked(true);
integrator.initiateScan();
I also remove camera auto focus from manifest.
N.B. I am using this library.
Upvotes: 2
Reputation: 4365
If I remember correctly, by default, ZXing uses all formats' filters to check an image against. I mean, it firstly scans if is, for example, EAN13, than if it is UPC-A, and so on until it gets to QR-parser. It is possible to set specific decoders to the ZXing's scanning view. I am sure it will speed scanning process up.
Upvotes: 3