ImageEn, unit ievision

TIEVisionBarCodeScanner.scan

TIEVisionBarCodeScanner.scan


Declaration

function scan(image: TIEVisionImage; const rect: TIEVisionRect): TIEVisionVectorObjRef; safecall;


Description

Look for barcodes within the specified image. Only 24 bit RGB and 8 bit gray scale images are supported.
Returns a list of detected barcodes as TIEVisionBarCodeSymbol objects.

Parameter Description
image Image where to search for barcodes
rect Rectangle of the image where to search for. Setting (0, 0, 0, 0) means the whole image



Note: There is also a shortcut method available: ScanBarcode


Demos

Demo  Demos\IEVision\Barcode\Barcode.dpr
Demo  Demos\IEVision\BarCodeCam\BarCodeCam.dpr


Examples

var
  symbols: TIEVisionVectorObjRef;
  s: TIEVisionBarCodeSymbol;
  i: integer;
begin
  symbols := IEVisionLib.createBarCodeScanner().scan(ImageEnView1.IEBitmap.GetIEVisionImage(), IEVisionRect(0, 0, 0, 0));
  for i := 0 to symbols.size() - 1 do
  begin
    s := TIEVisionBarCodeSymbol( symbols.getObj(i) );
    Memo1.Lines.Add('type = ' + s.getSymbolType().c_str());
    Memo1.Lines.Add('data = ' + s.getData().c_str());
    with s.getBoundingBox() do
      Memo1.Lines.Add('rect = ' + inttostr(x) + ' ' + inttostr(y) + ' ' + inttostr(width) + ' ' + inttostr(height));
  end;
end;

// Function to read a barcode from a file
function ReadBarcodeFromFile(const Filename : string): String;
var
  IEBitmap: TIEBitmap;
begin
  Result := '';
  IEBitmap := TIEBitmap.Create;
  try
    IEBitmap.Read( Filename );
    m_symbols := IEVisionLib.createBarCodeScanner().scan( IEBitmap.GetIEVisionImage(), IEVisionRect( 0, 0, 0, 0 ));

    if m_symbols.size() > 0 then
      Result := TIEVisionBarCodeSymbol( m_symbols.getObj( m_symbols.size() - 1 )).getData().c_str();
  finally
    IEBitmap.Free;
  end;
end;

// Function to read a barcode from a bitmap
function ReadBarcodeFromBitmap(aBitmap: TBitmap): String;
var
  IEBitmap: TIEBitmap;
begin
  IEBitmap := TIEBitmap.Create( aBitmap, Rect( 0, 0, aBitmap.Width, aBitmap.Height ));
  try
    m_symbols := IEVisionLib.createBarCodeScanner().scan( IEBitmap.GetIEVisionImage(), IEVisionRect( 0, 0, 0, 0 ));

    if m_symbols.size() > 0 then
      Result := TIEVisionBarCodeSymbol( m_symbols.getObj( m_symbols.size() - 1 )).getData().c_str();
  finally
    IEBitmap.Free;
  end;
end;