logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
chirag.doshi  
#1 Posted : 3 years ago
chirag.doshi

Rank: Newbie

Groups: Registered
Joined: 3/18/2022(UTC)
Posts: 3
United States
Location: Weston,FL

I am using the following code:

api.SetImage(OcrPix.FromFile(testBitmap));
api.Recognize();
plainText = api.GetUtf8Text();


OcrBoxa ocrBoxa = null;
OcrPixa ocrPixa = null;

api.GetWords(out ocrBoxa, out ocrPixa);
ResultWords = new List<string>();
for (int i = 0; i < ocrPixa.Pixes.Length; i++)
{
string word = ocrPixa.Pixes[i].Text;
if (api.IsValidWord(word.Trim()))
ResultWords.Add(word);
}


The property ocrPixa.Pixes[i].Text is always null. The plain text displays as many words.
Please advise on getting the words list for a given language from OCRApi.
I am trying to avoid parsing the words from text as rules of parsing are different in different languages.
Paul Rayman  
#2 Posted : 3 years ago
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,115

Thanks: 8 times
Was thanked: 130 time(s) in 127 post(s)
Hello,

The GetWords method returns Pixa in Leptonica style. The Text property of the Leptonics image returns the comment contained in the image's caption. It has nothing to do with the recognizable text.

Please use the following code instead
Code:
var iter = api.Iterator;
api.SetImage(pix);
api.Recognize();

do
{
    var text = iter.GetUtf8Text(PageIteratorLevel.RIL_WORD);
    var bbox= iter.PageIterator.GetBoundingBox(PageIteratorLevel.RIL_WORD);
} while (iter.Next(PageIteratorLevel.RIL_WORD));

Edited by user 3 years ago  | Reason: Not specified

chirag.doshi  
#3 Posted : 3 years ago
chirag.doshi

Rank: Newbie

Groups: Registered
Joined: 3/18/2022(UTC)
Posts: 3
United States
Location: Weston,FL

Thanks. I am able to retrieve bounding boxes for words and symbols.
Users browsing this topic
Guest
Forum Jump  
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.