• Last Post 23 August 2013
Julio posted this 22 August 2013

Hello I'm using the following code(FineReader 10 C#) to process an image given the path to the file. The problems is that the Words list is always empty. Most probably I am missing some code but I do not have any idea how to solve this. Can anybody suggest me something?

FREngine.PageProcessingParams pageParams = engine.CreatePageProcessingParams();
SynthesisParamsForPage synthesis = engine.CreateSynthesisParamsForPage();
synthesis.DetectBackgroundColor = detectFondoColor;
synthesis.DetectTextColor = detectTextoColor;
FREngine.Layout l = engine.CreateLayout();
FREngine.ImageDocument img = engine.PrepareAndOpenImage(sImgPath);
engine.AnalyzeAndRecognizePage(img, pageParams, synthesis, l);

Order By: Standard | Newest | Votes
Anastasia Galimova posted this 23 August 2013

Hello Julio!

You can use the code below (open Hello sample and replace the try block of the processImage method with it).

// Add image file to document
displayMessage( "Loading image..." );
string imagePath = Path.Combine( FreConfig.GetSamplesFolder(), @"SampleImages\Demo.tif" );

document.AddImageFile( imagePath, null, null );

FREngine.PageProcessingParams pageParams = engineLoader.Engine.CreatePageProcessingParams();
pageParams.RecognizerParams.SetPredefinedTextLanguage("English,French"); //specify the language here

FREngine.SynthesisParamsForPage synthesis = engineLoader.Engine.CreateSynthesisParamsForPage();
synthesis.DetectBackgroundColor = true; //specify the value here
synthesis.DetectTextColor = true; //specify the value here

//Recognize document
displayMessage( "Recognizing..." );
document.Process(pageParams, synthesis, null);

//get access to the first word
//be sure that Blocks[0] is a text block
string word = document.Pages[0].Layout.Blocks[0].GetAsTextBlock().Text.Paragraphs[0].Words[0].Text;

Julio posted this 23 August 2013

Thanks for your help Anastasia. I changed my code and that solved the problem. However, I would like to know what is wrong with the previous code. I think, it is lacking something simple.