Loading...

Annotation Measurement Units

Support for GdPicture XMP Annotations Plugin.

Annotation Measurement Units

Postby RobertHorn » Fri Jan 27, 2012 4:14 pm

Hi,

I am using Annotations to allow a user to select an area that is then used later to Zonal OCR.

Up to now, when working with the positions on the image, the values that I get for things like Page Width are in the 1000's. Now when I check the Top, Left, Width and Height of the Annotation, I find that the values are incredibly small. A possition of 5 is in the middle of the page. So how do I translate these position so that I can then use them to do the Zonal OCR?

Robert
RobertHorn
 
Posts: 14
Joined: Fri Jan 20, 2012 8:18 am

Re: Annotation Measurement Units

Postby Loïc » Fri Jan 27, 2012 5:48 pm

Hi,

Just scale the inch size by the image resolution.

IE:

Code: Select all
int widthPixel = Math.Round(widthInches * horizontalResolution);
int heightPixel = Math.Round(heightInches *verticalResolution);


Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4445
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Annotation Measurement Units

Postby RobertHorn » Fri Feb 03, 2012 6:35 pm

Hi Loic,

I have done the following to workout the exact pixels of the image where the annotation is:

HorizontalResolution = imageViewer.HorizontalResolution
VertialResolution = imageViewer.VerticalResolution

PixTop = AnnotationTop / VertialResolution
PixHeight = AnnotationHeight / VertialResolution
PixWidth = AnnotationWidth / HorizontalResolution
PixLeft = AnnotationLeft / HorizontalResolution

I then draw a rectangle:

oGdPictureImaging.DrawRectangle(ImageID, PixLeft, PixTop, PixWidth, PixHeight, 10, Color.Red, True)

Now when I reposition the annotation with these fixures, it is where it should be. But if draw a rectangle on this image using these figures, the rectangle is off to the left and slighly down. It is not in the same position as the Annotation. Now the GD Viewer has functionality that enables you to select what area you want to process. But using the Rectangle Annotation provides a really nice way of enabling the user to edit the size and position of the area. So I am trying to integrate the two so that I can then process the area selected.

So my question is, how do I translate the position of the Annotations so that I get an accurate rectangle on the image?
RobertHorn
 
Posts: 14
Joined: Fri Jan 20, 2012 8:18 am

Re: Annotation Measurement Units

Postby Loïc » Sun Feb 05, 2012 2:23 pm

Hi,

Please have a look on the reference guide: http://guides.gdpicture.com/v8/html/con ... ation.html

Especially here:


Left: Left position, in inches, of the middle point of the bounding box of the annotation.
Top: Top position, in inches, of the middle point of the bounding box of the annotation.
Width: Width, in inches, of the bounding box of the annotation.
Height: Height, in inches, of the bounding box of the annotation.


So the top-left corner of the annotation bbox is:

Code: Select all
topLeftX = annot.Left - annot.Width/2
topLeftY = annot.Top - annot.Height/2


Hope this helps.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4445
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdPicture XMP Annotations Plugin

Who is online

Users browsing this forum: No registered users and 1 guest