Hello,
The only eng.traineddata I can get to work is the one from the English LTSM+Legacy download. When I try to the other two English LTSM Only (Fast) or English LTSM Only (Best), I get an access error when using either of them. I have just been replacing the eng.traineddata. Any idea what I can do to make those two work?
Thanks
procedure TForm1.Button1Click(Sender: TObject);
begin
od1.Execute(Form1.Handle);
if od1.FileName <> '' then
begin
im1.IO.LoadFromFile(od1.FileName);
im1.Fit();
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ocrrect: TIERectangle;
langPath : string;
langCode: string;
langis : String;
begin
m1.Clear;
memo1.Clear;
Screen.Cursor := crHourglass;
langCode := string(IEVisionLanguageNameToCode('English'));
if cmbengine.Text = 'LTSMLegacy' then langPath := IncludeTrailingBackSlash(ExtractFilePath(Application.ExeName) + 'LTSMLegacy');
if cmbengine.Text = 'LTSMFast' then langPath := IncludeTrailingBackSlash(ExtractFilePath(Application.ExeName) + 'LTSMFast');
if cmbengine.Text = 'LTSMBest' then langPath := IncludeTrailingBackSlash(ExtractFilePath(Application.ExeName) + 'LTSMBest');
if not IEVisionAvailable(False) then
begin
ShowMessage('This application requires ievision.dll plugin. Please download it from www.imageen.com/download/');
Application.Terminate;
exit;
end;
//langis := langcode + '.traineddata';
//memo1.Lines.Add(langis);
//memo1.Lines.Add(langpath + langcode + '.traineddata');
Try
OCR := IEVisionLib.createOCR(PAnsiChar(AnsiString(langPath)), PAnsiChar(AnsiString(langCode)), TIEVisionOCREngine(cmbEngine.ItemIndex));
//OCR := IEVisionLib.createOCR(PAnsiChar(AnsiString(langPath)), PAnsiChar(AnsiString(langis)), TIEVisionOCREngine(cmbEngine.ItemIndex));
OCR.setSegmentationMode(TIEVisionOCRPageSegmentationMode(cmbLayout.ItemIndex));
ocrrect := Im1.SelectedRect;
m1.Lines.Text := OCR.recognize(Im1.IEBitmap.GetIEVisionImage(), IEVisionRect(ocrrect.x, ocrrect.y, ocrrect.width, ocrrect.height)).c_str();
except
on E: Exception do
begin
if E is EAccessViolation then
MessageDlg('An error was encountered processing this image. Ensure you are using the latest version of the IEVision plug-in.', mtError, [mbOK], 0)
else
MessageDlg('An error was encountered processing this image: ' + e.message, mtError, [mbOK], 0);
end;
end;
Screen.Cursor := crDefault;
end;