コミュニティ

Process is not working with block text 回答済み

Dear Support,

I try to use process with block text but is not working.

 

// Add image to document
 WriteToLog( "Loading image...\n" );
 CheckResult( frDocument->AddImageFile( imageFilePath, 0, 0 ) );

 

 // Set recognition settings
 CSafePtr<IFRPages> pages;
 CheckResult( frDocument->get_Pages( &pages ) );
 
 CSafePtr<IFRPage> firstPage;
 CheckResult( pages->Item( 0, &firstPage ) );
 
 CSafePtr<ILayout> layout;
 CheckResult( firstPage->get_Layout( &layout ));

 

 CSafePtr<IImageDocument> imgDoc;
 CheckResult( firstPage->get_ImageDocument( &imgDoc ) );
 
 CSafePtr<ICoordinatesConverter> converter;
 CheckResult(imgDoc->get_CoordinatesConverter(&converter));
 int left = 30;
 int top = 175;
 int right = 270;
 int bottom = 210;
 CheckResult(converter->ConvertCoordinates(IT_Base, IT_Modified, &left, &top));
 CheckResult(converter->ConvertCoordinates(IT_Base, IT_Modified, &right, &bottom));
 
 CSafePtr<IRegion> region;
 CheckResult(FREngine->CreateRegion(&region));
 CheckResult(region->AddRect(left, top, right, bottom));
 
 CSafePtr<ILayoutBlocks> blocks;
 CheckResult( layout->get_Blocks(&blocks));
 
 CSafePtr<IBlock> newBlock;
 CheckResult(blocks->AddNew(BT_Text, region, 0, &newBlock ));
 
 CSafePtr<ITextBlock> textBlock;
 CheckResult(newBlock->GetAsTextBlock(&textBlock));
 
 CSafePtr<IRecognizerParams> recParams;
 CheckResult(textBlock->get_RecognizerParams(&recParams));
 CheckResult(recParams->put_OneLinePerBlock(VARIANT_TRUE));
 CheckResult(recParams->put_OneWordPerLine(VARIANT_FALSE));
 CheckResult(recParams->SetPredefinedTextLanguage(CBstr(L"PortugueseBrazilian")));
 CheckResult(recParams->put_TextTypes( TT_Normal ) );
 
 CSafePtr<IIntsCollection> indices;
 CheckResult(FREngine->CreateIntsCollection(&indices));
 CheckResult(indices->Add(0));
 CheckResult(firstPage->RecognizeBlocks(indices));
 
 CSafePtr<IText> text;
 CheckResult(textBlock->get_Text(&text));
  
 CSafePtr<IParagraphs> pars;
 CheckResult(text->get_Paragraphs( &pars ) );
 CSafePtr<IParagraph> par;
 CheckResult(pars->Item(0, &par ));
 
 CBstr parText;
 CheckResult(par->get_Text(&parText ) );
 
 // Recognize
 WriteToLog( "Processing...\n" );
 CheckResult(frDocument->Process()); : is not OK
 //CheckResult(frDocument->Reconize());: is OK

 // Export to TXT
 WriteToLog( "Saving results (TXT)...\n" );
 CBstr resultFilePath = resultsPath + imageFileName + L".txt";
 CheckResult( frDocument->Export( resultFilePath, FEF_TextUnicodeDefaults, 0 ) );

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

2件のコメント

  • Avatar
    Permanently deleted user

    The issue is that you have not considered the fact that the IFRDocument::Process method includes the Preprocess, Analyze, Recognize and Synthesize methods calls. So, in case your intend is to add a block or some blocks manually, you do not need to call after adding blocks the Analyze method, which is included into IFRDocument::Proces, because during the automatic document analysis your blocks will be deleted.

    So, all that you need after adding blocks is to call the IFRDocument::Recognize method. You may need to call then the IFRDocument::Synthesize method for performing the document synthesis.

    Please also read the Developer's Help →  Guided Tour → Advanced Techniques → Tuning Parameters of Page Preprocessing, Analysis, Recognition, and Synthesis.

    1
  • Avatar
    Permanently deleted user

    Thank you very much for your reply. I really appreciate your help in resolving the problem.
    Best regards;

    0

サインインしてコメントを残してください。