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

Doomhammer
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.
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
0
Answers
-
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).0 -
Interesting idea, wil try it. Thank you!Martin Bokůvka, AxiomProvis0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions