Open oonisim opened 8 months ago
With the code below, it appears it is using (0,1) but not sure where it is clearly documented and guaranteed to be so in the future.
Correct the BoundingBox
default representation are floating point numbers in [0, 1]. The BoundingBox
class does have a handful of functions to provide denormalized coordinates if needed.
In terms of parsing everything is done with normalized coordinates: https://github.com/aws-samples/amazon-textract-textractor/blob/master/textractor/parsers/response_parser.py#L272
Hopefully this answers your question.
Thanks for the follow up. Does it mean the sentence:
By default BoundingBox is set to work with denormalized co-ordinates: x: (0, docwidth), y: (0, docheight). Use the as_normalized_dict function to obtain BoundingBox with normalized co-ordinates: x: (0, 1), y: (0, 1)
should be:
By default BoundingBox is set to work with normalized co-ordinates: x: (0, 1), y: (0, 1). Use appropriate functions to work with the denormalized coordinates.
Is it the correct understanding? I suppose this is more consistent with the Textract documentation.
classtextractor.entities.bbox.BoundingBox(x: float, y: float, width: float, height: float, spatial_object=None) says:
Problem
Definition of
docwidth
anddocheight
are not clear.Clarification
Does pages in the Document objects by default use x:(0, 1) and y:(0, 1) ir x(0: width_in_pixel) and y:(0, height_in_pixels) with regard to (docwidth, docheight) in
By default BoundingBox is set to work with denormalized co-ordinates: x: (0, docwidth), y: (0, docheight).
?With the code below, it appears it is using (0,1) but not sure where it is clearly documented and guaranteed to be so in the future.
If using the docheight is using the pixel, it should be in between (0, 2339), but apparently it is not using it.
AWS Textract Document
AWS documentation of BoundingBox is clear that the unit/scale is ratio of page width/height.