easier to see that pdf gives no clues when its 2 rows boo
parent
ae9e9bcc0d
commit
def34e1536
29
debug.py
29
debug.py
|
|
@ -3,18 +3,37 @@ import os
|
|||
import time
|
||||
import subprocess
|
||||
import config
|
||||
from PIL import ImageFont
|
||||
|
||||
def draw_boxes(page, boxes):
|
||||
im = debug_im(page)
|
||||
#for i in boxes:
|
||||
# continue
|
||||
# i["y0"] = page.height - i["y0"]
|
||||
# i["y1"] = page.height - i["y1"]
|
||||
# #i["x0"] *= im.original.height / page.height
|
||||
# #i["x1"] *= im.original.height / page.height
|
||||
# #i["y0"] *= im.original.height / page.height
|
||||
# #i["y1"] *= im.original.height / page.height
|
||||
for box in boxes:
|
||||
im.draw_line(((box["x0"], page.height - box["y0"]), (box["x1"], page.height - box["y0"])))
|
||||
im.draw_line(((box["x1"], page.height - box["y0"]), (box["x1"], page.height - box["y1"])))
|
||||
im.draw_line(((box["x1"], page.height - box["y1"]), (box["x0"], page.height - box["y1"])))
|
||||
im.draw_line(((box["x0"], page.height - box["y1"]), (box["x0"], page.height - box["y0"])))
|
||||
im.draw_line(((box["x0"], box["y0"]), (box["x1"], box["y0"])))
|
||||
im.draw_line(((box["x1"], box["y0"]), (box["x1"], box["y1"])))
|
||||
im.draw_line(((box["x1"], box["y1"]), (box["x0"], box["y1"])))
|
||||
im.draw_line(((box["x0"], box["y1"]), (box["x0"], box["y0"])))
|
||||
if "debug_label" in box:
|
||||
font = ImageFont.truetype("arial.ttf", 24)
|
||||
for offset in [-2, -1, 1, 2]:
|
||||
im.draw.text(
|
||||
xy=(offset + box["x0"] * im.original.height / page.height, offset + box["y0"] * im.original.height / page.height),
|
||||
text=str(box["debug_label"]),
|
||||
fill=(255,255,255),
|
||||
font=font,
|
||||
)
|
||||
im.draw.text(
|
||||
xy=(box["x0"], page.height-box["y0"]),
|
||||
xy=(box["x0"] * im.original.height / page.height, box["y0"] * im.original.height / page.height),
|
||||
text=str(box["debug_label"]),
|
||||
fill=(0,255,0),
|
||||
font=font,
|
||||
)
|
||||
debug_show(im)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue