Commit Graph

922 Commits

Author SHA1 Message Date
Nicolas Mowen
761daf46ea
Refactor Recordings (#7275)
* Run ffmpeg sub process & video_properties as async

* Run recording cleanup in the main process

* More cleanup

* Use inter process communication to write recordings into the DB

* Formatting
2023-07-26 05:55:08 -05:00
Nicolas Mowen
9016a48dc7
Refactor Audio Events To Use stdout Pipe (#7291)
* Cleanup audio detection

* Read audio frames from ffmpeg process directly

* Handle case where process has stopped
2023-07-26 05:51:45 -05:00
Andrew Reiter
a96a951e23
Nvidia Jetson ffmpeg + TensorRT support (#6458)
* Non-Jetson changes

Required for later commits:
- Allow base image to be overridden (and don't assume its WORKDIR)
- Ensure python3.9
- Map hwaccel decode presets as strings instead of lists
Not required:
- Fix existing documentation
- Simplify hwaccel scale logic

* Prepare for multi-arch tensorrt build

* Add tensorrt images for Jetson boards

* Add Jetson ffmpeg hwaccel

* Update docs

* Add CODEOWNERS

* CI

* Change default model from yolov7-tiny-416 to yolov7-320

In my experience the tiny models perform markedly worse without being
much faster

* fixup! Update docs
2023-07-26 05:50:41 -05:00
Nicolas Mowen
d30a738960
Show status when mask is saved (#7212) 2023-07-21 07:30:22 -05:00
Nicolas Mowen
bfa7a5cc60
db improvements (#7227)
* Store camera labels in dict and other optimizations

* Add max on timeout so it is at least 60

* Ensure db timeout is at least 60

* Update list once a day to ensure new labels are cleaned up

* Formatting

* Insert recordings as bulk instead of individually.

* Fix

* Refactor event and timeline cleanup

* Remove unused
2023-07-21 07:29:50 -05:00
Nicolas Mowen
b655eca152
Set supported ptz features in init to not fail when camera has an error (#7228) 2023-07-21 07:27:07 -05:00
Nicolas Mowen
f2ff55dba2
Set timeout based on number of cameras (#7219) 2023-07-19 07:42:32 -05:00
Nicolas Mowen
c5b8d13beb
Save audio scores and add audio filter config (#7185)
* Send and save score for external events

* Add audio filters config

* Fix access

* Add docs

* Cleanup
2023-07-17 06:07:15 -05:00
Nicolas Mowen
dacf45cd88
Add tests for recordings retention and fix bug (#7183)
* Add tests for segment info

* Fix logic
2023-07-16 13:07:15 -05:00
Nicolas Mowen
662025a961
Remove faster_fifo (#7181)
* Remove faster_fifo

* Remove const
2023-07-16 07:42:56 -05:00
Nicolas Mowen
8e584cf844
Add option for enabling sync recordings (#7169) 2023-07-15 08:38:21 -05:00
Nicolas Mowen
d0873631cc
Fix logic (#7165) 2023-07-14 20:46:01 -05:00
Nicolas Mowen
dfd3fcdff6
Publish audio detections (#7159)
* Send mqtt message when audio is detected

* Fix value

* Add audio topics to mqtt docs and add mqtt headers

* Use existing standard for values

* Update mqtt.md
2023-07-14 19:06:00 -05:00
Nicolas Mowen
00016b7499
Save average dBFS and retain segment with dBFS in motion mode (#7158)
* Hold audio info queue for recordings

* Add dBFS to db

* Cleanup

* Formatting

* Fix check
2023-07-14 19:05:14 -05:00
Nate Meyer
5bb5e2dc5a
Add check for valid label index for object detection (#7149) (#7164) 2023-07-14 19:01:53 -05:00
Josh Hawkins
dc2e786a6f
remove sleeps and improve queue logic (#7163) 2023-07-14 19:01:10 -05:00
Nicolas Mowen
598ae98bfe
Fix incorrect import in Config (#7157) 2023-07-14 06:32:17 -06:00
Sergey Krashevich
ce3a544ecd
Feature: automatic camera resolution configuration (#6810)
* Add auto configuration for height, width and fps in detect role

* Add auto-configuration for detect width, height, and fps for input roles with detect in the CameraConfig class in config.py

* Refactor code to retrieve video properties from input stream in CameraConfig class and add optional parameter to retrieve video duration in get_video_properties function

* format

* Set default detect dimensions to 1280x720 and update DetectConfig to use the defaults

* Revert "Set default detect dimensions to 1280x720 and update DetectConfig to use the defaults"

This reverts commit a1aed0414d.

* Add default detect dimensions if autoconfiguration failed and log a warning message

* fix warn message spelling on frigate/config.py

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* Ensure detect height and width are not None before using them in camera configuration

* docs: initial commit

* rename streamInfo to stream_info

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

* Apply suggestions from code review

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* Update docs

* handle case then get_video_properties returns 0x0 dimension

* Set detect resolution based on stream properties if available, else apply default values

* Update FrigateConfig to set default values for stream_info if resolution detection fails

* Update camera detection dimensions based on stream information if available

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-07-14 06:56:03 -05:00
Sergey Krashevich
6ac36e8436
Fix: Add limit to event query (#7108)
* Add limit to event query for fetching latest event with specified label and camera name

* Refactor the label_thumbnail function in frigate/http.py to simplify the event_query logic and improve code readability
2023-07-14 06:30:47 -05:00
Nicolas Mowen
3a0c36e8db
Refactor ff queue size (#7116)
* Refactor queue size

* Only use enabled cameras

* Formatting
2023-07-14 06:29:11 -05:00
Nicolas Mowen
6adc810145
Sub label api score (#7113)
* Support setting sub label scores via API

* Update docs

* Update docs

* Formatting

* Throw error when score is outside expected bounds

* Fix / cleanup
2023-07-14 06:28:16 -05:00
jpverdejo
b909ff4ecb
Expose dBFS when doing audio analysis (#6979)
* Expose dBFS when doing audio analysis

* Implement metadata communicator

* revert test changes

* Reverting the tests changes. For real this time

* Address feedback

* Address feedback

* Address feedback

* Address feedback
2023-07-13 19:52:33 -05:00
Josh Hawkins
c9254b256a
Autotracking: reset motion estimator (#7129)
* reset motion estimator after returning to preset

* small tweaks and a bugfix
2023-07-13 05:32:51 -05:00
Josh Hawkins
7a2d09dc35
Autotracking optimizations (#7109)
* much improved motion estimation and tracking

* docs updates

* move ptz specific mp values to ptz_metrics dict

* only check if moving at frame time

* pass full dict instead of individual values
2023-07-11 06:23:20 -05:00
Blake Blackshear
7c0d25f9da
Attribute scores (#7100)
* rework attributes to get scores

* show sublabel score

* formatting
2023-07-09 11:40:39 -05:00
Markus
5e772c3625
fix edgetpu device type "None" (auto) (#7097) 2023-07-08 16:04:51 -05:00
Josh Hawkins
691e9d26d2
Autotracking fixes (#7096)
* only check camera status if autotracking enabled

* a more sensible sleep time

* Only check camera status if preparing for a move

* only update tracked obj position when ptz stopped

* both pantilt *and* zoom should be idle

* check more often after moving

* No need to move pan and tilt separately
2023-07-08 16:02:54 -05:00
Nicolas Mowen
f37f034b6a
Only run audio detection when audio is above noise threshold (#7078)
* Only run audio detection when audio is above noise threshold

* Formatting

* Fix event parsing

* Update frigate/events/audio.py

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-07-08 07:16:24 -05:00
Josh Hawkins
88fc0fac8f
Basic PTZ object autotracking functionality (#6913)
* Basic functionality

* Threaded motion estimator

* Revert "Threaded motion estimator"

This reverts commit 3171801607.

* Don't detect motion when ptz is moving

* fix motion logic

* fix mypy error

* Add threaded queue for movement for slower ptzs

* Move queues per camera

* Move autotracker start to app.py

* iou value for tracked object

* mqtt callback

* tracked object should be initially motionless

* only draw thicker box if autotracking is enabled

* Init if enabled when initially disabled in config

* Fix init

* Thread names

* Always use motion estimator

* docs

* clarify fov support

* remove size ratio

* use mp event instead of value for ptz status

* update autotrack at half fps

* fix merge conflict

* fix event type for mypy

* clean up

* Clean up

* remove unused code

* merge conflict fix

* docs: update link to object_detectors page

* Update docs/docs/configuration/autotracking.md

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* clarify wording

* pass actual instances directly

* default return preset

* fix type

* Error message when onvif init fails

* disable autotracking if onvif init fails

* disable autotracking if onvif init fails

* ptz module

* verify required_zones in config

* update util after dev merge

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-07-08 07:04:47 -05:00
Nicolas Mowen
d6f82f9edc
Fix queues (#7087)
* Fix queues

* Change name

* Use standard queue for limited queue

* remove unused

* isort
2023-07-08 06:46:31 -05:00
Nicolas Mowen
69630e7385
Fix incorrect respnses (#7066) 2023-07-07 07:06:42 -05:00
Nate Meyer
dd02958f7c
Upgrade TensorRT to 8.5.3 (#7006)
* Update to latest tensorrt (8.6.1) release

* Build trt libyolo_layer.so in container

* Update tensorrt_models script to convert models from the frigate container

* Fix typo in model script

* Fix paths to yolo lib and models folder

* Add S6 scripts to test and convert specified TensortRT models at startup.

Rearrange tensorrt files into a docker support folder.

* Update TensorRT documentation to reflect the new model conversion process and minimum HW support.

* Fix model_cache path to live in config directory

* Move tensorrt s6 files to the correct directory

* Fix issues in model generation script

* Disable global timeout for s6 services

* Add version folder to tensorrt model_cache path

* Include TensorRT version 8.5.3

* Add numpy requirement prior to removal of np.bool

* This TRT version uses a mixture of cuda dependencies

* Redirect stdout from noisy model conversion
2023-07-06 14:20:33 -05:00
Sergey Krashevich
30dfdf47d4
Add thread-safety to LimitedQueue by implementing a lock for put and get methods (#7053) 2023-07-06 13:54:55 -05:00
Sergey Krashevich
f48dd8c1ab
Feature: camera debug/config enhancements (#6920)
* Add functionality to update YAML config file with PUT request in HTTP endpoint

* Refactor copying of text to clipboard with Clipboard API and fallback to document.execCommand('copy') in CameraMap.jsx file

* Update YAML file from URL query parameters in frigate/http.py and add functionality to save motion masks, zones, and object masks in CameraMap.jsx

* formatting

* fix merging fuckup

* Refactor camera zone coordinate saving to use single query parameter per zone in CameraMap.jsx

* remove unnecessary print statements in util.py

* Refactor update_yaml_file function to separate the logic for updating YAML data into a new function update_yaml().

* fix merge errors

* Refactor code to improve error handling and add dependencies to useEffect hooks
2023-07-06 13:54:26 -05:00
Sergey Krashevich
cbb77e5794
Bugfix: SqliteQueueDatabase instead of SqliteDatabase and retry_interval for fetching latest frame in http.py (#7059)
* Refactor http.py to use SqliteQueueDatabase instead of SqliteDatabase and add retry interval for fetching latest frame

* isort && black
2023-07-06 13:50:22 -05:00
Nicolas Mowen
baf671b764
Cleanup and organize utils (#7033)
* Force birdseye cameras into standard aspect ratios

* Organize utils

* Update tests

* Formatting

* Isort

* Fix tests

* Cleanup

* isort
2023-07-06 09:28:50 -05:00
Cody Cutrer
2fae9dcb93
reduce contention on frame_queue (#6890)
* reduce contention on frame_queue

don't check if the queue is full, just attempt to add the frame
in a non-blocking manner, and then if it fails, skip it

* don't check if the frame queue is empty, just try and get from it

* Update frigate/video.py

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-07-06 08:18:39 -05:00
Sergey Krashevich
c38c981cd0
Performance: multiprocessing improvement: step 2 (#6986)
* Refactored queues to use faster_fifo instead of mp.Queue

* Refactored LimitedQueue to include a counter for the number of items in the queue and updated put and get methods to use the counter

* Refactor app.py and util.py to use a custom Queue implementation called LQueue instead of the existing Queue

* Refactor put and get methods in LimitedQueue to handle queue size and blocking behavior more efficiently

* code format

* remove code from other branch (merging fuckup)
2023-07-06 07:56:38 -05:00
Nicolas Mowen
d0891e5183
Ptz cleanup (#6999)
* Use _ instead of - for ptz presets

* Update mqtt.md

* Fix

* Formatting
2023-07-06 07:42:17 -05:00
Andrew Reiter
325205740b
Check ffmpeg version instead of checking for presence of BTBN_PATH (#7023)
* Check ffmpeg version instead of checking for presence of BTBN_PATH

* Query ffmpeg version in s6 run script instead of subprocessing in every import

* Define LIBAVFORMAT_VERSION_MAJOR in devcontainer too

* Formatting

* Default ffmpeg version to current btbn version so unit tests pass
2023-07-06 07:35:26 -05:00
Andrew Reiter
f30ba25444
Reduce framerate before downscaling (#7022)
* Reduce framerate before downscaling

It is cheaper to drop frames and downscale those that remain than it is
to downscale all frames and then drop some of them. This is achieved
with the filter chain `-cv fps=FPS,scale=W:H`, and perhaps was the
original intention. The plain `-r` and `-s` flags do not execute in
order though - they each put themselves at the *end* of the filterchain,
so `-r FPS -s WxH` actually applies the scale filter first, and then the
rate filter.

This fix can halve the CPU used by the detect ffmpeg process.

* Bring back hard rate limits
2023-07-06 07:31:17 -05:00
Nicolas Mowen
339b6944f1
Force birdseye cameras into standard aspect ratios (#7026)
* Force birdseye cameras into standard aspect ratios

* Clarify comment

* Formatting

* Actually use the calculated aspect ratio when building the layout

* Fix Y aspect

* Force canvas into known aspect ratio as well

* Save canvas size and don't recalculate

* Cache coefficients that are used for different size layouts

* Further optimize calculations to not be done multiple times
2023-07-06 07:30:05 -05:00
Nicolas Mowen
0f68fbc8db
Use pre capture for custom events (#7038)
* Use pre capture for custom events

* Formatting
2023-07-06 07:26:53 -05:00
Nicolas Mowen
998bffe706
Fix min region size not being divisible by 4 (#7040)
* Fix min region size not being divisible by 4

* Simplify half calculation
2023-07-06 07:25:37 -05:00
Sergey Krashevich
12d4a47e3d
End audio event and update detections if successful, otherwise log a warning if ending audio event fails with a specific status code (#6984) 2023-07-03 09:50:25 -05:00
Sergey Krashevich
f905704479
UI: add audio process stats to System page (#6993)
* Add audio process PID to the list of processes and log the start of the audio process

* Update audio process PID key in processes dictionary to "audioDetector" instead of "audio".
2023-07-03 09:48:29 -05:00
Nicolas Mowen
58c6ef1e12
Add designator when events are from the api (#6997)
* Add designator when events are custom

* Add type field and set via API
2023-07-03 09:48:00 -05:00
Nicolas Mowen
83edf9574e
Scale birdseye layout up to max size after it has been calculated (#6825)
* Scale layout up to max size after it has been calculated

* Limit portrait cameras to taking up 2 rows

* Fix bug

* Fix birdsye not removing cameras once objects are no longer visible

* Fix lint
2023-07-02 07:45:45 -05:00
Nicolas Mowen
c25367221e
Fix audio events not being ended (#6981)
* Fix audio events not being ended

* Fix audio events not being ended correctly

* Clean up debug code
2023-07-01 16:33:47 -05:00
Nicolas Mowen
7ee17c7af8
Fix small audio events details (#6978)
* Fix missed audio details

* Add mqtt docs

* Delete instead of setting to None
2023-07-01 11:19:14 -05:00