import cv2 import os def save_debug_image(img, filename): os.makedirs( "debug", exist_ok=True ) cv2.imwrite( f"debug/{filename}", img )