import cv2
import os

img_path = r"C:\Users\Certes\.gemini\antigravity\brain\975cea00-dd68-4689-9ee3-f1a2408b4ee6\final_check_100_sec.png"
out_dir = r"C:\Users\Certes\.gemini\antigravity\brain\5805a1e3-c776-4325-8538-351d54b5e0a0"

img = cv2.imread(img_path)
h, w = img.shape[:2]

slice_h = 1000
num_slices = (h + slice_h - 1) // slice_h

md_content = "# Visual Inspection of final_check_100_sec.png\n\n```carousel\n"

for i in range(num_slices):
    y_start = i * slice_h
    y_end = min((i + 1) * slice_h, h)
    slice_img = img[y_start:y_end, :]
    out_file = os.path.join(out_dir, f"ai_slice_{i}.png")
    cv2.imwrite(out_file, slice_img)
    
    if i > 0:
        md_content += "<!-- slide -->\n"
    md_content += f"![Slice {i}]({out_file})\n"

md_content += "```\n"

with open(os.path.join(out_dir, "visual_inspection.md"), "w", encoding="utf-8") as f:
    f.write(md_content)

print(f"Generated {num_slices} slices and artifact visual_inspection.md")
