- Introduction
OBR (Optical Barcode recognition) component for Firemonkey supports Windows, macOS, iOS and Android. Its main purpose is to decode QR code and Barcode images. In the below video you can check the steps to install the firemonkey component for OBR. The installation steps differs to the one for the OBR firemonkey library, it is actually easier.
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.
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.
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 OpenDialog do if Execute then begin Memo.Lines.Clear; ImageControl.Bitmap.LoadFromFile(FileName); |
Then the selected picture is decoded using the TBarcodeDecoder object (the ‘scanner’) and the results is filled into the TDecodeResults list as it follows:
1 2 3 |
with TBarcodeDecoder.Create do try Barcodes := Decode(ImageControl.Bitmap); |
If code is detected by the TBarcodeDecoder object, the result is stored in the TDecodeResults list, named as Barcodes. With FOR cycle we check the list and its items of what they have stored before. The item of the TDecodeResults list contains FormatName and Text (which is the doceded text). You can see in the below code:
1 2 |
for I := 0 to Length(Barcodes) - 1 do Memo.Lines.Append(Barcodes[I].FormatName + ': ' + Barcodes[I].Text); |
You can download the Demo with the component from the link below:
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition