Commit Graph

201 Commits

Author SHA1 Message Date
Sebastian Englbrecht
ebf4e43ced Modernizing Typing
All Dict, List were converted to dict, list, see: https://mypy.readthedocs.io/en/stable/builtin_types.html#generic-types
2022-04-17 08:55:38 -05:00
Blake Blackshear
ec91466fe4 lint fixes 2022-04-16 09:08:10 -05:00
Josh Hawkins
65e0ec7826
Allow improve_contrast to be toggled via mqtt (#3011)
* Toggle improve_contrast for cameras via MQTT

* Process parameter to mqtt toggle improve_contrast

* Update mqtt docs for improve_contrast topic

* Spacing

* Add class variable and update in process_frames

* Pass to constructor

* pass by reference mistake

* remove parameter

* remove parameter
2022-04-16 08:52:02 -05:00
Sebastian Englbrecht
41f58c7692 Add basic typing for multiple modules:
* log.py
 * video.py
 * watchdog.py
 * zeroconf.py
2022-04-15 07:01:43 -05:00
Nick
045aac8933
Add object filter ratio (#2952)
* Add object ratio config parameters

Issue: #2948

* Add config test for object filter ratios

Issue: #2948

* Address review comments

- Accept `ratio` default
- Rename `bounds` to `box` for consistency
- Add migration for new field

Issue: #2948

* Fix logical errors

- field migrations require default values
- `clipped` referenced the wrong index for region, since it shifted
- missed an inclusion of `ratio` for detections in `process_frames`
- revert naming `o[2]` as `box` since it is out of scope!

This has now been test-run against a video, so I believe the kinks are
worked out.

Issue: #2948

* Update contributing notes for `make`

Issue: #2948

* Fix migration

- Ensure that defaults match between Event and migration script
- Deconflict migration script number (from rebase)

Issue: #2948

* Filter objects out of ratio bounds

Issue: #2948

* Update migration file to 009

Issue: #2948
2022-04-10 08:25:18 -05:00
Blake Blackshear
cbf26e09a4 fix for opencv changes 2022-02-21 06:51:33 -06:00
Blake Blackshear
ff19cdb773 refactor stationary config into section 2022-02-18 21:18:26 -06:00
Blake Blackshear
c14f986fae stop forcing detection all the way to stationary_threshold 2022-02-18 21:18:26 -06:00
Blake Blackshear
3e90f3032c make stationary_threshold configurable 2022-02-18 21:18:26 -06:00
Blake Blackshear
583912db9c allow motion based retention when detect is disabled 2022-02-18 21:18:26 -06:00
Blake Blackshear
f0212c2aa4 adjust error messages on ffmpeg crash 2022-02-18 21:18:26 -06:00
Blake Blackshear
7e7d70aa5b avoid extra tracking work on stationary frames 2022-02-18 21:18:26 -06:00
Blake Blackshear
e627f4e935 dont stop scanning when there are other regions 2022-02-18 21:18:26 -06:00
Blake Blackshear
c6445898ce default periodic checks to never 2022-02-18 21:18:26 -06:00
Blake Blackshear
f1ddd0e6f7 scan the frame on startup 2022-02-18 21:18:26 -06:00
Blake Blackshear
87cd618998 randomize the region multiplier for variation 2022-02-18 21:18:26 -06:00
Yuriy Sannikov
80627e4989 safe refactoring (#2552)
Co-authored-by: YS <ys@gm.com>
2022-02-18 21:18:26 -06:00
Blake Blackshear
9b23ff597c revert switch to b/w frame prep 2022-02-18 21:18:26 -06:00
Blake Blackshear
b2ce1edd5a fix default motion comment 2022-02-18 21:18:26 -06:00
Blake Blackshear
258215a3ae consolidate regions 2022-02-18 21:18:26 -06:00
Blake Blackshear
8ab6cba521 check for overlapping motion boxes 2022-02-18 21:18:26 -06:00
Blake Blackshear
eb16de7395 config option for stationary detection interval 2022-02-18 21:18:26 -06:00
Blake Blackshear
dde0498ed3 drop high overlap detections 2022-02-18 21:18:26 -06:00
Blake Blackshear
75c8570913 reduce detection rate for stationary objects 2022-02-18 21:18:26 -06:00
Blake Blackshear
e36099a342 improve box merging and keep tracking 2022-02-18 21:18:26 -06:00
Blake Blackshear
b143e11e0e cleanup logging 2021-08-16 07:38:53 -05:00
Blake Blackshear
2181379475 stop using pycoral libs for efficiency 2021-08-15 09:14:13 -05:00
Blake Blackshear
0ccf543ec1 clarify a few things in logs 2021-08-14 14:04:00 -05:00
Blake Blackshear
1823bd0305 fix scaling 2021-08-09 07:46:28 -05:00
Blake Blackshear
dc759a3e56 use new pycoral libraries 2021-08-07 15:34:55 -05:00
Blake Blackshear
92aa16c556 add labelmap customization to the config (fixes #507) 2021-07-07 22:58:18 -05:00
Patrick
7ad8b8298d identity check is correct way to check for None 2021-06-27 08:09:58 -05:00
Sean Vig
84a0827aee Use dataclasses for config handling
Use config data classes to eliminate some of the boilerplate associated
with setting up the configuration.  In particular, using dataclasses
removes a lot of the boilerplate around assigning properties to the
object and allows these to be easily immutable by freezing them.  In the
case of simple, non-nested dataclasses, this also provides more
convenient `asdict` helpers.

To set this up, where previously the objects would be parsed from the
config via the `__init__` method, create a `build` classmethod that does
this and calls the dataclass initializer.

Some of the objects are mutated at runtime, in particular some of the
zones are mutated to set the color (this might be able to be refactored
out) and some of the camera functionality can be enabled/disabled.  Some
of the configs with `enabled` properties don't seem to have mqtt hooks
to be able to toggle this, in particular, the clips, snapshots, and
detect can be toggled but rtmp and record configs do not, but all of
these configs are still not frozen in case there is some other
functionality I am missing.

There are a couple other minor fixes here, one that was introduced
by me recently where `max_seconds` was not defined, the other to
properly `get()` the message payload when handling publishing mqtt
messages sent via websocket.
2021-05-23 20:38:57 -05:00
Sean Vig
57864f2be6 Wait on stop event when possible
Generally eliminate the `while True` loops while waiting for a stop
event and prefer to condition the loops on if the stop event is set,
blocking on that where it makes sense.  This generally comes in 3
flavors.  First and simplest, when there is a sleep and the stop event
is the only thing the loop blocks on, instead do a check using
`stop_event.wait(timeout)` to instead block on the stop event for the
designated amount of time. Second, when there is a different event that
is blocking in the loop, condition the loop on `stop_event.is_set()`
rather than breaking when it is set. Finally, when there is a separate
internal condition that requires a counter, have the loop iterate over
the counter and use `if stop_event.wait(timeout)` internal to the loop.
2021-05-22 07:54:16 -05:00
Blake Blackshear
39ff49e054 formatting cleanup 2021-02-25 07:01:57 -06:00
Blake Blackshear
e299e73a68 ignore detections that don't overlap with motion 2021-02-20 08:20:17 -06:00
Blake Blackshear
9550ac7422 fix intersection calculation 2021-02-20 08:20:17 -06:00
Blake Blackshear
1cbe6f77ee only run detection on objects that intersect with motion 2021-02-20 08:20:17 -06:00
Blake Blackshear
ee3e744cc6 tail last 100 lines of ffmpeg logs and dump when failure detected 2021-01-31 06:18:35 -06:00
Blake Blackshear
39040c1874 enable and disable detection via mqtt 2021-01-26 21:40:33 -06:00
Blake Blackshear
b2c7fc8f5b add mask as object filter 2021-01-26 21:40:33 -06:00
Nat Morris
4619836122 Set titles for forked processes 2021-01-26 21:40:33 -06:00
Blake Blackshear
899d41f361 allow runtime drawing settings for mjpeg and latest 2021-01-26 21:40:33 -06:00
Blake Blackshear
3bc7cdaab6 configurable motion and detect settings 2021-01-26 21:40:33 -06:00
Blake Blackshear
a4b88ac4a7 fix process clip 2021-01-26 21:40:33 -06:00
Blake Blackshear
d0470fffcc allow defining model shape and switch to mobiledet as default model 2021-01-26 21:40:33 -06:00
Blake Blackshear
d60ca9d783 log level configuration 2021-01-26 21:40:33 -06:00
Blake Blackshear
d62aec7287 graceful exit of subprocesses 2021-01-26 21:40:33 -06:00
Blake Blackshear
4e0cf3681e add multiple streams per camera 2021-01-26 21:40:33 -06:00
Blake Blackshear
03c855ecbe sort imports 2021-01-26 21:40:33 -06:00
Blake Blackshear
3a3cb24631 naming threads and processes for logs 2021-01-26 21:40:33 -06:00
Blake Blackshear
4c3fea25a5 use a queue for logging 2021-01-26 21:40:33 -06:00
Blake Blackshear
af303cbf2a create typed config classes 2021-01-26 21:40:33 -06:00
Blake Blackshear
9778a748fc add capture processes 2021-01-26 21:40:33 -06:00
Blake Blackshear
a89dddcafa add camera processors 2021-01-26 21:40:33 -06:00
Blake Blackshear
64b63142b1 start the frame rate tracker 2020-10-26 08:01:18 -05:00
Blake Blackshear
cee1ab000b make ffmpeg pid available for cache maintenance (fixes #271) 2020-10-26 08:01:18 -05:00
Blake Blackshear
eafde6c677 capture ffmpeg in a dedicated process 2020-10-25 14:30:36 -05:00
Blake Blackshear
35ba5e2f7c improve frame memory management 2020-10-25 14:30:36 -05:00
Blake Blackshear
12c4cd77c5 only convert pix_fmt when necessary 2020-10-18 13:47:13 -05:00
Blake Blackshear
a611cbb942 use yuv420p pixel format for motion 2020-10-18 13:47:13 -05:00
Blake Blackshear
f946813ccb support multiple coral devices (fixes #100) 2020-10-18 13:47:13 -05:00
Blake Blackshear
ec4d048905 upgrade to python3.8 and switch from plasma store to shared_memory 2020-10-18 13:47:13 -05:00
Blake Blackshear
005e188d38 continue if frames not in frame manager 2020-09-17 07:37:27 -05:00
Blake Blackshear
5fe201da25 avoid processing broken frames 2020-09-17 07:37:27 -05:00
Blake Blackshear
1ce993051e add support for polygon masks 2020-09-17 07:37:27 -05:00
Blake Blackshear
1c33b8acb2 handle mask files that failed to read 2020-09-17 07:37:27 -05:00
Blake Blackshear
5e77436d39 fix coral fps value 2020-09-17 07:37:27 -05:00
Blake Blackshear
c16ee3186f fix masks 2020-09-17 07:37:27 -05:00
Blake Blackshear
acb75fa02d refactor and reduce false positives 2020-09-17 07:37:27 -05:00
Blake Blackshear
ea4ecae27c Refactor with a working false positive test 2020-09-17 07:37:27 -05:00
Blake Blackshear
adcfe699c2 ensure frigate can exit gracefully 2020-08-08 07:40:48 -05:00
Blake Blackshear
e6c6338266 allow mask to be base64 encoded into the config file 2020-08-08 07:40:48 -05:00
Blake Blackshear
c1f522ff54 fix box merging 2020-07-26 12:00:46 -05:00
Blake Blackshear
760e1ffe1d skip frames in the capture thread instead 2020-06-02 05:25:02 -05:00
Blake Blackshear
15b4024715 expose frame time at each step of processing 2020-06-02 05:25:02 -05:00
Blake Blackshear
4ee200a81c move ffmpeg capture to a separate thread and use a queue 2020-06-02 05:25:02 -05:00
Blake Blackshear
6de8e3bd1f remove sharedarray references 2020-06-02 05:25:02 -05:00
Blake Blackshear
3a9781c4f8 handle various scenarios with external process failures 2020-06-02 05:25:02 -05:00
Blake Blackshear
a5bef89123 improve detection processing and restart when stuck 2020-03-03 20:26:53 -06:00
Blake Blackshear
d8aa73d26e handle ffmpeg process failures in the camera process itself 2020-03-03 20:26:53 -06:00
Blake Blackshear
791409d5e5 add a few print statements for debugging 2020-03-03 20:26:53 -06:00
Blake Blackshear
8e73c7e95e increase the buffer size a bit 2020-03-03 20:26:53 -06:00
Blake Blackshear
76a7a3bad5 allow specifying the frame size in the config instead of detecting 2020-03-03 20:26:53 -06:00
Blake Blackshear
e6892d66b8 update docs and add back benchmark 2020-03-03 20:26:53 -06:00
Blake Blackshear
3e6f6edf7e check avg wait before dropping frames 2020-03-03 20:26:53 -06:00
Blake Blackshear
6f6d202c99 improve watchdog and coral fps tracking 2020-03-03 20:26:53 -06:00
Blake Blackshear
05951aa7da cleanup 2020-03-03 20:26:53 -06:00
Blake Blackshear
bb8e4621f5 add models and convert speed to ms 2020-03-03 20:26:53 -06:00
Blake Blackshear
04e9ab5ce4 add watchdog for camera processes 2020-03-03 20:26:53 -06:00
Blake Blackshear
1089a40943 cleanup old code 2020-03-03 20:26:53 -06:00
Blake Blackshear
68c3a069ba add a min_fps option 2020-03-03 20:26:53 -06:00
Blake Blackshear
80b9652f7a check plasma store and consolidate frame drawing 2020-03-03 20:26:53 -06:00
Blake Blackshear
569e07949f split into separate processes 2020-03-03 20:26:53 -06:00
Blake Blackshear
cd057370e1 fallback to opencv to detect resolution and allow config to specify 2020-02-22 09:03:00 -06:00
Blake Blackshear
6263912655 use ffprobe to get frame shape (fixes #87) 2020-02-22 09:03:00 -06:00
Blake Blackshear
af247275cf make timestamp on snapshots configurable (fixes #88) 2020-02-22 09:03:00 -06:00
Blake Blackshear
1198c29dac make watchdog timeout configurable per camera (fixes #95) 2020-02-22 09:03:00 -06:00
Blake Blackshear
38efbd63ea add camera name to ffmpeg log messages 2020-02-22 09:03:00 -06:00
Blake Blackshear
50bcad8b77 skip regions when the queue is too full and add more locks 2020-02-22 09:03:00 -06:00