ImageEn, unit ievision

TIEVisionLibrary.createBarCodeScanner

TIEVisionLibrary.createBarCodeScanner


Declaration

function createBarCodeScanner(): TIEVisionBarCodeScanner; safecall;


Description

Create a barcode scanner object.



Note: A shortcut method for this is 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.LoadFromFile( 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;