From 817f008e3c49bf1da182ff9da349a8214be0aa72 Mon Sep 17 00:00:00 2001 From: Claude Pageau Date: Thu, 12 Oct 2023 21:57:13 -0400 Subject: [PATCH] minor updates --- speed-cam.py | 2 +- strmpilibcam.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/speed-cam.py b/speed-cam.py index 2576691..15f405b 100644 --- a/speed-cam.py +++ b/speed-cam.py @@ -135,7 +135,7 @@ "IM_SAVE_4AI_ON": False, "IM_SAVE_4AI_POS_DIR": "media/ai/pos", "IM_SAVE_4AI_NEG_DIR": "media/ai/pos", - "IM_SAVE_4AI_NEG_TIMER_SEC": 60 * 60 * 24, + "IM_SAVE_4AI_NEG_TIMER_SEC": 60 * 60 * 6, "IM_FIRST_AND_LAST_ON": False, "IM_SHOW_CROP_AREA_ON": True, "IM_SHOW_SPEED_FILENAME_ON": False, diff --git a/strmpilibcam.py b/strmpilibcam.py index 31ca2d8..7765a44 100644 --- a/strmpilibcam.py +++ b/strmpilibcam.py @@ -6,7 +6,7 @@ from threading import Thread class CamStream: - ''' + """ Create a picamera2 libcamera in memory image stream that runs in a Thread (Bullseye or later) returns image array when read() called @@ -20,12 +20,14 @@ class CamStream: while True: frame = vs.read() # frame will be array that opencv can process. # add code to process stream image arrays. - ''' + """ def __init__(self, size=(320, 248), vflip=False, hflip=False): self.size = size self.vflip = vflip self.hflip = hflip + self.framerate = 40.0 # set a reasonable fps for pilibcamera + self.cam_delay = float(1.0 / self.framerate) # initialize the camera and stream self.picam2 = Picamera2() @@ -58,11 +60,11 @@ def update(self): # release camera resources and stop the thread if self.stopped: return - self.frame = self.picam2.capture_array("main") - time.sleep(0.01) # Slow down loop a little + time.sleep(self.cam_delay) # Slow down loop def read(self): '''return the frame array data''' + self.frame = self.picam2.capture_array("main") return self.frame def stop(self):