Detector Builder

The detector_builder module defines the plug-in infrastructure that all detectors share. Every detector must inherit from BaseClass and implement the required interface; DetectorFactory() discovers and instantiates the correct subclass at runtime from a plain string name.

BaseClass

class ecosound.detection.detector_builder.BaseClass(detector_name)[source]

Bases: object

Base class for all detectors.

All detectors need to inheritate from this BaseClass in order to be built by the DetectorFactory.

classmethod is_detector_for(detector_name)[source]

Check detector name.

Compare the requested detector_name with each detector classe available.

Parameters:
  • detector_name (str)

  • class. (Name of the detector)

Return type:

bool

DetectorFactory

ecosound.detection.detector_builder.DetectorFactory(detector_name, *args, **kwargs)[source]

Detector Factory.

Loads the detector class defined by detector_name. Each detector class must be added to the __init__.py file.

For example : from .detector1 import Detector1

where Detector1 is the name of the detector class to load from teh .py file detection1

Parameters:
  • detector_name (str) – Name of the detector class.

  • *args (any) – Input arguments for the detector selected.

  • **kwargs (any) – Keyword arguments for the detector selected.

Raises:

ValueError – If detector_name doesn’t correspond to any of the detectors available.

Return type:

Detector object