Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent frame none #224

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pyroengine/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ async def capture_camera_image(camera: ReolinkCamera, image_queue: asyncio.Queue
if frame is not None:
await image_queue.put((cam_id, frame))
await asyncio.sleep(0) # Yield control
if not is_day_time(None, frame, "ir"):
return False
if not is_day_time(None, frame, "ir"):
return False
else:
frame = camera.capture()
if frame is not None:
await image_queue.put((cam_id, frame))
await asyncio.sleep(0) # Yield control
if not is_day_time(None, frame, "ir"):
return False
if not is_day_time(None, frame, "ir"):
return False
except Exception as e:
logging.exception(f"Error during image capture from camera {cam_id}: {e}")
return True
Expand Down Expand Up @@ -166,12 +166,14 @@ async def night_mode(self) -> bool:
# Move camera to the next pose to avoid waiting
next_pos_id = camera.cam_poses[(idx + 1) % len(camera.cam_poses)]
camera.move_camera("ToPos", idx=int(next_pos_id), speed=50)
if not is_day_time(None, frame, "ir"):
return False
if frame is not None:
if not is_day_time(None, frame, "ir"):
return False
else:
frame = camera.capture()
if not is_day_time(None, frame, "ir"):
return False
if frame is not None:
if not is_day_time(None, frame, "ir"):
return False
except Exception as e:
logging.exception(f"Error during image capture from camera {cam_id}: {e}")
return True
Expand Down
Loading