From 6913fae3e5e70e3dd389f892f7fbb2303ec6c607 Mon Sep 17 00:00:00 2001 From: Conner Vieira Date: Thu, 5 Sep 2024 14:17:04 -0400 Subject: [PATCH] Added status light support to dashcam ALPR --- CHANGELOG.md | 14 ++++++++------ assets/support/configdefault.json | 2 +- dashcam.py | 17 ++++++++++++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c8fed5..23b54c2 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -433,9 +433,9 @@ March 6th, 2024 ## Version 11.0 -### Unification Update +### Refinement Update -This update focuses on unifying Predator's different modes to allow multipurpose functionality. Additional, this update emphasizes improving the reliability of Predator, especially when operating in dash-cam mode. +This update emphasizes improving the reliability of Predator, especially when operating in dash-cam mode. This update also expands the functionality of dash-cam mode to allow simultaneous dash-cam recording and ALPR analysis. *Release date to be determined* @@ -448,7 +448,6 @@ This update focuses on unifying Predator's different modes to allow multipurpose - Predator will no longer try to apply a time offset when the system time is in the future relative to the GPS time. - Predator no longer displays warning about the time being desynced when GPS time correction is disabled. - Predator will now reset the time offset if the system time changes. -- Increased the max-depth of the configuration validation process. - Updated dash-cam mode. - Added customizable frame-rate restrictions. - Added a per-device configuration value to set a maximum allowed frame-rate. When this frame-rate is exceeded, Predator will throttle dash-cam recording to stay below the limit. @@ -488,11 +487,14 @@ This update focuses on unifying Predator's different modes to allow multipurpose - Moved the status lighting configuration to the "general" section. - Network requests are only made to update the status lighting if it has changed since the last update. - This means that the status lighting can be turned off, and it will only turn back on when an update is made. + - Changed the default `dashcam_save` status light color to blue, to avoid confusion with `alpr_alert`. - Updated configuration back-end. + - Increased the max-depth of the configuration validation process. - Predator can now automatically update the configuration file between versions when configuration values are added or removed. - Added an initial start-up sequence, where Predator shows some basic information before the normal start-up. - Predator now creates a file named `install.json` containing some basic install information on the first start-up. -- Remote alert database sources can now be cached. - - This allows Predator to continue using entries from a remote alert database even when the source goes offline. -- Migrated most of the ALPR processing to a dedicated file for sake of organization. +- Updated the ALPR handler. + - Remote alert database sources can now be cached. + - This allows Predator to continue using entries from a remote alert database even when the source goes offline. + - Migrated most of the ALPR processing to a dedicated file for sake of organization. - The "detected plate" notification sound now plays regardless of the console output level. diff --git a/assets/support/configdefault.json b/assets/support/configdefault.json index ea70212..a144983 100755 --- a/assets/support/configdefault.json +++ b/assets/support/configdefault.json @@ -53,7 +53,7 @@ "normal": "[U]&R=0&G=255&B=0", "alpr_alert": "[U]&R=255&G=0&B=0", "alpr_detection": "[U]&R=255&G=128&B=0", - "dashcam_save": "[U]&R=255&G=0&B=0" + "dashcam_save": "[U]&R=0&G=0&B=255" } } }, diff --git a/dashcam.py b/dashcam.py index f81f735..54335b2 100755 --- a/dashcam.py +++ b/dashcam.py @@ -810,6 +810,7 @@ def capture_dashcam_video(directory, device="main", width=1280, height=720): plate_log = alpr.load_alpr_log() def background_alpr(device): global current_frame_data + global saving_active # This variable is used to determine which value the status lighting should be returned to after a plate detection. if (config["realtime"]["saving"]["license_plates"]["enabled"] == True): # Check to see if the license plate logging file name is not empty. If the file name is empty, then license plate logging will be disabled. global plate_log @@ -922,8 +923,18 @@ def background_alpr(device): # Display alerts. alpr.display_alerts(active_alerts) # Display active alerts. - for plate in detected_plates_valid: - utils.play_sound("notification") + if (config["general"]["status_lighting"]["enabled"] == True): # Check to see if status lighting alerts are enabled in the Predator configuration. + if (len(active_alerts) > 0): # Check to see if there are active alerts. + update_status_lighting("alpr_alert") # Run the function to update the status lighting. + elif (len(detected_plates_valid) > 0): + update_status_lighting("alpr_detection") # Run the function to update the status lighting. + else: + if (saving_active == True): + update_status_lighting("dashcam_save") # Since the current dashcam segment is being saved, return to the corresponding status lighting value. + else: + update_status_lighting("normal") + for plate in detected_plates_valid: # Run once for each detected plate. + utils.play_sound("notification") # Play the "new plate detected" sound. for alert in active_alerts: # Run once for each active alert. if (config["realtime"]["push_notifications"]["enabled"] == True): # Check to see if the user has Gotify notifications enabled. debug_message("Issuing alert push notification") @@ -1146,7 +1157,7 @@ def dashcam_output_handler(directory, device, width, height, framerate): dashcam_segment_saving.start() # Start the dashcam segment saving thread. save_this_segment = False # Reset the segment saving flag. saving_active = False - update_status_lighting("normal") # Return status lighting to normal. + update_status_lighting("normal") # Return status lighting to normal since a new segment has been started. delete_old_segments() # Handle the erasing of any old dash-cam segments that need to be deleted.