Files

27 lines
760 B
Python

"""Detector interface. Implement this to plug in a new model (e.g. YOLO)."""
from __future__ import annotations
from abc import ABC, abstractmethod
from ..video.frame import Frame
from .types import Detection
class Detector(ABC):
"""Abstract censorship detector.
Implementations must be safe to call repeatedly on consecutive frames. They
receive a :class:`Frame` and return detections in *source-frame* pixel
coordinates (the same resolution as ``frame.image``).
"""
@property
def name(self) -> str:
return type(self).__name__
@abstractmethod
def detect(self, frame: Frame) -> list[Detection]:
"""Return detected censored regions for ``frame`` (possibly empty)."""
raise NotImplementedError