I'm developing an iPhone app and need to highlight, for example every occurance of the word CRM like shown below:
How do i retrieve the coordinates of a word CRM?
I'm developing an iPhone app and need to highlight, for example every occurance of the word CRM like shown below:
How do i retrieve the coordinates of a word CRM?
1 out of 1 found this helpful
Comments
1 comment
First of all, you need to specify data export format by adding a parametr to
processImage
call:cloud.ocrsdk.com/processImage?exportFormat=xml
You'll get an xml response that for each recognized character will contain an instance of
charParams
element as follows:The XML you get is synthesised according to this schema.
Those "l", "t", "r", "b" params stand for left, top, right and bottom, they describe a rectangle of each character with top-left and bottom-right corner. I beleive that's exatly what you are looking for.
The element will contain the coordinates in page pixels - the same XML also contains a
page
element:where the image width and height are stored. So
l
andr
for eachcharParams
element is in range0..width-1
of the corresponding page andt
andb
for eachcharParams
element is in range0..height-1
of the corresponding page.Also it's worth mentioning explicitly that all coordinates are in pixels - they are completely resolution-agnostic. This is why whenever you try to highlight anything on an image you have to take zoom into account - the image will likely not be always displayed as is by your device software, but will be downscaled and so you have to map page coordinates onto your zoomed-out image coordinates and highlight appropriately.
Please sign in to leave a comment.