Skip to content

the question with get_textpage_ocr DPI #4202

Discussion options

You must be logged in to vote

I think I answered this?

  • An A4 page has the rectangle Rect(0.0, 0.0, 595.0, 842.0). The page's Pixmap in default resolution is this Pixmap(DeviceRGB, (0, 0, 595, 842), 0), pix.xres, pix.yres = (96, 96).

  • So the matrix transforming page coordinates to image coordinates is m = page.rect.torect(pix.irect) the identity matrix Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0).

  • If we create the pixmap with some non-default DPI, things change like this:

  • A page rectangle bbox = Rect(100, 100, 200, 200) (imagine a text boundary box here) will therefore have these coordinates on the image (actually more precisely the IRect version of it):

  • And of course vice versa: given a bbox or a point on the image…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@xiaolibuzai-ovo
Comment options

@JorjMcKie
Comment options

@xiaolibuzai-ovo
Comment options

@JorjMcKie
Comment options

Answer selected by xiaolibuzai-ovo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants