Skip to content

Commit

Permalink
fix: bug azimuth camera non ptz
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronan committed Jul 12, 2024
1 parent aa8d499 commit cfb9005
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyroengine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _process_alerts(self, cameras: List[ReolinkCamera]) -> None:
frame_info["frame"].save(stream, format="JPEG", quality=self.jpeg_quality)
for camera in cameras:
if camera.ip_address == cam_id:
azimuth = camera.cam_azimuths[pose_id - 1] if pose_id is not None else None
azimuth = camera.cam_azimuths[pose_id - 1] if pose_id is not None else camera.cam_azimuths[0]
localization = self._alerts[0]["localization"]
response = self.api_client[cam_id].create_detection(stream.getvalue(), azimuth, localization)
logging.info(f"Azimuth : {azimuth} , localization : {localization}")
Expand Down
3 changes: 3 additions & 0 deletions src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def main(args):
if cam_data["type"] == "ptz":
cam_poses = cam_data["poses"]
cam_azimuths = cam_data["azimuths"]
else:
cam_poses = []
cam_azimuths = [cam_data["azimuth"]]
splitted_cam_creds[_ip] = cam_data["token"]
cameras.append(
ReolinkCamera(_ip, CAM_USER, CAM_PWD, cam_data["type"], cam_poses, cam_azimuths, args.protocol)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_engine_offline(tmpdir_factory, mock_wildfire_image, mock_forest_image):
engine._stage_alert(mock_wildfire_image, 0, None, datetime.now().isoformat(), localization="dummy")
assert len(engine._alerts) == 1
assert engine._alerts[0]["ts"] < datetime.now().isoformat() and _ts < engine._alerts[0]["ts"]

# Cache dump
engine._dump_cache()
assert engine._cache.joinpath("pending_alerts.json").is_file()
Expand Down

0 comments on commit cfb9005

Please sign in to comment.