"""Debug: save each detected box ROI as separate image."""
import cv2
import numpy as np
import os
from test_detect import find_boxes

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
image = cv2.imread(os.path.join(BASE_DIR, "test.png"))

boxes = find_boxes(image)
for i, box in enumerate(boxes):
    roi = box["roi"]
    path = os.path.join(BASE_DIR, f"debug_box_{i}.png")
    cv2.imwrite(path, roi)
    print(f"Box {i}: bbox={box['bbox']}, area={box['area']}, saved to {path}")
