diff --git a/secure_pixelation/__main__.py b/secure_pixelation/__main__.py index 4fea3ce..0db385f 100644 --- a/secure_pixelation/__main__.py +++ b/secure_pixelation/__main__.py @@ -1,7 +1,8 @@ from .get_bounding_boxes import select_bounding_boxes +from .pixelation_process import pixelate def cli(): print(f"Running secure_pixelation") - select_bounding_boxes("assets/human_detection/test.png") + pixelate("assets/human_detection/test.png") diff --git a/secure_pixelation/data_classes.py b/secure_pixelation/data_classes.py index 6f6baf7..a285e80 100644 --- a/secure_pixelation/data_classes.py +++ b/secure_pixelation/data_classes.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Union, List +from typing import Union, List, Tuple from pathlib import Path import json @@ -18,15 +18,13 @@ class RawImage: self.image = self.get_image() - self.steps_dir = self._get_dir("steps") - def _get_path(self, ending: str, original_suffix: bool = False) -> Path: if original_suffix: return self.file.with_name(self.file.stem + "_" + ending + self.file.suffix) else: return self.file.with_name(self.file.stem + "_" + ending) - def _get_dir(self, name: str) -> Path: + def get_dir(self, name: str) -> Path: p = self._get_path(ending=name, original_suffix=False) p.mkdir(exist_ok=True, parents=True) return p @@ -47,7 +45,7 @@ class RawImage: return cv2.imread(str(self.file)) @property - def bounding_boxes(self) -> List[List[int]]: + def bounding_boxes(self) -> List[Tuple[Tuple[int, int], Tuple[int, int]]]: _key = "bounding_boxes" if _key not in self.meta_data: self.meta_data[_key] = [] diff --git a/secure_pixelation/get_bounding_boxes.py b/secure_pixelation/get_bounding_boxes.py index 89e493f..4644f2d 100644 --- a/secure_pixelation/get_bounding_boxes.py +++ b/secure_pixelation/get_bounding_boxes.py @@ -18,5 +18,8 @@ def select_bounding_boxes(to_detect: str): fromCenter=False ) - raw_image.bounding_boxes.extend(bounding_boxes.tolist()) + raw_image.bounding_boxes.extend([ + ((box[0], box[1]), (box[0] + box[2], box[1] + box[3])) + for box in bounding_boxes + ]) raw_image.write_meta()