在 ABBYY SDK 中获取字符边界框和置信度
Get char bounding boxes and confidence levels in ABBYY SDK
我使用 ABBYY 的 OCR SDK 转换图像:
CSafePtr<IFRDocument> frDocument = ...;
frDocument->AddImageFile( "C:\test\input.tif" );
frDocument->Process( 0 );
frDocument->Export( "C:\test\output.rtf", FEF_RTF, 0 );
但现在我还需要获取字符边界框和置信度。我可以从 Tesseract 获得它们,所以我认为 ABBYY 的 SDK 也有可能。
如何获取边界框和置信度?
我终于找到了怎么做,你需要使用 IPlainText::GetCharacterData()
。
GetCharacterData Method of the PlainText Object
This method returns the information about all characters in the text as a set of arrays: the page numbers on which the characters are located, the coordinates of characters' rectangles, and characters' confidences.
示例:
CSafePtr<IPlainText> plainText;
frDocument->get_PlainText(&plainText);
SAFEARRAY *confidences, *pageNumbers, *leftBorders, *topBorders, *rightBorders, *bottomBorders, *isSuspicious;
plainText->GetCharacterData(&pageNumbers, &leftBorders, &topBorders, &rightBorders, &bottomBorders, &confidences, &isSuspicious);
我使用 ABBYY 的 OCR SDK 转换图像:
CSafePtr<IFRDocument> frDocument = ...;
frDocument->AddImageFile( "C:\test\input.tif" );
frDocument->Process( 0 );
frDocument->Export( "C:\test\output.rtf", FEF_RTF, 0 );
但现在我还需要获取字符边界框和置信度。我可以从 Tesseract 获得它们,所以我认为 ABBYY 的 SDK 也有可能。
如何获取边界框和置信度?
我终于找到了怎么做,你需要使用 IPlainText::GetCharacterData()
。
GetCharacterData Method of the PlainText Object This method returns the information about all characters in the text as a set of arrays: the page numbers on which the characters are located, the coordinates of characters' rectangles, and characters' confidences.
示例:
CSafePtr<IPlainText> plainText;
frDocument->get_PlainText(&plainText);
SAFEARRAY *confidences, *pageNumbers, *leftBorders, *topBorders, *rightBorders, *bottomBorders, *isSuspicious;
plainText->GetCharacterData(&pageNumbers, &leftBorders, &topBorders, &rightBorders, &bottomBorders, &confidences, &isSuspicious);