feat: blacking out

This commit is contained in:
Hazel 2025-04-24 11:33:28 +02:00
parent 88180d035c
commit 180b41ffa4

View File

@ -0,0 +1,36 @@
from __future__ import annotations
from pathlib import Path
import cv2
import numpy as np
from .data_classes import RawImage
def blackout(raw_image: RawImage) -> np.ndarray:
image = raw_image.get_image()
for box in raw_image.bounding_boxes:
cv2.rectangle(image, box, (0, 0, 0), -1)
return image
def pixelate(to_detect: str, debug_drawings: bool = True):
raw_image = RawImage(to_detect)
step_dir = raw_image.get_dir("steps")
def write_image(image: np.ndarray, name: str):
nonlocal debug_drawings
f = str(step_dir / (name + raw_image.file.suffix))
if debug_drawings:
for box in raw_image.bounding_boxes:
cv2.rectangle(image, box, (0, 255, 255), 1)
cv2.imwrite(f, image)
step_1 = blackout(raw_image)
write_image(step_1, "step_1")