ImageEn, unit ievision

TIEVisionBarCodeScanner


Declaration

TIEVisionBarCodeScanner = interface(TIEVisionBase)


Description

This interface allows you to read bar codes (EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code).




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 bar code 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 bar code 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;


Methods and Properties

Public Method  scan


See Also

Public Method  createBarCodeScanner
Class  TIEVisionBarCodeSymbol