Skip to content

Commit

Permalink
Merge branch 'main' of Predator
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Nov 10, 2024
2 parents 1315ff7 + 74b6575 commit fbb92b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
10 changes: 4 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ This update refines Predator's functionality, and focuses its purpose back on li
- The `alerts_ignore_validation` configuration value has been moved to the 'general' section.
- Dramatically improved alert handling.
- Alerts detected in real-time mode are now recorded to a dictionary every round, which makes processing and handling alerts more efficient and organized.
- Alerts are now handled on a plate by plate basis, instead of by frame.
- Alerts are now handled on a plate-by-plate basis, instead of frame-by-frame.
- This means only the plates that match alert rules will be marked as alerts in web-hook submissions, logs, and similar context.
- When the `alerts_ignore_validation` configuration value is enabled, a single rule matching multiple guesses for a particular plate will only be considered one alert.
- This prevents an alert with wildcards from repeatedly triggering for every similar guess.
Expand Down Expand Up @@ -437,12 +437,9 @@ March 6th, 2024

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*
November 4th, 2024

- Added more descriptive error messages when the interface directory fails to be created.
- Added comprehensive configuration validation.
- Predator now checks to see if each value in the configuration matches the expected data type.
- Configuration values that exist in the configuration template file but not in the actual configuration file will show errors.
- Added performance monitoring to state interface file to allow external programs to see basic performance diagnostics.
- Updated the way automatic GPS time correction is handled.
- Predator will no longer try to apply a time offset when the system time is in the future relative to the GPS time.
Expand Down Expand Up @@ -503,8 +500,9 @@ This update emphasizes improving the reliability of Predator, especially when op
- 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 maximum depth of the configuration validation process.
- Predator can now automatically update the configuration file between versions when configuration values are added or removed.
- Added comprehensive configuration validation.
- Predator now checks to see if each value in the configuration matches the expected data type.
- Improved the consistency of the configuration file location when starting Predator from an external source, like Assassin.
- 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.
Expand Down
2 changes: 1 addition & 1 deletion alpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def generate_dashcam_sidecar_files(working_directory, dashcam_files):
if (config["general"]["alpr"]["engine"] == "openalpr"): # Check to see if the configure ALPR engine is OpenALPR.
alpr_command = ["alpr", "-j", "-n", str(config["general"]["alpr"]["validation"]["guesses"]), working_directory + "/" + file] # Set up the OpenALPR command.

video_frame_count = utils.count_frames(os.path.join(working_directory, file), method="manual")
video_frame_count = utils.count_frames(os.path.join(working_directory, file))

utils.debug_message("Running ALPR")
alpr_process = subprocess.Popen(alpr_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # Execute the ALPR command.
Expand Down
7 changes: 3 additions & 4 deletions assets/support/configdefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"confidence": 80,
"best_effort": true,
"license_plate_format": [
"AAA0000"
"AAA0000", "AAA000"
]
}
},
Expand All @@ -26,7 +26,7 @@
"debugging_output": false
},
"gps": {
"enabled": true,
"enabled": false,
"demo_file": "",
"time_correction": {
"enabled": true,
Expand Down Expand Up @@ -166,7 +166,7 @@
"max_deletions_per_round": 10
}
},
"framerate_snap": 0.1
"framerate_snap": 0.15
},
"capture": {
"video": {
Expand Down Expand Up @@ -221,7 +221,6 @@
"reticulum": {
"enabled": false,
"destinations": [
"7d72f75f4aebdb94f977b71d394dd12f"
],
"identity_file": "/home/pi/.reticulum/storage/identities/predator",
"instance_name": "My Car",
Expand Down
9 changes: 5 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def display_message(message, level=1):
save_to_file(error_file_location, json.dumps(error_log)) # Save the modified error log to the disk as JSON data.
print(style.red + "Error: " + message + style.end)
if (config["developer"]["hard_crash_on_error"] == True):
global_variables.predator_running = False
os._exit(1)
prompt(style.faint + "Press enter to continue..." + style.end)

Expand Down Expand Up @@ -803,17 +804,17 @@ def convert_corners_to_bounding_box(corners):


# This function counts the number of frames in a given video file.
def count_frames(video, method="manual"):
def count_frames(video):
debug_message("Counting frames")
cap = cv2.VideoCapture(video)
if (method == "opencv"):
if (config["developer"]["frame_count_method"] == "opencv"):
video_frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) # Count the number of frames in the video.
elif (method == "ffprobe"):
elif (config["developer"]["frame_count_method"] == "ffprobe"):
video_frame_count_command = "ffprobe -select_streams v -show_streams \"" + video + "\" 2>/dev/null | grep nb_frames | sed -e 's/nb_frames=//'" # Define the commmand to count the frames in the video.
video_frame_count_process = subprocess.Popen(video_frame_count_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True) # Execute the command to count the frames in the video.
video_frame_count, command_error = video_frame_count_process.communicate() # Fetch the results of the frame count command.
video_frame_count = int(video_frame_count) # Convert the frame count to an integer.
elif (method == "manual"):
elif (config["developer"]["frame_count_method"] == "manual"):
video_frame_count = 0
while (cap.isOpened()):
ret, frame = cap.read() # Get the next frame.
Expand Down

0 comments on commit fbb92b8

Please sign in to comment.