Skip to content

How to retrieve the absolute coordinates of the predicted bounding boxes #570

Answered by fg-mindee
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone looking for the answer, here is the snippet from the other thread starting from the predictor result:

# Everything to produce the result goes here
# ...
export = result.export()
# Flatten the export
page_words = [[word for block in page['blocks'] for line in block['lines'] for word in line['words']] for page in export['pages']]
page_dims = [page['dimensions'] for page in export['pages']]
# Get the coords in [xmin, ymin, xmax, ymax]
words_abs_coords = [
    [[int(round(word['geometry'][0][0] * dims[1])), int(round(word['geometry'][0][1] * dims[0])), int(round(word['geometry'][1][0] * dims[1])), int(round(word['geometry'][1][1] * dims[0]))] for word in words]
    for words, dims in 

Replies: 3 comments 23 replies

Comment options

You must be logged in to vote
22 replies
@fg-mindee
Comment options

@ghost
Comment options

@fg-mindee
Comment options

@ghost
Comment options

@fg-mindee
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by fg-mindee
Comment options

You must be logged in to vote
1 reply
@frgfm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
module: io Related to doctr.io
3 participants