Skip to content

Commit

Permalink
fix name & check not None
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoLostanlen committed Jun 17, 2024
1 parent ae3e12c commit 8dd7c23
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pyroengine/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ def capture_camera_image(args: Tuple[ReolinkCamera, MPQueue]) -> None:
for pose_id in camera.cam_poses:
cam_id = f"{camera.ip_address}_{pose_id}"
frame = camera.capture(pose_id)
queue.put((cam_id, frame))
if not frame is None:
queue.put((cam_id, frame))
else:
frame = camera.capture()
queue.put((cam_id, frame))
if not frame is None:
queue.put((cam_id, frame))
except Exception as e:
logging.exception(f"Error during image capture from camera {cam_id}: {e}")

Expand Down Expand Up @@ -162,7 +164,8 @@ def run(self, period: int = 30) -> None:
if not self.day_time:
try:
frame = self.cameras[0].capture()
self.day_time = is_day_time(None, frame, "ir")
if frame is not None:
self.day_time = is_day_time(None, frame, "ir")
except Exception as e:
logging.exception(f"Exception during initial day time check: {e}")

Check warning on line 170 in pyroengine/core.py

View check run for this annotation

Codecov / codecov/patch

pyroengine/core.py#L165-L170

Added lines #L165 - L170 were not covered by tests

Expand All @@ -178,14 +181,16 @@ def run(self, period: int = 30) -> None:
# Analyze each captured frame
if queue:
while not queue.empty():
cam_id, img = queue.get()
cam_id, frame = queue.get()
try:
self.analyze_stream(img, cam_id)
if frame is not None:
self.analyze_stream(frame, cam_id)
except Exception as e:
logging.error(f"Error running prediction: {e}")

Check warning on line 189 in pyroengine/core.py

View check run for this annotation

Codecov / codecov/patch

pyroengine/core.py#L184-L189

Added lines #L184 - L189 were not covered by tests

# Use the last frame to check if it's day_time
self.day_time = is_day_time(None, img, "ir")
if frame is not None:
self.day_time = is_day_time(None, frame, "ir")

Check warning on line 193 in pyroengine/core.py

View check run for this annotation

Codecov / codecov/patch

pyroengine/core.py#L193

Added line #L193 was not covered by tests

# Process alerts
try:
Expand Down

0 comments on commit 8dd7c23

Please sign in to comment.