You are viewing limited content. For full access, please sign in.

Question

Question

Use SDK to get information about OCR Text

SDK
asked on September 19, 2023

In the LF client you can highlight text in the image and it highlights in the OCR text.  If you highlight the OCR text, it highlights the image.   This leads me to believe that somewhere the location of the OCR text in the image is saved.  Is there a way to get the location of the OCR text in the image via the SDK.

0 0

Replies

replied on September 20, 2023

Yeah.  Using RepositoryAccess, you'd want to do something like:

PageInfo page = // however you get your page

using (WordLocationsReader words = page.ReadLocationsPagePart())
{
    while (!words.EndOfStream)
    {
        LfRectangle rect = words.Read();
        // if this is a word you want, do what you need to with the location
    }
}

To unpack a little bit, the location data is stored in the "locations" page part, and so ReadLocationsPagePart() is used to return a WordLocationsReader, which in turn will produce a sequence of LfRectangles, one for each word in the text on the page (assuming that the text was generated by OCR).  So you'll need to iterate through the list of rectangles until you find the ones corresponding to the parts of the text you care about, then do whatever you need to do with them.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.