ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Problem using traineddata (Fast and Best)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
restkrat Posted - Feb 02 2022 : 14:12:40
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;

3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 16 2022 : 17:01:14
Hi

ievOCRLTSMAndLegacy ievOCRLegacy cannot be used with the Best or Fast engines, as they include no legacy support.

The corrected code is as follows:

procedure TForm1.Button2Click(Sender: TObject);
var
  ocrrect: TIERectangle;
  langPath : string;
  langCode: string;
  eng: TIEVisionOCREngine;
begin
  m1.Clear;
  Screen.Cursor := crHourglass;

  langCode := string(IEVisionLanguageNameToCode('English'));
  if cmbengine.Text = 'LTSMLegacy' then                                  
  begin
    langPath := IncludeTrailingBackSlash(ExtractFilePath(Application.ExeName) + 'LTSMLegacy');
    eng := ievOCRLTSMAndLegacy; // or ievOCRDefault or ievOCRLegacy
  end
  else
  if cmbengine.Text = 'LTSMFast' then
  begin
    langPath := IncludeTrailingBackSlash(ExtractFilePath(Application.ExeName) + 'LTSMFast');
    eng := ievOCRLTSM; // Or ievOCRDefault
  end
  else
  if cmbengine.Text = 'LTSMBest' then
  begin
    langPath := IncludeTrailingBackSlash(ExtractFilePath(Application.ExeName) + 'LTSMBest');
    eng := ievOCRLTSM; // Or ievOCRDefault
  end
  else
    raise Exception.create( 'Invalid selection' );

  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;

  OCR := IEVisionLib.createOCR(PAnsiChar(AnsiString(langPath)), PAnsiChar(AnsiString(langCode)), eng );
  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();

  Screen.Cursor := crDefault;
end;


Nigel
Xequte Software
www.imageen.com
restkrat Posted - Feb 03 2022 : 20:26:33
Hello,

I am using ImageEn 10.3.0 and IEVision 6.0.1

The attachment has the image I have been testing with.

Thanks



xequte Posted - Feb 02 2022 : 16:08:30
Hi

Can you forward us some of your test files? Are you using the latest version of ImageEn and IEVision?

Nigel
Xequte Software
www.imageen.com