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

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, May 14, 2019 1:27:54 PM(UTC)

Jay911  
Jay911

Groups: Registered
Posts: 27

Thanks: 12 times

Hi,

I have used Leadtools OCR library to ocr the specific zone on a pdf and send recognized text and zone information(top,left,right,bottom) to client to display.
To be specific, I use IOcrPage.GetZoneBoundsInPixels(0), and send the ocr zone information (top,left,right,bottom) to draw annotations in client side Imageviewer.
However, it seems like the location of annotations is totally off (see the green area in the image).

Any advice? Thanks in advance.


leadtoolcode.PNGBellOCr.PNG
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, May 14, 2019 1:36:44 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 218

Was thanked: 12 time(s) in 12 post(s)

You need to use the AnnContainerMapper's RectToContainerCoordinates to convert the OCR Coordinates (which are in pixel coordinates) to Annotation coordinates:
https://www.leadtools.co...ontainercoordinates.html

More information on this can be found here:
https://www.leadtools.co.../anncontainermapper.html

AnnContainerMapper is used for converting values between display, annotations and image coordinates.

In LEADTOOLS Annotations, all the values are stored in annotations units (1/720 of an inch). For example, when you create a new container and you must set its size; you may write code like this:

Code:
double inch = 720.0; 
// Create a new annotation container 
Leadtools.Annotations.Engine container = new AnnContainer(); 
// Set its size to 8.5 by 11 inches. Size must be in annotation units (1/720 of an inch) 
container.Size = LeadSizeD.Create(8.5 * inch, 11 * inch); 


Code:

var inch = 720.0; 
// Create a new annotation container 
var container = new Leadtools.Annotations.Engine.AnnContainer(); 
// Set its size to 8.5 by 11 inches. Size must be in annotation units (1/720 of an inch) 
container.set_size(Leadtools.LeadSizeD.create(8.5 * inch, 11 * inch)); 
Similarly, when you create an annotation object and set its location and size, these values must be in annotation coordinates as well:


Code:
// Create a line object from 1, 1 to 2, 2 inches: 
AnnPolylineObject lineObj = new AnnPolylineObject(); 
lineObj.Points.Add(LeadPointD.Create(1 * inch, 1 * inch)); 
lineObj.Points.Add(LeadPointD.Create(2 * inch, 2 * inch)); 


Code:
// Create a line object from 1, 1 to 2, 2 inches: 
var lineObj = new Leadtools.Annotations.Engine.AnnPolylineObject(); 
lineObj.get_points().add(Leadtools.LeadPointD.create(1 * inch, 1 * inch)); 
lineObj.get_points().add(Leadtools.LeadPointD.create(2 * inch, 2 * inch)); 


In automation mode, the user typically draws an annotation object with the mouse or touches the screen using physical screen coordinates. These coordinates must then be transformed to annotation units (1/720 of an inch). To perform this, the mapper needs to know the values of the screen DPI (Dots per Inch). The user must set these values in TargetDpiX and TargetDpiY.

Similarly, when an object is rendered to a target context, the container mapper needs to know the values for the context (or image, during a burn operation) DPI. You must set these values in SourceDpiX and SourceDpiY.

When converting between font size and fixed length and size values between annotation and display coordinates, the mapper will use the values of DeviceDpiX and DeviceDpiY.

To set the DPI values, use MapResolutions. For example, if the current screen resolution is 96 and the container is associated with an image at 300 DPI then you can use the following code:

Quote:
container.MapResolutions(96, 96, 300, 300);


In cases when the target DPI value is unknown or must be calculated at runtime, such as in the case of medical applications, you can use the Calibrate method to adjust the ratio between the source and target resolution based on a provided known value. The resulting calibration value is stored in CalibrationScale and used by this container throughout.

To render the container to a destination context, a transformation matrix might also be required to perform such operations as scroll and zoom. You can set the value of this matrix in Transform, using the UpdateTransform method.

The mapper can now use all the values above to perform the following:

Convert values from display to container coordinates using PointToContainerCoordinates, PointsToContainerCoordinates, LengthToContainerCoordinates, RectToContainerCoordinates, SizeToContainerCoordinates and FontToContainerCoordinates

Convert values from container to display coordinates using PointFromContainerCoordinates, PointsFromContainerCoordinates, LengthFromContainerCoordinates, RectFromContainerCoordinates, SizeFromContainerCoordinates and FontFromContainerCoordinates

Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.075 seconds.