ImageEn, unit ievision

TIEVisionLibrary.createOCR

TIEVisionLibrary.createOCR


Declaration

function createOCR(language: PAnsiChar = nil; engine: TIEVisionOCREngine = ievOCRDefault): TIEVisionOCR; overload; safecall;
function createOCR(path: PAnsiChar; language: PAnsiChar; engine: TIEVisionOCREngine = ievOCRDefault): TIEVisionOCR; overload; safecall;
function createOCR(path: PAnsiChar; languages: TIEVisionVectorString; engine: TIEVisionOCREngine = ievOCRDefault): TIEVisionOCR; overload; safecall;


Description

Creates an OCR object for the specified language.
Many languages are available as separate files.

Parameter Description
language Language code of OCR recognition (e.g. 'eng', 'fra').
path Folder containing language data files.
engine OCR engine to use.
languages A list of languages.


Demos

Demo  Demos\IEVision\OCR\OCR.dpr
Demo  Demos\IEVision\OCRwithLayout\OCRwithLayout.dpr


Examples

OCR := IEVisionLib.createOCR(IEOCRLanguageList[OCR_English_language].Code);
str := OCR.recognize(ImageEnView1.IEBitmap.GetIEVisionImage(), IEVisionRect(0, 0, 0, 0)).c_str();

OR

sLanguage := 'fra'; // French
if FileExists( IncludeTrailingPathDelimiter( ExtractFilePath( Application.ExeName )) + sLanguage + '.traineddata' ) = False then
  raise Exception.create( 'Language file not found' );
OCR := IEVisionLib.createOCR( sLanguage );
str := OCR.recognize(ImageEnView1.IEBitmap.GetIEVisionImage(), IEVisionRect(0, 0, 0, 0)).c_str();

OR for multiple languages:

var
  langs: TIEVisionVectorString;
langs := IEVisionLib.createVectorString();
langs.push_back( IEOCRLanguageList[ OCR_English_language ].Code ); // load English
langs.push_back( IEOCRLanguageList[ OCR_Italian_language ].Code ); // load Italian
m_OCR := IEVisionLib.createOCR( '', langs );
str := m_OCR.recognize(ImageEnView1.IEBitmap.GetIEVisionImage(), IEVisionRect(0, 0, 0, 0)).c_str();