2

I'm trying to process an image using ABBYY OCR SDK using the sample code placed in this question but I'm not able get the co-ordinates right for a specific word say "OCR" on the screenshot below.

enter image description here

I want to draw an overlay (yellow rectangle over the word "OCR") and sometimes the rectangle is placed very far away from the actual word.

Community
  • 1
  • 1
YogiAR
  • 2,207
  • 23
  • 44

2 Answers2

3

The XML you get is synthesised according to this schema.

For each recognized character it will contain an instance of charParams element as shown in the answer you linked to. The element will contain the coordinates in page pixels - the same XML also contains a page element:

<page width="..." height="..." resolution="..." originalCoords="...">

where the image width and height are stored. So l and r for each charParams element is in range 0..width-1 of the corresponding page and t and b for each charParams element is in range 0..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.

Community
  • 1
  • 1
sharptooth
  • 167,383
  • 100
  • 513
  • 979
  • Yes Sharptooth , actually it all depends upon the image resolution , the image that i was using is of 449*651 and thats why the coordinates i was getting for a particular word is diffrent . but when i took the image of 320*480 then it was placed correctly on the word. – YogiAR Jan 05 '12 at 09:51
  • @sharptooth: can ABBYY convert a tiff to searchable pdf? I have asked this question here http://stackoverflow.com/questions/9103044/convert-image-to-searchable-pdf Thank you very much – Thang Pham Feb 01 '12 at 21:32
  • @Harry Pham: Yes, the TIFF can be OCR'd and then exported as a searchable PDF. – sharptooth Feb 02 '12 at 08:30
  • hi Sharptooth, can u please help me with this: http://stackoverflow.com/questions/9113119/how-to-get-coordinates-using-abbyy-mobile-sdk-for-iphone – YogiAR Feb 02 '12 at 13:27
2

Have you checked the DPI of the original image and also check the documentation to make sure the OCR engine is using the same DPI and not returning the image in points or some other measurement system.

It could be that rectangle you are drawing in iOS is not based on pixels but on some other measurement system also.

You just need to work through the process, testing as you go, and work out where the problem is coming from. It is most likely a uniform scaling and the distance from the actual word is proportional to the distance of the word from the top left of the page.

Andrew Cash
  • 2,321
  • 1
  • 17
  • 11