From 489d32beaecc29a307a79299b969b370cd49df0c Mon Sep 17 00:00:00 2001 From: mateo Date: Mon, 22 Apr 2024 10:28:12 +0200 Subject: [PATCH] not in this pr --- pyroengine/engine.py | 16 ++++++++++++++++ pyroengine/sensors.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pyroengine/engine.py b/pyroengine/engine.py index 9d1d43a2..cf926925 100644 --- a/pyroengine/engine.py +++ b/pyroengine/engine.py @@ -327,6 +327,22 @@ def process_prediction(self, preds: np.ndarray, frame: Image.Image, cam_id: Opti self._dump_cache() self.last_cache_dump = ts + # save frame + if len(self.api_client) > 0 and isinstance(self.frame_saving_period, int) and isinstance(cam_id, str): + self._states[cam_key]["frame_count"] += 1 + if self._states[cam_key]["frame_count"] == self.frame_saving_period: + # Save frame on device + self._local_backup(frame_resize, cam_id, is_alert=False) + # Send frame to the api + stream = io.BytesIO() + frame_resize.save(stream, format="JPEG", quality=self.jpeg_quality) + try: + self._upload_frame(cam_id, stream.getvalue()) + # Reset frame counter + self._states[cam_key]["frame_count"] = 0 + except ConnectionError: + stream.seek(0) # "Rewind" the stream to the beginning so we can read its content + return float(conf) def _upload_frame(self, cam_id: str, media_data: bytes) -> Response: diff --git a/pyroengine/sensors.py b/pyroengine/sensors.py index 2deb5ed7..b91e78bc 100644 --- a/pyroengine/sensors.py +++ b/pyroengine/sensors.py @@ -13,7 +13,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) -CAM_URL = "http://{ip_address}/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user={login}&password={password}" +CAM_URL = "https://{ip_address}/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user={login}&password={password}" class ReolinkCamera: