Commit Graph

1022 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
Nicolas Mowen
c3b313a70d
Audio events (#6848)
* Initial audio classification model implementation

* fix mypy

* Keep audio labelmap local

* Cleanup

* Start adding config for audio

* Add the detector

* Add audio detection process keypoints

* Build out base config

* Load labelmap correctly

* Fix config bugs

* Start audio process

* Fix startup issues

* Try to cleanup restarting

* Add ffmpeg input args

* Get audio detection working

* Save event to db

* End events if not heard for 30 seconds

* Use not heard config

* Stop ffmpeg when shutting down

* Fixes

* End events correctly

* Use api instead of event queue to save audio events

* Get events working

* Close threads when stop event is sent

* remove unused

* Only start audio process if at least one camera is enabled

* Add const for float

* Cleanup labelmap

* Add audio icon in frontend

* Add ability to toggle audio with mqtt

* Set initial audio value

* Fix audio enabling

* Close logpipe

* Isort

* Formatting

* Fix web tests

* Fix web tests

* Handle cases where args are a string

* Remove log

* Cleanup process close

* Use correct field

* Simplify if statement

* Use var for localhost

* Add audio detectors docs

* Add restream docs to mention audio detection

* Add full config docs

* Fix links to other docs

---------

Co-authored-by: Jason Hunter <hunterjm@gmail.com>
2023-07-01 08:18:33 -05:00
Blake Blackshear
2f401bd8da
update deps (#6973)
* update web deps

* update python deps
2023-07-01 07:47:16 -05:00
Nicolas Mowen
f3f9b36e07
Fix bad check on np.array (#6968) 2023-06-30 07:06:38 -06:00
Nicolas Mowen
0a8249d6fb
Fix Bad Resize For Camera Snapshot (#6797)
* Catch cases where incorrect size is requested

* Set a default if calculated height is incorrect
2023-06-30 07:34:10 -05:00
Blake Blackshear
d51197eaa2
use a different method for blur and contrast to reduce CPU (#6940)
* use a different method for blur and contrast to reduce CPU

* blur with radius instead

* use faster interpolation for motion

* improve contrast based on averages

* increase default threshold to 30

* ensure mask is applied after contrast improvement

* update opencv

* update benchmark script
2023-06-30 07:27:31 -05:00
Nicolas Mowen
d2a2643cd6
Apply zone filter before inertia (#6854)
* Apply zone filter before intertia

* Formatting
2023-06-30 07:15:55 -05:00
spacebares
ed0d2be321
configurable ffmpeg timeout (#6897)
* configurable ffmpeg timeout

* configurable ffmpeg healthcheck interval

rename timeout to healthcheck_interval
only grab config value once

* configurable ffmpeg retry interval

rename healthcheck_interval to retry_interval

* add retry_interval to docs

- update retry_interval text in config.py
2023-06-30 07:14:39 -05:00
Nicolas Mowen
9137f1594b
Remove legacy recordings file cleanup (#6947)
* Remove legacy recordings file cleanup

* Remove unused
2023-06-30 07:13:00 -05:00
Cody Cutrer
ef14a43930
optimize frame-per-second calculations (#6887)
* optimize frame-per-second calculations

FPS is never calculated over differing periods for even given
counter. By only storing timestamps within the period that is
used, we avoid having to iterate 1000 entries every time it's
re-calculated (multiple times per second). 1000 entries would
normally only be needed if something is running at 100fps. A
more common speed - anywhere from 5 to 30fps, only needs 50
to 300 entries.

This isn't a huge improvement in the grand scheme, but when motion
detection is disabled, it takes nearly as much time in a flamegraph
as actually transferring the video frame.

* fix python checks
2023-06-28 05:55:53 -05:00
Cody Cutrer
ee4a133655
actually keep track of skipped frames (#6889)
* actually keep track of skipped frames

fixes #6863

* fix black errors
2023-06-28 05:53:28 -05:00
Nicolas Mowen
ece070fee1
Load labels dynamically for event filters (#6896)
* Load labels dynamically to include custom events and audio, do not include attribute labels

* Formatting

* Fix sorting

* Also filter tracked object list on camera page

* isort

* Don't fail before load
2023-06-28 05:51:53 -05:00
Sergey Krashevich
e640981cc4
Performance: multiprocessing improvement (#6936)
* Add faster-fifo dependency for improved performance

* isort
2023-06-28 05:39:39 -05:00
Blake Blackshear
9e531b0b5b
reduce grid size for contrast improvement (#6870) 2023-06-21 08:38:51 -05:00
Blake Blackshear
7c1568fcb9
use clahe for contrast improvement (#6835)
* use clahe for contrast improvement

* update tests
2023-06-18 11:56:41 -05:00
Nicolas Mowen
09cc4251f0
Fix dict getting overwritten (#6830) 2023-06-17 10:31:35 -05:00
Blake Blackshear
793fe251b9
Label attributes (#6829)
* pass attribute labels as attributes

* add label attrs to events and snapshots

* incorporate area of license_plate and face into snapshot selection

* populate sublabels for cars with logos
2023-06-17 09:56:22 -05:00
Nicolas Mowen
2be2050d57
Don't fail to save segment when cv2 fails (#6823)
* Don't fail when cv2 fails

* Clean up exception handling
2023-06-17 09:56:00 -05:00
Nicolas Mowen
b66810247e
Optimize stacked recordings (#6809)
* Make camera recordings mover asynchronous

* Formatting

* Move to using cv2 instead of external ffmpeg process

* Use ffprobe if cv2 failed

* Formatting

* Fix bad access

* Formatting

* Update frigate/record/maintainer.py

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

* Update name of caller

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-06-16 07:09:13 -06:00
Nicolas Mowen
0592cedcde
Rewrite birdseye auto layout (#6818)
* Prefer horizontal layout to vertical

* Rewrite birdseye to use aspect ratios instead of resolutions as layout configurator

* Improve layout with slightly larger than 16:9 cameras

* Remove manual 2 camera layout

* Lint

* Remove log
2023-06-16 07:35:36 -05:00
Blake Blackshear
ca7853c087
Fix max_frames, improve stationary objects in masked areas (#6815)
* fix issue with max_frames

* dont consider stationary until the threshold

* require a stationary interval

* try to fix formatter issues
2023-06-16 07:32:43 -05:00
Sergey Krashevich
3efa77f302
Round the timestamp value read from .vacuum file to prevent potential errors caused by float values (#6800) 2023-06-14 17:19:26 -05:00
Nicolas Mowen
7e5abe7a65
Optimize Birdseye layout for portrait cameras (#6779)
* Handle vertical cameras more optimally in 2 camera layout

* Optimize portrait layout for 3+ cams

* Remove logging
2023-06-12 17:39:12 -05:00
Nicolas Mowen
ec4d79eafc
Fix bug in intersection logic (#6780)
* Fix bug in intersection logic

* Fix isort

* Remove unrelated test

* Formatting

* Fix type in test
2023-06-12 17:38:22 -05:00
Nicolas Mowen
ff90db30e6
Various Bug Fixes (#6768)
* Fix birdseye infinite loop

* Fix division by zero
2023-06-12 06:06:02 -04:00
Sergey Krashevich
dfd574beeb
Refactor storage stats calculation to use powers of 2 for more accurate values (#6765)
* "Refactor storage stats calculation to use powers of 2 for more accurate values"

* replace 1000000 to 2^20

* Refactor storage unit size display to use binary prefixes

This commit updates the display of storage unit sizes in both the camera storage stats and the Storage component in the web UI to use binary prefixes (MiB and GiB) instead of decimal prefixes (MB and GB). This provides more accurate and consistent representation of storage sizes
2023-06-11 14:49:13 -05:00
Nicolas Mowen
0f1cf67b91
Fix birdseye optimistic approach (#6764) 2023-06-11 08:47:34 -05:00
Blake Blackshear
d81dd60fef
Improve motion detection and region selection (#6741)
* refactor existing motion detector

* implement and use cnt bgsub

* pass fps to motion detector

* create a simplified motion detector

* lightning detection

* update default motion config

* lint imports

* use estimated boxes for regions

* use improved motion detector

* update test

* use a different strategy for clustering motion and object boxes

* increase alpha during calibration

* simplify object consolidation

* add some reasonable constraints to the estimated box

* adjust cluster boundary to 10%

* refactor

* add disabled debug code

* fix variable scope
2023-06-11 08:45:11 -05:00
Nicolas Mowen
32569842d3
Option to enable / disable stats that require external processes (#6615)
* Add option for network bandwidth and only calculate if enabled

* Don't show network bandwidth in system stats page if not enabled

* Formatting

* Hide other rows as well

* Add docs

* Add config options for AMD and Intel GPU stats

* Fix stats access

* Update docs

* Use correct bool syntax

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

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-06-11 08:26:34 -05:00
Sergey Krashevich
5c27cb7e9b
Optimization of Sync Records: Implementing Pagination and Temporary Table (#6585)
* Update pull_request.yml

* Add temporary table for deletion and use pagination to process recordings in chunks for deletion of recordings with missing files

* move RecordingsToDelete class to models.py

* recording cleanup: bugfixes

* Update cleanup.py

* improve log message in cleanup.py

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

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-06-11 08:01:50 -05:00
Nicolas Mowen
b160abac0d
Ability to configure min frames for zone presence (#6680)
* Objects need to be in zones multiple times to be considered present in the zone

* Add a field to configure inertia per zone

* Formatting

* Use correct default method

* Clarify zone presence behavior

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

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-06-11 08:00:53 -05:00
Nicolas Mowen
fd6eb78f41
Birdseye Autolayout (#6734)
* Calculate possible layout

* Working in ideal conditions

* Fix issues with different heights

* Remove logs

* Optimally handle cameras that don't match the canvas aspect ratio

* Make sure to copy so list is not overwritten

* Remove unused import

* Remove try catch

* Optimize layout for low amount of cameras

* Try to scale frames up if not enough space is used
2023-06-11 07:54:18 -05:00
Sergey Krashevich
8d941e5e26
Add function to get physical interfaces for bandwidth calculation (#6618)
* Add function to get physical interfaces for bandwidth calculation in get_bandwidth_stats() function

* Add telemetry configuration option for enabled network interfaces, with default values for monitoring bandwidth stats for camera ffmpeg processes, go2rtc, and object detectors. Also add support for FrigateConfig in set_bandwidth_stats function to get bandwidth stats for specified network interfaces
2023-06-11 07:34:03 -05:00
Nicolas Mowen
8bc76d19db
DB Optimizations (#6712)
* Enable auto vacuums

* Enable auto vacuum

* Fix separator

* Fix separator and remove incorrect log

* Limit to 1 row since that is all that is used

* Add index on camera + segment_size

* Formatting

* Increase timeout and cache_size

* Set DB mode to NORMAL synchronous level

* Formatting

* Vacuum every 2 weeks

* Remove fstring

* Use string

* Use consts
2023-06-11 07:23:18 -05:00
Nicolas Mowen
435d152423
Fix bug introduced in new linter (#6754)
* Fix bug introduced in new linter

* Ignore this error

* Fix more

* Ignore boolean error too
2023-06-11 07:18:47 -05:00
Nicolas Mowen
d3949eebfa
Add API and WebUI to export recordings (#6550)
* Add ability to export frigate clips

* Add http endpoint

* Add dir to nginx

* Add webUI

* Formatting

* Cleanup unused

* Optimize timelapse

* Fix pts

* Use JSON body for params

* Use hwaccel to encode when available

* Print ffmpeg command when fail

* Print ffmpeg command when fail

* Add separate ffmpeg preset for timelapse

* Add docs outlining the export directory

* Add export docs

* Use ''

* Fix playlist max time

* Lower max playlist time

* Add api docs for export

* isort fixes
2023-06-08 07:32:35 -04:00
Nicolas Mowen
62f36b221e
Remove ffmpeg banner (#6600)
* Hide banner in maintainer

* Hide banner in event download
2023-06-01 05:46:34 -05:00
Blake Blackshear
ae0aba44dc
Improve tracking (#6516) 2023-05-31 08:12:43 -06:00
Martin Weinelt
ab50d0b006
Add isort and ruff linter (#6575)
* Add isort and ruff linter

Both linters are pretty common among modern python code bases.

The isort tool provides stable sorting and grouping, as well as pruning
of unused imports.

Ruff is a modern linter, that is very fast due to being written in rust.
It can detect many common issues in a python codebase.

Removes the pylint dev requirement, since ruff replaces it.

* treewide: fix issues detected by ruff

* treewide: fix bare except clauses

* .devcontainer: Set up isort

* treewide: optimize imports

* treewide: apply black

* treewide: make regex patterns raw strings

This is necessary for escape sequences to be properly recognized.
2023-05-29 05:31:17 -05:00
Martin Weinelt
1e17dbaa91
deepstack: pass api key in request (#6579)
The POST data was prepared, but not passed into the request call.
2023-05-23 17:32:08 -05:00
Nicolas Mowen
f66ccb04f6
Fix pydantic (#6584) 2023-05-23 08:00:21 -06:00
Sergey Krashevich
11738110dc
Add handling for non-existent or empty model file paths (#6525)
* Add handling for non-existent or empty model file paths in `compute_model_hash()` method

* Remove print() in detector_config.py

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

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-05-21 08:29:57 -05:00
Nicolas Mowen
4940826011
Fix false positives (#6544) 2023-05-19 13:26:19 -06:00
Nicolas Mowen
fec1dd3f46
Fix breakages by manual_event_api branch (#6542)
* Fix breakages by manual_event_api branch

* More fixes
2023-05-19 10:59:24 -06:00
Blake Blackshear
42f3ee3de5 sync master 2023-05-19 05:47:49 -05:00
Nicolas Mowen
e357715a8c
Ability to manually create events through the API (#3184)
* Move to events package

* Improve handling of external events

* Handle external events in the event queue

* Pass in event processor

* Check event json

* Fix json parsing and change defaults

* Fix snapshot saving

* Hide % score when not available

* Correct docs and add json example

* Save event png db

* Adjust image

* Formatting

* Add catch for failure ending event

* Add init to modules

* Fix naming

* Formatting

* Fix http creation

* fix test

* Change to PUT and include response in docs

* Add ability to set bounding box locations in snapshot

* Support multiple box annotations

* Cleanup docs example response

Co-authored-by: Blake Blackshear <blake@frigate.video>

* Cleanup docs wording

Co-authored-by: Blake Blackshear <blake@frigate.video>

* Store full frame for thumbnail

* Formatting

* Set thumbnail height to 175

* Formatting

---------

Co-authored-by: Blake Blackshear <blake@frigate.video>
2023-05-19 05:16:11 -05:00
Sergey Krashevich
6d0c2ec5c8
Add go2rtc & remote detectors network bandwidth usage to System table (#6526)
* Add network bandwidth usage to System table display in System.jsx and update get_bandwidth_stats function in util.py to include go2rtc processes

* black...

* Add network bandwidth usage to system table in web UI and improve regex in get_bandwidth_stats function to include frigate detector processes

* black...

* Update bandwidth calculation to include both incoming and outgoing traffic

* black:(
2023-05-18 06:40:24 -05:00
Korneliusz Jarzębski
17e8a46c7d
add ffmpeg bandwidth stats (#6492)
* add ffmpeg bandwidth stats

* add ffmpeg bandwidth stats

* Change column name

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

* fix lint formatting

---------

Co-authored-by: Korneliusz Jarzębski <k.jarzebski@netverse.pl>
Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-05-17 20:01:56 -05:00
Nicolas Mowen
b568a29fa8
Don't fail if camera does not support presets (#6497) 2023-05-17 07:42:56 -05:00
Sergey Krashevich
b4038821cc
Update DeepStack detector to set width and height from input image size (#6429) 2023-05-17 07:40:41 -05:00
Sergey Krashevich
5fb96c777a
Add cmdline information to CPU usage stats in get_cpu_stats() function and display it in the System page's ffmpeg table with a copy-to-clipboard button (#6430) 2023-05-15 07:39:03 -05:00
Sergey Krashevich
181b53a55d
Fix error in parsing DeepStack response JSON and handle cases where predictions field is missing (#6463) 2023-05-15 07:37:34 -05:00
Nicolas Mowen
5951a740d2
Prevent recordings from being turned on if disabled in config (#6444)
* Prevent enabling recordings if not enabled in config

* Fix conflict

* Fix spacing

* Update wording

* Update wording

---------

Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
2023-05-15 07:36:26 -05:00
Sergey Krashevich
ede1dedbbd
Add Deepstack/CodeProject-AI.Server detector plugin (#6143)
* Add Deepstack detector plugin with configurable API URL, timeout, and API key

* Update DeepStack plugin to recognize 'truck' as 'car' for label indexing

* Add debug logging to DeepStack plugin for better monitoring and troubleshooting

* Refactor DeepStack label loading from file to use merged labelmap

* Black format

* add documentation draft

* fix link to codeproject website

* Apply suggestions from code review

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

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-05-04 18:06:07 -05:00
Sergey Krashevich
0fcfcb85ab
Implement NVML for NVIDIA GPU Stats (#6359)
* nvml

* black...black...black...

* small fix for avoid errors on strange GPUs and old drivers

* fix type errors

* fix type errors

* fix unittest process crash

where the tests for tests?..

* it's impossible to mock low-level library

* fix double % for other GPU types

* remove space before gpu statistic values
2023-05-04 18:02:01 -05:00
Sergey Krashevich
03b45c153b
Increase maximum event sub_label length to 100 characters (#6350)
* Increase maximum sub label length to 100 characters and update corresponding fields in models and API

* black format...
2023-05-04 17:59:44 -05:00
Sergey Krashevich
2add675d42
Refactor Process Stats and Bugfixes (#6344)
* test refactor process stats

* Update util.py

* bugfix

* black formatting

* add missing processes field to StatsTrackingTypes class

* fix python checks and tests...

* use psutil for calcilate cpu utilization on get_cpu_stats

* black...black...black...

* add cpu average

* calculate statiscts for logger process

* add P-ID for other processes in System.jsx

* Apply suggestions from code review

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

* make page beautiful again :)

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-05-04 17:58:59 -05:00
Nicolas Mowen
305323c9e9
Update Rpi preset (#6385)
* Update Rpi preset

* Fix rpi test
2023-05-04 17:55:44 -05:00
Sergey Krashevich
b38c9e82e2
Replace subprocess usage with os module for better performance and maintainability (#6298)
* avoid executing external tools by using Python's built-in os module to interact with the filesystem directly

* Refactor recording cleanup script to use os module instead of subprocess

* black format util.py

* Ooooops

* Refactor get_cpu_stats() to properly identify recording process
2023-05-01 21:22:35 -05:00
Blake Blackshear
19890310fe
Bug fixes (#6332)
* fix timeline delete

* fix labelmap in config response

* create cache dirs if needed
2023-04-30 14:58:39 -05:00
Blake Blackshear
9bf98f908d
add plus integration for models (#6328) 2023-04-30 13:32:36 -05:00
Nicolas Mowen
ad52e238ce
Refactor events to be more generic (#6320)
* Organize event table to be more generalized

* Add appropriate fields to data

* Move tracked object logic to own function

* Add source type to event queue

* rename enum

* Fix types that are used in webUI

* remove redundant

* Formatting

* fix typing

* Rename enum
2023-04-30 12:07:14 -05:00
Nicolas Mowen
ca7790ff65
Cleanup timeline entries when relevant recording segments are removed (#6319)
* Cleanup timeline entries when relevant recording segments are removed

* Make timeline cleanup simpler

* Formatting
2023-04-30 09:28:21 -05:00
Nicolas Mowen
37360edbc1
Show other system processes in system page (#6276) 2023-04-28 07:47:49 -05:00
Nicolas Mowen
df016ddd0d
Fix http-jpeg template insertion (#6291) 2023-04-28 07:11:01 -05:00
Nicolas Mowen
b48f6d750f
Add annotation support (#6288) 2023-04-28 06:02:06 -05:00
Alin Balutoiu
83006eeb65
Add option to have cameras sorted inside the Birdseye stream (#5450)
* Add option to sort cameras inside Birdseye

* Make default order to be sorted alphabetically

* Add docs for sorting cameras

* Update index.md for cameras

* Remove irelevant comments
2023-04-26 19:29:01 -05:00
Nicolas Mowen
e451f44ced
Move recording management to separate process (#6248)
* Move recordings management to own process and ensure db multiprocess access

* remove reference to old threads

* Cleanup directory remover

* Mypy fixes

* Fix mypy

* Add support back for setting record via MQTT and WS

* Formatting

* Fix rebase issue
2023-04-26 07:25:26 -06:00
Nicolas Mowen
43ade86796
Support Controlling PTZ Cameras Via WebUI (#4715)
* Add support for ptz commands via websocket

* Fix startup issues

* Fix bugs

* Set config manually

* Add more commands

* Add presets

* Add zooming

* Fixes

* Set name

* Cleanup

* Add ability to set presets from UI

* Add ability to set preset from UI

* Cleanup for errors

* Ui tweaks

* Add visual design for pan / tilt

* Add pan/tilt support

* Support zooming

* Try to set wsdl

* Fix duplicate logs

* Catch auth errors

* Don't init onvif for disabled cameras

* Fix layout sizing

* Don't comment out

* Fix formatting

* Add ability to control camera with keyboard shortcuts

* Disallow user selection

* Fix mobile pressing

* Remove logs

* Substitute onvif password

* Add ptz controls ot birdseye

* Put wsdl back

* Add padding

* Formatting

* Catch onvif error

* Optimize layout for mobile and web

* Place ptz controls next to birdseye view in large layout

* Fix pt support

* Center text titles

* Update tests

* Update docs

* Write camera docs for PTZ

* Add MQTT docs for PTZ

* Add ptz info docs for http

* Fix test

* Make half width when full screen

* Fix preset panel logic

* Fix parsing

* Update mqtt.md

* Catch preset error

* Add onvif example to docs

* Remove template example from main camera docs
2023-04-26 06:08:53 -05:00
Blake Blackshear
0d16bd0144
False positives (#6217)
* add false positive submission

* switch timeline events to x,y,w,h

* update docs

* fix type checks

* convert to upsert

* fix config test
2023-04-24 07:24:28 -05:00
Felipe Santos
cdd8e6fd4e
Migrate default database path from /media/frigate to /config (#5219)
* Migrate db path to /config

* Ensure oneshot runs

* Put logic inside of Frigate's run

* Use new db default path in code

* Fix missing config dir

* Upgrade yq to 4.33.3
2023-04-23 11:35:40 -05:00
Nicolas Mowen
fbaab71d78
Metadata Timeline (#6194)
* Create timeline table

* Fix indexes

* Add other fields

* Adjust schema to be less descriptive

* Handle timeline queue from tracked object data

* Setup timeline queue in events

* Add source id for index

* Add other fields

* Fixes

* Formatting

* Store better data

* Add api with filtering

* Setup basic UI for timeline in events

* Cleanups

* Add recordings snapshot url

* Start working on timeline ui

* Add tooltip with info

* Improve icons

* Fix start time with clip

* Move player logic back to clips

* Make box in timeline relative coordinates

* Make region relative

* Get box overlay working

* Remove overlay when playing again

* Add disclaimer when selecting overlay points

* Add docs for new apis

* Fix mobile

* Fix docs

* Change color of bottom center box

* Fix vscode formatting
2023-04-23 10:45:19 -05:00
KtAlumi
366c31259f
Edit dsize order (#6172)
dsize could be (width, height).

Co-authored-by: kt.lu <kt.lu@latticeworkinc.com>
2023-04-22 21:38:58 -05:00
Martin Weinelt
cb73d0cd39
Migrate away from deprecated np.float (#5898)
It is an alias for the python float type, and got deprecated in 1.20 and
was removed in 1.24. The rest of the project already uses float32
(single), so I believe this is also correct here, as opposed to float64
(double).
2023-04-16 07:13:33 -05:00
Blake Blackshear
15415bab10
update deps (#6093)
* update dev deps

* update deps

* docs deps

* python dev deps

* update python deps
2023-04-15 14:17:59 -05:00
Nicolas Mowen
3b62ff093a
Ensure the frigate config validators are also checked when saving config (#6069) 2023-04-15 07:24:13 -05:00
Nicolas Mowen
6986949d84
Remove deprecated retain_days config (#5952) 2023-04-09 11:23:34 -05:00
Nicolas Mowen
3f17f871fa
Fix cleaning logs with rtsp in middle (#5800) 2023-03-21 17:21:37 -05:00
Blake Blackshear
2d9556f5f3
set threads to 2 (#5747) 2023-03-17 17:14:57 -05:00
Blake Blackshear
750bf0e79a
Revert "Update ffmpeg args with low risk improvements (#5519)" (#5715)
This reverts commit 52459bf348.
2023-03-14 08:25:27 -05:00
Dermot Duffy
e8d8cc4f55
Return sub_labels in event summary information. (#5642) 2023-03-05 11:39:41 -06:00
Martin Weinelt
161e7b3fd7
Allow using full tensorflow in cpu/edgetpu detector plugins (#5611)
It supports the same entrypoints, given that tflite is a small cut-out
of the big tensorflow picture.

This patch was created for downstream usage in nixpkgs, where we don't
have the tflite python package, but do have the full tensorflow package.
2023-03-03 17:44:17 -06:00
Nicolas Mowen
17c26c9fa9
Sub label filter fixes (#5602)
* Fix list access issue

* Specifically include item when in list or individual only

* Formatting

* Sort sub labels to ensure consistent list
2023-03-03 17:43:27 -06:00
Nicolas Mowen
318240c14c
Add docs for time / date styling (#5572)
* Add docs for time / date styling

* Convert 12hour time format option to enum

* Change option in web

* Add docs with examples

* Fix errors in docs

* Fix mismatched names
2023-02-26 09:37:18 -06:00
Nicolas Mowen
34bdf2fc10
Clean up output for vainfo and ffprobe (#5586)
* Clean up output for vainfo and ffprobe

* Fix cleanup

* Format vainfo display

* Fix ffprobe output

* Fix stringification

* remove unused
2023-02-26 07:05:27 -06:00
Nicolas Mowen
d97fa99ec5
Fix logging for corrupt segments (#5582)
* Fix logging for corrupt segments

* Formatting
2023-02-24 19:13:33 -06:00
Bernt Christian Egeland
3611e874ca
Events Page: Added option to override browser time format and style (#5538)
* use12hour optional config

* use12hour config arg

* added use12HourFormat arg to format function

* dateStyle & timeStyle option

* moved timezone & locales to format function

* added dateStyle & timeStyle

* re-formatted

* added strftime_fmt config entry

* strftime package

* added strftime option

* underscore instead of camelCase

* underscore props instead of camelCase
2023-02-22 06:54:16 -07:00
Nicolas Mowen
2797a60d4f
Don't fail if openvino fails to import (#5532)
* Don't fail if openvino fails to import

* Ensure all modules are imported safely

* Undo

* Fix list append
2023-02-19 07:41:14 -06:00
Anil Ozyalcin
0592c8b0e2
YOLOv5 & YOLOv8 support for the OpenVINO Detector (#5523)
* Initial commit that adds YOLOv5 and YOLOv8 support for OpenVINO detector

* Fixed double inference bug with YOLOv5 and YOLOv8

* Modified documentation to mention YOLOv5 and YOLOv8

* Changes to pass lint checks

* Change minimum threshold to improve model performance

* Fix link

* Clean up YOLO post-processing

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-02-19 07:39:47 -06:00
Nicolas Mowen
2b685ac343
Plus upload in progress (#5521)
* Fix frigate+ uploading bug

Fixes https://github.com/blakeblackshear/frigate/issues/5515

* wording

* Formatting

* Don't show button when event is in progress

* Don't show in download menu either
2023-02-19 07:38:16 -06:00
Nicolas Mowen
27d3676ba5
Fix rpi birdseye encode (#5522)
* Remove invalid bframe argument for rpi encoder

* Remove gop size arg as well
2023-02-16 18:38:32 -06:00
Nicolas Mowen
52459bf348
Update ffmpeg args with low risk improvements (#5519)
* Add threads 1 to input / output args

* Remove cuvid from hwaccel

* Update docs for new args

* Formatting
2023-02-16 15:44:10 -07:00
Nicolas Mowen
7b26935462
Ensure birdseye restream is not left with partially read frames (#5504)
* Ensure birdseye pipe does not get corrupted

* Fix conditionals

* Change log

* Formatting
2023-02-16 07:49:31 -06:00
Nicolas Mowen
1715e2e09d
Init birdseye restream command in S6 (#5494)
* remove restream from frigate logic

* Migrate birdseye stream definition to S6

* Cleanup

* Use consts to import as well
2023-02-15 07:09:25 -06:00
Nicolas Mowen
08ab9dedf7
Update ffmpeg_presets.py (#5462) 2023-02-12 08:02:40 -06:00
Nicolas Mowen
562e2627c2
Auto select gpu for hwaccel presets (#5406)
* Add ability to GPU device to be automatically detected when multiple exist

* Add logging info

* Fix access

* Fix

* Formatting

* Fix path of device

* Use log error instead of raise

* Remove log which could apply to other caess

* Set default value

* rework logic and support auto gpu selection for encoding gpu as well
2023-02-11 08:00:58 -06:00
Nicolas Mowen
88252e0ae6
Update ffmpeg_presets.py (#5433) 2023-02-08 21:27:43 -06:00
Blake Blackshear
e10ddb343c
additional shutdown optimizations (#5380) 2023-02-04 08:58:45 -06:00
Blake Blackshear
624c314335
Fast restart (#5378)
* dont wait so long for queues

* implement stop methods for comms

* set the detection events on exit and return early from processing

* handle the stop event in the broadcast threads

* short circuit the detection process exit code if it already exited

* some logging for stats thread

* just keep the log process alive 1 second after the last log message

* ensure the multiprocessing queues are emptied and closed

* Update frigate/log.py

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

* Update frigate/log.py

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

* mypy fixes

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-02-03 20:15:47 -06:00
Anil Ozyalcin
b33094207c
YOLOX support for OpenVINO Detector (#5285)
* Initial commit to enable Yolox models with OpenVINO in Frigate

* Fix ModelEnumtType import error in openvino.py

* Initial edit of the docs to include verbage about yolox

* Initial edit of the docs to include verbage about yolox

* Elaborate configuration and limitations in docs.

* Add capability to dynamically determine number of classes in yolox model

* Further refinements

* Removed unnecesarry comments, improved documentation, addressed PR items

* Fixed lint formatting issues
2023-02-03 19:36:37 -06:00
jvrobert
7083a5c9b6
Try to limit nvidia GPU queries to included GPUs (#5356)
* Try to limit nvidia GPU queries to included GPUs

* ignore non digit GPU indexes

* formatting

* Formatting

* Remove trailing spaces

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2023-02-03 19:34:07 -06:00