- Introduction
OBR (Optical Barcode recognition) is a VCL type library (Windows platform only). Its main purpose is to decode QR code and Barcode images.
In the next short video you will see installation instructions:
2) Components in the Demo and what they do
There are two panels. One is at the top, containing the button for the picture choise. In the middle there is a Scroll box component (for scrolling) and a Timage component inside it for the chosen picture. At the bottom there is another panel again, containing the TMemo component . All combined they create the windows that shows up with button, image and text at the bottom. You can see it in a short video below:
Clicking on the button executes the TOpenPictureDialog component which opens a dialog for selecting a picture. The selected picture is loaded in an TImage component and shown on the main empty window.
1 2 3 4 5 |
with OpenPictureDialog do if Execute then begin Memo.Clear; Image.Picture.LoadFromFile(FileName); |
Then the selected picture is scanned using the TObr component (the ‘scanner’) as it follows:
1 2 3 4 |
Obr.Active := <strong>True</strong>; <strong>try</strong> Obr.Picture.Assign(Image.Picture); Obr.Scan; |
If no code is detected (found) after decoding the picture, the TMemo components writes “No barcode found” in the field at the bottom.
1 2 |
if Obr.BarcodeCount = 0 then Memo.Lines.Append('No barcode found'); |
If code is detected by the TObr component, an OnBarcodeDetected event is fired. The Result from the TObr scanner is generated in this event. To get all the scanned symbols, we use an TObrSymbol which is an item of the OBR list. In this case the list contains only one item. The TObrSymbol breaks down the scanned result on different parts. Each part contains different information (part of the result in text).
1 2 3 4 5 6 7 8 9 10 11 12 |
procedure TFormMain.ObrBarcodeDetected(Sender: TObject); var i: Integer; Barcode: TObrSymbol; begin Memo.Clear; for i := 0 to Obr.BarcodeCount - 1 do begin Barcode := Obr.Barcode[i]; Memo.Lines.Append(Barcode.SymbologyName + Barcode.SymbologyAddonName + ' ' + Barcode.OrientationName + ' ' + Barcode.DataAnsi); end; end; |
The code for this OBR demo can be downloaded at:
https://winsoft.sk/download/obr.zip
Head over and find out more info about the OBR library from WINSOFT for use with Delphi.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition