generated from Hazel/python-project
feat: blacking out
This commit is contained in:
parent
88180d035c
commit
180b41ffa4
36
secure_pixelation/pixelation_process.py
Normal file
36
secure_pixelation/pixelation_process.py
Normal 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")
|
Loading…
x
Reference in New Issue
Block a user