image2data

Der Tech-Blog

...weitermachen, wo OCR aufhört

Bitmapobjekte finden, Seite löschen und Objekte neu zeichnen (sample_10.i2dspt)

Dez 012014
// *****************************************************
// * sample_10.i2dspt                                  *
// *                                                   *
// * - Retrieving the objects of an image              *
// * - Clearing the image                              *
// * - Redrawing only the retrieved objects            *
// * - Showing the result in the i2dBitmapViewer       *
// *                                                   *
// * Press F9 to execute the code or F7/F8 to debug it *
// *                                                   *
// * Be sure that the sample data was installed!       *
// *                                                   *
// * Contact www.norpa.eu for more information         *
// *****************************************************
 
var
  // Declare some variables
  oPage: TBitmap;
 
  aOCRObjects: Ti2dOCRObjects;
  rProcessSettings: Ti2dProcessSettings;
 
begin
  // Get the configured process settings. We must know the configured "in"-folder because that's
  // where the sample docs are located in!
  i2dGetProcessSettings(rProcessSettings);
 
  // Create the bitmap object
  oPage := TBitmap.Create;
 
  try
    // Load first page of the image into the bitmap object
    i2dLoadBitmap(rProcessSettings.InPath + 'sample_invoice_1.tif', 1, oPage);
 
    // Show it in the original state
    i2dShowInBitmapViewerB(oPage);
 
    // Get the image objects
    i2dGetBitmapObjects(oPage, 2, 2, 4, 11, 5, 5, 5, 5, 3, aOCRObjects);
 
    // Clear the page
    oPage.Canvas.Brush.Color := clWhite;
    oPage.Canvas.Brush.Style := bsSolid;
    oPage.Canvas.Rectangle(0, 0, oPage.Width, oPage.Height);
 
    // Draw the found (and only them) image objects
    i2dDrawBitmapObjects(oPage, aOCRObjects);
 
    // And show it without barcodes and logo
    i2dShowInBitmapViewerB(oPage);
  finally
    // Destroy the bitmap object and release memory
    oPage.Free;
  end;
end.

Atom

powered by Nibbleblog