markup: move work files to a per-cat subdir

This commit is contained in:
2019-10-18 16:39:01 -07:00
parent 3199f6ab40
commit f819ac65b5
3 changed files with 11 additions and 9 deletions

View File

@ -76,9 +76,11 @@ def find_shapes(image_path):
return img.width, img.height, bboxes
def write_debug_image(subdir, cat_name, page_num, prods, scribbles):
def write_debug_image(subdir, name, page_num, prods, scribbles):
"""Draw an image with boxes for products, images, and shapes."""
path = os.path.join(WORKDIR, subdir, f"{cat_name}-debug-page{page_num:03d}.png")
dir = os.path.join(WORKDIR, subdir, name)
ensure_dir(dir)
path = os.path.join(dir, f"debug-page{page_num:03d}.png")
pagew = int(11*72)
pageh = int(8.5*72)

View File

@ -1,6 +1,6 @@
from markup.img import find_shapes, write_debug_image
from markup.pdf import parse_pdf
from markup.utils import overlaps
from .img import find_shapes, write_debug_image
from .pdf import parse_pdf
from .utils import overlaps
def find_marked_products(pdf, subdir, catname, debug=0):

View File

@ -59,10 +59,10 @@ def make_scribble(obj, pagenum, mediabox, subdir, name):
def export_jp2(obj, subdir, name, pagenum):
oid = obj.objid
jp2_path = os.path.join(WORKDIR, subdir, f"{name}-export-page{pagenum:03d}-{oid}.jp2")
png_path = os.path.join(WORKDIR, subdir, f"{name}-export-page{pagenum:03d}-{oid}.png")
ensure_dir(os.path.join(WORKDIR, subdir))
dir = os.path.join(WORKDIR, subdir, name)
ensure_dir(dir)
jp2_path = os.path.join(dir, f"export-page{pagenum:03d}-obj{oid:05d}.jp2")
png_path = os.path.join(dir, f"export-page{pagenum:03d}-obj{oid:05d}.png")
data = obj.get_rawdata()
print('extracting jp2: {}'.format(jp2_path))