image2data

Der Tech-Blog

...weitermachen, wo OCR aufhört

Einfache Texterkennung (sample_1.i2dspt)

Dez 012014
// ***********************************************************
// * sample_1.i2dspt                                         *
// *                                                         *
// * - Retrieving the text from a page of an image using OCR *
// * - Showing the result in the i2dTextViewer               *
// *                                                         *
// * 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
  sText: String;
  oPage: TBitmap;
 
  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);
 
    // Perform a character recognition (ocr) with format preservation on the bitmap object
    sText := i2dOCRBitmap(oPage, 0, True);
 
    // Show the result
    i2dShowInTextViewer(sText);
  finally
    // Destroy the bitmap object and release memory
    oPage.Free;
  end;
end.

Atom

powered by Nibbleblog