Hi, I try to recognize only one region on an image(actually many regions, but I simplified the code sample). Code below tries to remove all blocks from page before processing, adds block with defined coordinates and then performs processing. It writes to console a number of blocks on the first page before and after processing. I expect that after processing it outputs 1, but when I run the code, I get 1 and 22. So why do I get all blocks after processing instead of only one? I hope the question is clear.
var engineLoader = new FREngine.OutprocLoader();
var processControl = (FREngine.IHostProcessControl) engineLoader; processControl.SetClientProcessId(Process.GetCurrentProcess().Id);
var engine = engineLoader.GetEngineObjectEx("SWAT-XXXX-XXXX-XXXX-XXXX-XXXX", null, null, true);
var frDocument = engine.CreateFRDocument(); frDocument.AddImageFile(Environment.CurrentDirectory + @"/Images/Test.jpg");
// Remove all the blocks from the collection
var region = engine.CreateRegion();
// Add blocks of required type to the layout var block = blocks.AddNew(BlockTypeEnum.BT_Text, region, 0); var recognizerParams = engine.CreateRecognizerParams(); recognizerParams.SetPredefinedTextLanguage("English");
// Set the required parameters of the block var textBlock = block.GetAsTextBlock(); textBlock.RecognizerParams = recognizerParams;
block.Name = "test";
Thanks in advance, Kirill
asked 03 Oct '14, 17:51
You are doing practically everything correct, except one moment: IFRDocument::Process method includes Preprocess, Analyze, Recognize and Synthesize methods calls. So in case your intend is to add block or blocks manually you do not need to call after adding blocks Analyze method included into IFRDocument::Process - while automatic analysis your blocks will be deleted.
So all that you need after adding blocks is to call IFRDocument::Recognize method.