Skip to content

Add configurable night detection strategy for cameras without IR support #387

Description

@fe51

Context

Our detection models are trained primarily on daytime images and are not intended to run during the night. Running inference on night images leads to a some false positives.

Current behavior

Night detection currently relies on the camera IR mode (automatic IR detection) to determine when to stop the inference loop.

This assumption does not hold for all cameras, especially third-party cameras that are not installed by Pyronear, as they may not expose or support IR information. In these cases, inference continues throughout the night, resulting in unnecessary detections.

Proposed solution

Make the night detection strategy configurable on a per-camera basis.

One possible strategy is to rely on a sunrise/sunset service using the camera coordinates to determine whether it is currently night. This was the historical implementation and may still exist in the repository (see

def is_day_time(cache: Optional[Path], frame: Image.Image, strategy: str, delta: int = 0) -> bool:
)

As part of this task:

  • Investigate whether the historical sunrise/sunset implementation is still present in the repository.
  • Reuse it if possible; otherwise, reimplement an equivalent solution.
  • Add a configurable parameter to the camera configuration to select the night detection strategy.

Example (to be discussed):

night_detection_strategy: ir
# or
night_detection_strategy: sunrise_sunset

Acceptance criteria

  • A working alternative night detection strategy is available for cameras without IR support.
  • The night detection strategy is configurable in the camera configuration.
  • Existing IR-based behavior remains unchanged.
  • Inference is not executed during night periods for cameras using the configured strategy, reducing night-time false positives.
  • Automated tests are added where appropriate (the repository currently has limited test coverage, making this a good opportunity to improve it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions