Using folders "Copies" and "Par label", hopefully
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
import json
|
||||
import numpy as np
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from PIL import Image, ImageChops, ImageFilter
|
||||
Image.MAX_IMAGE_PIXELS = None
|
||||
from pdf2image import convert_from_path
|
||||
@@ -99,7 +100,7 @@ def detect_checks_and_notes(output_dir):
|
||||
density = changed_pixels / roi.size
|
||||
|
||||
if density > DENSITY_THRESHOLD:
|
||||
print("A checked box !", density, b)
|
||||
# print("A checked box !", density, b)
|
||||
actions.append(box)
|
||||
# It's checked, so we mask this area out for manual notes
|
||||
# Expand mask slightly to catch sloppy ticks
|
||||
@@ -254,7 +255,7 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
|
||||
|
||||
# B. Regenerate Label Image
|
||||
# We always regenerate to ensure Concat.jpg is consistent with any modifications
|
||||
pdf_path = os.path.join(root_dir, f"Copie{student_id}", f"{label}.pdf")
|
||||
pdf_path = Path(root_dir) / "Copies" / f"Copie{student_id}" / f"{label}.pdf"
|
||||
if not os.path.exists(pdf_path): continue
|
||||
|
||||
(base_img, _, _) = annotating.make_base_image(pdf_path)
|
||||
@@ -328,7 +329,6 @@ def apply_actions_and_regenerate(root_dir, data, student_id, actions, notes_laye
|
||||
full_img.save(os.path.join(output_dir, "Concat_F.jpg"))
|
||||
print(f" Saved regenerated Concat_F.jpg")
|
||||
|
||||
from pathlib import Path
|
||||
from utils import read_all_labels
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
|
||||
Reference in New Issue
Block a user