the question with get_textpage_ocr DPI #4202
Answered
by
JorjMcKie
xiaolibuzai-ovo
asked this question in
Looking for help
-
Beta Was this translation helpful? Give feedback.
Answered by
JorjMcKie
Jan 8, 2025
Replies: 1 comment 4 replies
-
Of course - this is a must! The positions of text on the page cannot depend on the precision by which it is detected. Detection precision is the only sense in life of DPI. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 thisPixmap(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 matrixMatrix(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 theIRect
version of it):And of course vice versa: given a
bbox
or apoint
on the image…