LEADTOOLS Support
General
General Questions
Highlight OCR Text and save highlighted document without viewing
#1
Posted
:
Wednesday, January 17, 2018 11:43:11 AM(UTC)
Groups: Registered
Posts: 26
Thanks: 3 times
In batch mode (not an interactive application), I need to OCR a tif and highlight certain key text areas and save the highlighted document. I've already got an application that takes care of the OCR and text recognition. Looking for sample code that highlights and saves highlighted document. I found one solution that uses AnnHiliteObject but I don't understand how to associate the "bounds" of the OCR'd text with the "points" in the AnnHiliteObject.Points.Add(LeadPointD) command.
#2
Posted
:
Wednesday, January 17, 2018 12:08:57 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 199
Was thanked: 28 time(s) in 28 post(s)
Hello,
You can use the
RectToContainerCoordinates method to convert between OCR bounds and annotation coordinates.
Code:
void HiliteWord(AnnContainer container, IOcrPage page, OcrWord word)
{
// Get bounds of word as LeadRectD
LeadRectD bounds = word.Bounds.ToRectangle(page.DpiX, page.DpiY).ToLeadRectD();
// Convert to annotation coordinates
bounds = container.Mapper.RectToContainerCoordinates(bounds);
// Create the annotation
AnnHiliteObject hilite = new AnnHiliteObject();
hilite.Points.Clear();
hilite.Points.Add(bounds.TopLeft);
hilite.Points.Add(bounds.TopRight);
hilite.Points.Add(bounds.BottomRight);
hilite.Points.Add(bounds.BottomLeft);
// Add to container
container.Children.Add(hilite);
}
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
1 user thanked Anthony Northrup for this useful post.
LEADTOOLS Support
General
General Questions
Highlight OCR Text and save highlighted document without viewing
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.