23 lines
663 B
Python
23 lines
663 B
Python
import numpy as np
|
|
import cv2
|
|
from obfuscation.base_obfuscation_technique import ObfuscationTechnique
|
|
|
|
|
|
class Blackening(ObfuscationTechnique):
|
|
"""
|
|
Simply fill the face ROI with a constant colour (black).
|
|
"""
|
|
def __init__(self):
|
|
# Normalise to 3-tuple BGR
|
|
self.colour=(0, 0, 0)
|
|
|
|
def obfuscate(self, face_roi_img_bgr: np.ndarray, face_mask) -> np.ndarray:
|
|
if face_roi_img_bgr is None or face_roi_img_bgr.size == 0:
|
|
raise ValueError("Eingabebild ist leer.")
|
|
|
|
obf = face_roi_img_bgr.copy()
|
|
obf[face_mask.astype(bool)] = self.colour
|
|
return obf
|
|
|
|
def name(self):
|
|
return "Black" |