ImageEn, unit iexHelperFunctions

TIEBitmapHelper.ScanQRCode

TIEBitmapHelper.ScanQRCode

Declaration

function ScanQRCode(): string; overload;
function ScanQRCode(ScanRect: TRect): string; overload;
function ScanQRCode(ScanRect: TRect; out Data: TIEStringArray; out Rects: TIERectArray): Integer; overload;
function ScanQRCode(ScanRect: TRect; out Data: TIEStringArray; out Rects: TIERectArray; out Corners: TIEArrayOfTPoint): Integer; overload;

Description

A shortcut method that creates a TIEVisionQRCodeDetector object and calls detect to read the QR codes in the image.
You can specify a rect to limit scanning to an area of the image. Specify Rect(0,0,0,0) to scan the whole image.
The first and second overloads return the payload of the first QR code that could be decoded, or '' if none was found.
The third and fourth overloads return the number of QR codes found, with parallel arrays of the payload (Data) and bounding rectangle (Rects) of each code. A code is included with an empty payload when its corners were found but it could not be decoded.
The fourth overload also returns the four corners of each code in Corners (four points per code, so Corners[i * 4] to Corners[i * 4 + 3] are the corners of code i). The corners are consecutive around the symbol and follow it when it is rotated or skewed.


Note:
◼You must add the iexHelperFunctions unit to your uses clause
◼Delphi/C++ 2005 or newer is required to use helper classes
◼ScanBarcode can also read QR codes (along with other barcode types). ScanQRCode uses a dedicated QR code detector that returns every code in the image together with its corners
◼You can draw the rects to a canvas using DrawRects
◼QR code reading requires IEVision. You will need to register it before calling the method

Method Behavior

The following call:
count := ImageEnView1.IEBitmap.ScanQRCode( Rect( 0,0,0,0 ), qrData, qrRects );
Is the same as calling:
codes := IEVisionLib.createQRCodeDetector().detect( ImageEnView1.IEBitmap.GetIEVisionImage(), IEVisionRect( 0,0,0,0 ) );
for i := 0 to codes.size() - 1 do
begin
  qr := TIEVisionQRCode( codes.getObj(i) );
  s := qr.getData().c_str();
  r := qr.getBoundingBox();
end;

Demo

Demo  Demos\IEVision\QRCode\QRCode.dpr

Examples

Also see: Automated Samples
// Show the text of the first QR code in the image
s := ImageEnView1.IEBitmap.ScanQRCode();
if s <> '' then
  ShowMessage( s );

// Outline all QR codes in the image
count := ImageEnView1.IEBitmap.ScanQRCode( Rect( 0, 0, 0, 0 ), qrData, qrRects, qrCorners );
ImageEnView1.IEBitmap.IECanvas.Pen.Color := clRed;
ImageEnView1.IEBitmap.IECanvas.Pen.Width := 3;
for i := 0 to count - 1 do
begin
  ImageEnView1.IEBitmap.IECanvas.MoveTo( qrCorners[i * 4 + 3].X, qrCorners[i * 4 + 3].Y );
  for c := 0 to 3 do
    ImageEnView1.IEBitmap.IECanvas.LineTo( qrCorners[i * 4 + c].X, qrCorners[i * 4 + c].Y );
end;
ImageEnView1.Update();

See Also

◼GenerateQRCode
◼TIEVisionQRCodeDetector
◼TIEVisionQRCode
◼ScanBarcode
◼detect