Skip to content

Commit

Permalink
Added video framerate snapping
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Sep 4, 2024
1 parent c3163a2 commit 8e2f27b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ This update focuses on unifying Predator's different modes to allow multipurpose
- 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.
- A threshold can be set to allow Predator to round up to the maximum framerate if it is within a small difference.
- Added a per-device configuration to set a minimum expected frame-rate, below which a warning is displayed. This value does not have any impact on the actual recording frame-rate.
- Overhauled dash-cam saving.
- Frames captured during dash-cam recording are now saved in a separate thread.
Expand Down Expand Up @@ -480,16 +481,17 @@ This update focuses on unifying Predator's different modes to allow multipurpose
- Dashcam video save events can now be triggered using buttons via GPIO pins.
- Improved looped recording.
- Each thread now checks to see if old segments have already been deleted before deleting them themselves.
- Added optional background ALPR to dash-cam mode.
- The user can now configure Predator to conduct ALPR in the background while simultaneously capturing video.
- Removed the old "background recording" functionality in real-time mode, and it's corresponding configuration value.
- Updated status lighting.
- 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.
- Updated configuration back-end.
- 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.
- Added optional background ALPR to dash-cam mode.
- The user can now configure Predator to conduct ALPR in the background while simultaneously capturing video.
- Removed the old "background recording" functionality in real-time mode, and it's corresponding configuration value.
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ These are the features actively planned for Predator and are likely to be added
- [X] Add default config support for values that involve adding entries.
- [X] Improve the efficiency of the GPS stamp.
- [X] Check to see if old dashcam video files actually exist before deleting them.
- [ ] Test GPS behavior.
- [X] Test GPS behavior.
- [X] Finish video framerate snapping.

## Hypothetical

Expand Down
2 changes: 1 addition & 1 deletion assets/support/configdefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"max_deletions_per_round": 10
}
},
"framerate_snap": 0.5
"framerate_snap": 0.1
},
"capture": {
"video": {
Expand Down
4 changes: 2 additions & 2 deletions dashcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ def dashcam_output_handler(directory, device, width, height, framerate):
save_this_segment = False # This will be set to True when the saving trigger is created. The current and previous dashcam segments are saved immediately when the trigger is created, but this allows the completed segment to be saved once the next segment is started, such that the saved segment doesn't cut off at the moment the user triggered a save.

process_timing("start", "Dashcam/Calculations")
if (framerate + 0.2 >= float(config["dashcam"]["capture"]["video"]["devices"][device]["framerate"]["max"])): # Check to see if the frame-rate benchmark is within 0.2FPS of the maximum allowed framerate.
if (framerate + config["dashcam"]["saving"]["framerate_snap"] >= float(config["dashcam"]["capture"]["video"]["devices"][device]["framerate"]["max"])): # Check to see if the frame-rate benchmark is within 0.2FPS of the maximum allowed framerate.
framerate = float(config["dashcam"]["capture"]["video"]["devices"][device]["framerate"]["max"]) # Set the frame-rate to the maximum allowed frame-rate.
process_timing("end", "Dashcam/Calculations")

Expand Down Expand Up @@ -973,7 +973,7 @@ def dashcam_output_handler(directory, device, width, height, framerate):
output = cv2.VideoWriter(current_segment_name[device] + "." + config["dashcam"]["saving"]["file"]["extension"], cv2.VideoWriter_fourcc(output_codec[0], output_codec[1], output_codec[2], output_codec[3]), float(calculated_framerate[device]), (width, height)) # Start the new video output file.

process_timing("start", "Dashcam/Calculations")
if (calculated_framerate[device] > float(config["dashcam"]["capture"]["video"]["devices"][device]["framerate"]["max"])): # Check to see if the calculated frame-rate exceeds the maximum allowed frame-rate.
if (calculated_framerate[device] + config["dashcam"]["saving"]["framerate_snap"] >= float(config["dashcam"]["capture"]["video"]["devices"][device]["framerate"]["max"])): # Check to see if the frame-rate benchmark is within 0.2FPS of the maximum allowed framerate.
calculated_framerate[device] = float(config["dashcam"]["capture"]["video"]["devices"][device]["framerate"]["max"]) # Set the frame-rate to the maximum allowed frame-rate.
process_timing("end", "Dashcam/Calculations")
process_timing("start", "Dashcam/Writing")
Expand Down

0 comments on commit 8e2f27b

Please sign in to comment.