Intro
Optical Barcode Recognition (OBR) or Optical Character Recognition (OCR) technology has been utilized in many commercial applications. The fonts are electronically scanned and digitized into ASCI characters. Hand-held scanners also allow the user to have the ability to examine data, for instance, locating and reading the International Standard Book Number (ISBN) found on most published books, which is usually printed on the back cover.
So, in this tutorial, you will learn how to scan the optical barcode with your Delphi/C++ Builder VCL applications.
OBR Library by WINSOFT can scan optical barcodes for you quickly and fast. It uses ZXing.Net and supports a wide variety of visual barcode types. For example, UPC-A, UPC-E, EAN-8, EAN-13, Code 39, Code 93, Code 128, Codabar, ITF, RSS-14, RSS-Expanded, QR Code, Data Matrix, Aztec, PDF 417 and Pharmacode barcodes.
This is a commercial library that has a trial version with all features for evaluation only, and if you wish to distribute this library as a part of your project, you should get a license.
Specifications
- Supports Windows 32-bit & Windows 64-bit
- Available for Delphi & C++ Builder 6-10.4 VCL
Development
When you have the library for your development, everything gets easy. There are tens of thousands of applications that utilize Visual Component Library as a primary weapon. Moreover, the VCL community is massive, and there are enough libraries to do any kind of job.
For instance, in this case, suppose you want to develop an application that can scan any type of optical barcodes. You can rely on the OBR Library here.
We have a demo that shows how we can implement such an application. After configuring your development environment you need to declare required units to work with the OBR library.
1 2 3 4 5 6 7 |
uses JPEG, ObrLib {$ifdef CONDITIONALEXPRESSIONS} {$if CompilerVersion >= 30} // Delphi 10 , GIFImg, PngImage {$ifend} {$endif} ; |
Here is our user interface. There is one button which triggered to open the open dialog box to select a barcode image. After loading the picture, it starts to get the result.
So we have only one event and here is the implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
procedure TFormMain.ButtonSelectPictureClick(Sender: TObject); var Barcodes: TDecodeResults; begin Barcodes := nil; // to avoid warning message with OpenPictureDialog do if Execute then begin Memo.Clear; Image.Picture.LoadFromFile(FileName); with TBarcodeDecoder.Create do try Barcodes := Decode(Image.Picture.Graphic); if Length(Barcodes) = 0 then Memo.Lines.Append('No barcode found') else for var I: Integer := 0 to Length(Barcodes) - 1 do Memo.Lines.Append(Barcodes[I].FormatName + ': ' + Barcodes[I].Text); finally Free; end; end; end; |
The TDecodeResults record has Text, Format, FormatName, and Points fields. TBarcodeDecoder is the main class here, which controls all the process for you.
First, it decodes the loaded image. If there is no barcode, it displays the “No barcode found” message. Or it starts to iterate over parsed barcodes from the Barcodes variable and prints all the available results in the TMemo component.
Here’s a quick video of the component and its code in action:
As you can see with this OBR Library by WINSOFT, it is swift and straightforward.
Like what you see? You can get Optical Barcode Recognition and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4 today!
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
Hi. I Used the Winsoft FCamera and FOBR Component. But it doesn’t seem to read the PDF417 code but reads the QRCode successfully.