Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pageauc committed Oct 13, 2023
1 parent 94c64bd commit 817f008
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion speed-cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions strmpilibcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 817f008

Please sign in to comment.