pyronear / pyronear/pyro-engine

/control/azimuth: report configured azimuth for static / non-PTZ cameras

Open
#394 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
19
Forks
8
PR merge metrics
No merged PRs in 30d

Description

PR #390 adds GET /control/azimuth. It covers the two moving cases (hardware read-back on Linovision, dead reckoning from commanded moves on Reolink PTZ), but the stationary case, where the azimuth is a constant already present in credentials.json, has no path through the code.

Priority: low/medium. No production caller (with livestreaming access) consumes /control/azimuth yet, and the PTZ paths delivered in #390 are unaffected.

Static Reolink ("type": "static")
  • current_azimuth is initialised to None in pyro_camera_api/camera/adapters/reolink.py:62 and only ever written by _sync_azimuth_from_pose, reached solely via operation == "ToPos" (reolink.py:137-138). A static camera never receives a ToPos, since static_loop only captures (pyro_camera_api/camera/patrol.py:119). The value therefore stays None for the process lifetime and /control/azimuth answers azimuth_deg: null.
  • The constructor guard in reolink.py:66 is explicitly if self.cam_type == "ptz" and .... It validates the poses/azimuths alignment for PTZ and does nothing for static. That is the natural place for the missing branch: for a static camera with a configured azimuth, seed current_azimuth directly from cam_azimuths[0], no poses involved.
  • The background sync cannot help either: _cameras_needing_azimuths skips any camera with not cam.cam_poses (pyro_camera_api/camera/pose_azimuths.py:71), and static cameras have none.
Non-PTZ adapters (rtsp / url / rest)

_require_ptz (pyro_camera_api/api/routes_control.py:527, used at routes_control.py:866) returns 400 for anything that is not a PTZMixin. Their azimuth is in RAW_CONFIG and is already reported by /cameras/camera_infos, so the data exists, it is just unreachable through this endpoint. A client that wants to know where a camera is pointing has to special-case the adapter type instead of asking one endpoint.

Proposed fix
  1. Seed the azimuth from config for static cameras, in a constructor branch next to reolink.py:66.
  2. In the route, fall back to RAW_CONFIG[camera_ip]["azimuths"][0] when the adapter has no tracked or hardware value, and drop the hard PTZ requirement for this read-only lookup.
  3. Return "source": "config" ? for these, so callers can tell a fixed value from a tracked or measured one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the constructor guard in pyro_camera_api/camera/adapters/reolink.py and the GET /control/azimuth route in pyro_camera_api/api/routes_control.py, then inspect RAW_CONFIG and the azimuth handling in pose_azimuths.py. Confirm static and non-PTZ cameras return their configured azimuth with source "config", while existing tracked or measured PTZ behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.