Skip to content

Commit

Permalink
Update to work with bookworm
Browse files Browse the repository at this point in the history
  • Loading branch information
pageauc committed Feb 10, 2024
1 parent 6977333 commit e217180
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 67 deletions.
53 changes: 27 additions & 26 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,36 @@

# Calibration Settings
# --------------------
CALIBRATE_ON = True # Create a calibration image file with calibration hash markers 10 px per mark
CAL_OBJ_PX_L2R = 80 # L2R Moving Objects, Length of a calibration object in pixels
CAL_OBJ_MM_L2R = 4700 # L2R Moving Objects, Length of the calibration object in millimetres
CAL_OBJ_PX_R2L = 85 # R2L Moving Objects, Length of a calibration object in pixels
CAL_OBJ_MM_R2L = 4700 # R2L Moving Objects, Length of the calibration object in millimetres
CALIBRATE_ON = True # Create a calibration image file with calibration hash markers 10 px per mark
CAL_OBJ_PX_L2R = 80 # L2R Moving Objects, Length of a calibration object in pixels
CAL_OBJ_MM_L2R = 4700 # L2R Moving Objects, Length of the calibration object in millimetres
CAL_OBJ_PX_R2L = 85 # R2L Moving Objects, Length of a calibration object in pixels
CAL_OBJ_MM_R2L = 4700 # R2L Moving Objects, Length of the calibration object in millimetres
# Note if tested speed is too low increase appropriate cal_obj_mm value and redo speed test for desired direction.
# IMPORTANT - If plugins Enabled Edit Settings in specified plugin file located in plugins folder.

# Align Camera Settings
ALIGN_CAM_ON = False # Default=False True Saves alignment image to help with camera pointing
ALIGN_DELAY_SEC = 3 # Default=3 seconds delay between each alignment image in recent folder
# ---------------------
ALIGN_CAM_ON = False # Default=False True Saves alignment image to help with camera pointing
ALIGN_DELAY_SEC = 3 # Default=3 seconds delay between each alignment image in recent folder

# Plugins override specified config.py variable settings
# ----------------------------------------------------------
PLUGIN_ENABLE_ON = False # True enables import of the specified PLUGIN_NAME
PLUGIN_NAME = "picam240" # Specify filename in plugins subfolder without .py extension per below
# picam240, webcam240 (Recommended for RPI2 or greater)
# picam480, webcam480, rtsp352, picam720, webcam720 (can use RPI3 but Test)
# picam1080 (Experimental Not Recommended)
# secpicam480, secwebcam480 (Experimental no CSV entries)

# Display and Log settings
# ------------------------
SHOW_SETTINGS_ON = False # True Displays the config.py file on startup
LOG_VERBOSE_ON = True # True= Display basic status information on console False= Off
LOG_DATA_TO_CSV = False # True= Save log data as CSV comma separated values False= Off
LOG_TO_FILE_ON = False # True= Send logging to file False= No Logging to File
SHOW_SETTINGS_ON = False # True Displays the config.py file on startup
LOG_VERBOSE_ON = True # True= Display basic status information on console False= Off
LOG_DATA_TO_CSV = False # True= Save log data as CSV comma separated values False= Off
LOG_TO_FILE_ON = False # True= Send logging to file False= No Logging to File
LOG_FILE_PATH = 'speed-cam.log' # Location of log file when LOG_TO_FILE_ON=True
LOG_FPS_ON = False # True= Show average frame count every 1000 loops False= Off
LOG_FPS_ON = False # True= Show average frame count every 1000 loops False= Off

# Camera Settings
# ---------------
Expand All @@ -40,11 +50,11 @@
RTSPCAM_SRC = "rtsp://user:password@IP:554/path" # Set per IP Cam Docs and config see example below
# rtsp://admin:[email protected]:554/12
# Camera Image Stream Settings
IM_SIZE = (320, 240) # Image resolution width, height pixels
IM_VFLIP = False # True enables flipping image vertically
IM_HFLIP = False # True enables flipping image horizonally
IM_ROTATION = 0 # Rotate camera image valid values are 0, 90, 180, 270
IM_FRAMERATE = 30 # Legacy Picamera Framerate
IM_SIZE = (320, 240) # Image resolution width, height pixels
IM_VFLIP = False # True enables flipping image vertically
IM_HFLIP = False # True enables flipping image horizonally
IM_ROTATION = 0 # Rotate camera image valid values are 0, 90, 180, 270
IM_FRAMERATE = 30 # Legacy Picamera Framerate

# Image Settings
# --------------
Expand Down Expand Up @@ -110,15 +120,6 @@
MO_CROP_Y_UPPER = 90 # Default=90
MO_CROP_Y_LOWER = 150 # Default=150

# Plugins override the specified config.py variable settings
# ----------------------------------------------------------
PLUGIN_ENABLE_ON = False # True enables import of the specified PLUGIN_NAME
PLUGIN_NAME = "picam240" # Specify filename in plugins subfolder without .py extension per below
# picam240, webcam240 (Recommended for RPI2 or greater)
# picam480, webcam480, rtsp352, picam720, webcam720 (can use RPI3 but Test)
# picam1080 (Experimental Not Recommended)
# secpicam480, secwebcam480 (Experimental no CSV entries)

# Display opencv windows on GUI desktop
# GUI_WINDOW_ON suppresses All Windows if False
# ----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion speed-cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"""
from __future__ import print_function
PROG_VER = "13.20" # current version of this python script
PROG_VER = "13.2" # current version of this python script
print('Loading Wait...')
import os
import sys
Expand Down
58 changes: 18 additions & 40 deletions strmcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def strmcam():
import subprocess
import logging

PROG_VER="13.07" # version of this module
CAM_WARMUP_SEC = 3
PROG_VER="13.08" # version of this module
CAM_WARMUP_SEC = 3
# List of valid camera values in the config.py file
CAMLIST = ('usbcam', 'rtspcam', 'pilibcam', 'pilegcam')

# Setup logging
logging.basicConfig(level=logging.INFO,
format="%(asctime)s %(levelname)-8s %(funcName)-10s %(message)s",
Expand Down Expand Up @@ -48,37 +48,10 @@ def strmcam():
sys.path.insert(0, pluginDir)
# Try importing any camera plugin settings if present
try:
from plugins.current import CAMERA
except ImportError:
pass
try:
from plugins.current import IM_SIZE
except ImportError:
pass
try:
from plugins.current import RTSPCAM_SRC
except ImportError:
pass
try:
from plugins.current import USBCAM_SRC
except ImportError:
pass
try:
from plugins.current import IM_FRAMERATE
except ImportError:
pass
try:
from plugins.current import IM_ROTATION
except ImportError:
pass
try:
from plugins.current import IM_HFLIP
except ImportError:
pass
try:
from plugins.current import IM_VFLIP
except ImportError:
pass
from plugins.current import (CAMERA, IM_SIZE, RTSPCAM_SRC, USBCAM_SRC,
IM_FRAMERATE, IM_ROTATION, IM_HFLIP, IM_VFLIP)
except Exception as err_msg:
logging.warning("%s", err_msg)
logging.info("%s Imported New Camera Stream Settings from plugin %s", CAMERA.upper(), PLUGIN_NAME)

# ------------------------------------------------------------------------------
Expand All @@ -87,16 +60,21 @@ def is_pi_legacy_cam():
Determine if pi camera is configured for Legacy = True or Libcam = False.
'''
logging.info("Check for Legacy Pi Camera Module with command - vcgencmd get_camera")
camResult = subprocess.check_output("vcgencmd get_camera", shell=True)
camResult = camResult.decode("utf-8")
camResult = camResult.replace("\n", "")
params = camResult.split()
try:
camResult = subprocess.check_output("vcgencmd get_camera", shell=True)
camResult = camResult.decode("utf-8")
camResult = camResult.replace("\n", "")
params = camResult.split()
except Exception as err_msg:
logging.warning(err_msg)
return False

if params[0].find("=1") >= 1 and params[1].find("=1") >= 1:
logging.info("Pi Camera Module Found %s", camResult)
return True
else:
logging.warn("Problem Finding Pi Legacy Camera %s", camResult)
logging.warn('Check Camera Connections and Legacy Pi Cam is Enabled per command sudo raspi-config')
logging.warning("Problem Finding Pi Legacy Camera %s", camResult)
logging.warning('Check Camera Connections and Legacy Pi Cam is Enabled per command sudo raspi-config')
return False


Expand Down

0 comments on commit e217180

Please sign in to comment.