Closed victor7376 closed 11 months ago
Everything looks OK. Not sure if your IP cam stream is low resolution. Having a large image really slows down opencv.
Also speed-cam.py is at ver 12.05 so upgrade if lower. I have run speed-cam.py on RPI 3 quad core with IP Camera stream with no issues. Also have a single core RPI using RPI Legacy cam an other than missing the odd vehicle it works fine. My IP cams have a low resolution 640x480 stream and that is what I use. Please check you IP Cam Docs and pick the lowest res stream size. Even 720p can cause slow RPI. Claude ...
On Tue, Sep 12, 2023 at 9:18 AM victor7376 @.***> wrote:
Hi,
I love this program but I've got an issue with it lol.
The server & tracking starts up with no problem & gets the feed from my rtsp camera (Tapo C200 - 640x360) & the log shows it is seeing the vehicles going past & calculating the speeds, but its not saving them. But as soon as someone walks past its detecting them & saving those. I've tried to adjust the settings to only save those that are going over a certain speed (I have it showing MPH) but max_speed_over I wasnt sure if this was in MPH or KPH so put it to 10.
Config: `# ---------------- User Configuration Settings for speed-cam.py
Ver 12.00 speed-cam.py Variable Configuration Settings
####################################### speed-cam.py Variable Settings Default is 320x240 image stream size Note motion track crop area is now auto configured so you may not need to use a plugin to change resolution.
####################################### Calibration Settings --------------------
calibrate = False # Create a calibration image file with calibration hash markers 10 px per mark align_cam_on = False # Default=False True Saves align_cam.jpg See Web page recent align cam align_delay_sec = 2 # Default=2 seconds delay between each alignment image (disables motion tracking)
cal_obj_px_L2R = 180 # L2R Moving Objects, Length of a calibration object in pixels cal_obj_mm_L2R = 4000 # L2R Moving Objects, Length of the calibration object in millimetres
cal_obj_px_R2L = 180 # R2L Moving Objects, Length of a calibration object in pixels cal_obj_mm_R2L = 4000 # R2L Moving Objects, Length of the calibration object in millimetres Camera Settings ---------------
CAMERA = "ipcam" # valid values are usbcam, ipcam, pilibcam, pilegcam CAM_LOCATION = 'None' # Specify an address, physical location Etc for camera Libcam (Bullseye or later) and Legacy Pi Camera Settings
CAMERA_WIDTH = 320 # Image stream width for opencv motion scanning Default=320 CAMERA_HEIGHT = 240 # Image stream height for opencv motion scanning Default=240 CAMERA_FRAMERATE = 22 # Default= 20 Frame rate for video stream V2 picam can be higher CAMERA_ROTATION = 0 # Rotate camera image valid values are 0, 90, 180, 270 CAMERA_VFLIP = True # Flip the camera image vertically if required CAMERA_HFLIP = True # Flip the camera image horizontally if required USB, WEB and RTSP IP Cam Settings ---------------------------------
USBCAM_SRC = 1 # Used if CAMERA = "usbcam" IPCAM_SRC = @.***:554/stream2"
Set low res stream per IP Cam Docs and config
WEBCAM_WIDTH = 640 # Default= 320 USB, RTSP cam image stream width WEBCAM_HEIGHT = 360 # Default= 240 USB, RTSP cam image stream height WEBCAM_HFLIP = False # Default= False USB Webcam flip image horizontally WEBCAM_VFLIP = False # Default= False USB Webcam flip image vertically
IMPORTANT Webcam Streaming Performance Hit if Stream Flipped.
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. Plugins overlay the config.py variable settings
pluginEnable = True pluginName = "picam240" # Specify filename in plugins subfolder without .py extension per below
picam240, webcam240 (Recommended for RPI2 or greater)
picam480, webcam480, 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 ----------------------------------------------
gui_window_on = True # True= Turn On All desktop GUI openCV windows. False=Don't Show (req'd for SSH) . gui_show_camera = True # True=Show the camera on gui windows. False=Don't Show (useful for image_sign) show_thresh_on = True # Display desktop GUI openCV cropped threshold window. True=Show, False=Don't Show show_crop_on = True # Same as show_thresh_on but in color. True=Show, False=Don't Show (Default) Display and Log settings ------------------------
verbose = True # True= Display basic status information on console False= Off display_fps = True # True= Show average frame count every 1000 loops False= Off log_data_to_CSV = True # True= Save log data as CSV comma separated values False= Off loggingToFile = True # True= Send logging to file False= No Logging to File logFilePath = 'speed-cam.log' # Location of log file when loggingToFile=True Motion Event Settings ---------------------
SPEED_MPH = True # Set Speed Units kph=False mph=True track_counter = 20 # Default= 6 Number of Consecutive Motion Events to trigger speed photo. Adjust to suit.
Suggest single core cpu=4-7 quad core=8-15 but adjust to smooth erratic
readings due to contour jumps MIN_AREA =1000 # Default= 200 Exclude all contours less than or equal to this sq-px Area show_out_range = True # Default= True Show Out of Range Events per x_diff settings below False= Off x_diff_max = 24 # Default= 20 Exclude if max px away >= last motion event x position x_diff_min = 1 # Default= 1 Exclude if min px away <= last event x position x_buf_adjust = 10 # Default= 10 Divides motion Rect x for L&R Buffer Space to Ensure contours are in track_timeout = 0.5 # Default= 0.5 Optional seconds to wait after track End (Avoids dual tracking) event_timeout = 0.3 # Default= 0.3 seconds to wait for next motion event before starting new track max_speed_over = 15 # Exclude track if Speed less than or equal to value specified 0=All
Can be useful to exclude pedestrians and/or bikes, Etc or track only
fast objects Motion Tracking Window Crop Area Settings ----------------------------------------- Note: Values based on 320x240 image stream size. If variable is commented, value will be set automatically based on image size. To see motion tracking crop area on images, Set variable image_show_motion_area = True Set align_cam_on = True to help with adjusting settings. uncomment to set the red box - roydz
x_left = 50 # Default=50 comment variable for auto calculate
x_right = 50 # Default=250 comment variable for auto calculate
y_upper = 190 # Default=90 comment variable for auto calculate
y_lower = 50 # Default=150 comment variable for auto calculate
Camera Image Settings ---------------------
image_path = "media/images" # folder name to store images image_prefix = "speed-" # image name prefix image_format = ".jpg" # Default = ".jpg" image Formats .jpg .jpeg .png .gif .bmp image_jpeg_quality = 98 # Set the quality of the jpeg. Default = 95 https://docs.opencv.org/3.4/d8/d6a/group__imgcodecs__flags.html#ga292d81be8d76901bff7988d18d2b42ac image_jpeg_optimize = True # Optimize the image. Default = False https://docs.opencv.org/3.4/d8/d6a/group__imgcodecs__flags.html#ga292d81be8d76901bff7988d18d2b42ac image_show_motion_area = True # True= Display motion detection rectangle area on saved images image_filename_speed = True # True= Include speed value in filename image_text_on = True # True= Show Text on speed images False= No Text on images image_text_bottom = True # True= Show image text at bottom otherwise at top image_font_size = 12 # Default= 12 Font text height in px for text on images image_font_scale = 0.5 # Default= 0.5 Font scale factor that is multiplied by the font-specific base size. image_font_thickness = 2 # Default= 2 Font text thickness in px for text on images image_font_color = (255, 255, 255) # Default= (255, 255, 255) White image_bigger = 3.0 # Default= 3.0 min=0.1 Resize saved speed image by specified multiplier value image_max_files = 0 # 0=off or specify MaxFiles to maintain then oldest are deleted Default=0 (off)
image_sign_on = False image_sign_show_camera = False image_sign_resize = (1280, 720) image_sign_text_xy = (100, 675) image_sign_font_scale = 30.0 image_sign_font_thickness = 60 image_sign_font_color = (255, 255, 255) image_sign_timeout = 5 # Keep the image sign for 5 seconds. Optional Manage SubDir Creation by time, number of files or both (not recommended)
imageSubDirMaxFiles = 2000 # 0=off or specify MaxFiles - Creates New dated sub-folder if MaxFiles exceeded imageSubDirMaxHours = 0 # 0=off or specify MaxHours - Creates New dated sub-folder if MaxHours exceeded Optional Save Most Recent files in recent folder
imageRecentMax = 100 # 0=off Maintain specified number of most recent files in motionRecentDir imageRecentDir = "media/recent" # Default= "media/recent" save recent files directory path Optional Manage Free Disk Space Settings
spaceTimerHrs = 0 # Default= 0 0=off or specify hours frequency to perform free disk space check spaceFreeMB = 500 # Default= 500 Target Free space in MB Required. spaceMediaDir = 'media/images' # Default= 'media/images' Starting point for directory walk spaceFileExt = 'jpg' # Default= 'jpg' File extension to Delete Oldest Files OpenCV Motion Settings ----------------------
SHOW_CIRCLE = False # True=circle in center of motion, False=rectangle CIRCLE_SIZE = 5 # Default= 5 Diameter circle in px if SHOW_CIRCLE = True LINE_THICKNESS = 1 # Default= 1 Size of lines for circle or Rectangle FONT_SCALE = 0.5 # Default= 0.5 OpenCV window text font size scaling factor Default=.5 (lower is smaller) WINDOW_BIGGER = 1.0 # Default= 1.0 min=0.1 Resize multiplier for opencv window if gui_window_on=True BLUR_SIZE = 10 # Default= 10 OpenCV setting for Gaussian difference image blur THRESHOLD_SENSITIVITY = 20 # Default= 20 OpenCV setting for difference image threshold Sqlite3 Settings ----------------
DB_DIR = "data" DB_NAME = "speed_cam.db" DB_TABLE = "speed" matplotlib graph image settings -------------------------------
GRAPH_PATH = 'media/graphs' # Directory path for storing graph images GRAPH_ADD_DATE_TO_FILENAME = False # True - Prefix graph image filenames with datetime default = False GRAPH_RUN_TIMER_HOURS = 0.5 # Default= 0.5 Update Graphs every specified hours wait (Continuous). List of sql query Data for sql-make-graph-count-totals.py and sql-make-graph-speed-ave.py (with no parameters) [[Group_By, Days_Prev, Speed_Over]] where Group_By is 'hour', 'day' or 'month'
GRAPH_RUN_LIST = [ ['day', 28, 10], ['hour', 28, 10], ['hour', 7, 0], ['hour', 2, 0] ]
======================================
webserver.py Settings
======================================
Web Server settings -------------------
web_server_port = 8080 # Default= 8080 Web server access port eg http://192.168.1.100:8080 web_server_root = "media" # Default= "media" webserver root path to webserver image/video sub-folders web_page_title = "SPEED-CAMERA Media" # web page title that browser show (not displayed on web page) web_page_refresh_on = True # False=Off (never) Refresh True=On (per seconds below) web_page_refresh_sec = "400" # Default= "900" seconds to wait for web page refresh seconds (15 minutes) web_page_blank = False # True Starts left image with a blank page until a right menu item is selected
False displays second list[1] item since first may be in progress
Left iFrame Image Settings --------------------------
web_image_height = "768" # Default= "768" px height of images to display in iframe web_iframe_width_usage = "70%" # Left Pane - Sets % of total screen width allowed for iframe. Rest for right list web_iframe_width = "100%" # Desired frame width to display images. can be eg percent "80%" or px "1280" web_iframe_height = "100%" # Desired frame height to display images. Scroll bars if image larger (percent or px) Right Side Files List ---------------------
web_max_list_entries = 0 # 0 = All or Specify Max right side file entries to show (must be > 1) web_list_height = web_image_height # Right List - side menu height in px (link selection) web_list_by_datetime = True # True=datetime False=filename web_list_sort_descending = True # reverse sort order (filename or datetime per web_list_by_datetime setting ---------------------------------------------- End of User Variables
`
— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/138, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZDUMB2SQHCD5LYUP6DX2BOKJANCNFSM6AAAAAA4U3C7IE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc
I've tweaked the settings and it seems to have now worked.
The Tapo C200's lowest resolution is 640x360 as its a 1080p camera.
Having to reopen my issue, as after a few hours of working the app crashes after not getting any response for 60 seconds. I've confirmed the camera is working on not only the TPLink app, but also the cctv software I use (AgentDVR). I even tried using the feed from agentdvr into the speed camera, but the speed camera crashed after a few hours of use with the same error.
Today I tried to use a usb webcam (c270) but when I run the software the webcam blinks on then off.
Not sure what is happening. I did upgrade the software. I've even tried on Ubuntu to see if that made any difference, but its the same issue.
The error message is:
2023-09-13 20:15:12 ERROR speed_get_contours image Stream Image is Not Complete. Cannot Crop. Retry.
after 60 times then crashes
Hi,
I love this program but I've got an issue with it lol.
The server & tracking starts up with no problem & gets the feed from my rtsp camera (Tapo C200 - 640x360) & the log shows it is seeing the vehicles going past & calculating the speeds, but its not saving them. But as soon as someone walks past its detecting them & saving those. I've tried to adjust the settings to only save those that are going over a certain speed (I have it showing MPH) but max_speed_over I wasnt sure if this was in MPH or KPH so put it to 10.
Config: