NAV 2016 - scanning barcode/QR using Android phone and camera?

DoomhammerDoomhammer Member Posts: 211
Hi everyone, does anyone has experience with scanning barcodes/2d codes using Android phone and rear camera?
I tried to use standard NAV functionality to take picture, save it to server and then feed picture to ZXING.net library which has capability to decode barcodes/2d codes. But my solution is not reliable.
I tried to resize bitmap, tried to change camera output quality... nothing helped - scanning of codes is not reliable and only 1/5 attempts resulted in success.
My code:
NAVCamera::PictureAvailable(PictureName : Text;PictureFilePath : Text)
TempPath := FileMgt.ServerTempPath + '\' + PictureName;
FILE.RENAME(PictureFilePath,TempPath);
CLEAR(VtResult);
CLEAR(SystemBitmap);
CLEAR(ZXingBarcodeReader);
CLEAR(ZXingBarcodeResult);
SLEEP(250);

SystemBitmap := SystemBitmap.Bitmap(TempPath);
///resize image if too big
IF SystemBitmap.Height > 1000 THEN BEGIN
BmpHeight := ROUND(SystemBitmap.Height / 5,1,'=');
BmpWidth := ROUND(SystemBitmap.Width / 5,1,'=');
SystemBitmap := SystemBitmap.Bitmap(SystemBitmap,BmpHeight,BmpWidth);

END;

SLEEP(250);

ZXingBarcodeReader := ZXingBarcodeReader.BarcodeReader;
VtResult := ZXingBarcodeReader.Decode(SystemBitmap);
//IF VtResult.ISTEXT THEN
Result := FORMAT(VtResult);
MESSAGE(Result);
//SLEEP(500);
CLEAR(SystemBitmap);
//FileMgt.DeleteServerFile(TempPath);

NET variables:

ZXingBarcodeReader DotNet ZXing.BarcodeReader.'zxing, Version=0.16.0.0, Culture=neutral, PublicKeyToken=830ae994e36ac27d'
ZXingBarcodeResult DotNet ZXing.Result.'zxing, Version=0.16.0.0, Culture=neutral, PublicKeyToken=830ae994e36ac27d'
SystemBitmap DotNet System.Drawing.Bitmap.'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Any help will be appreciated. Thanks a lot.
Martin Bokůvka, AxiomProvis

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    Have you considered a different approach, such as using the phone itself to convert Scan/Picture to text?
    For example, a quick search found Barcode/NFC/OCR Scanner Keyboard. It acts as a keyboard with a function to scan the barcodes into a text field (and uses the same ZXing library you mentioned).
  • DoomhammerDoomhammer Member Posts: 211
    Interesting idea, wil try it. Thank you!
    Martin Bokůvka, AxiomProvis
Sign In or Register to comment.