Commit Graph

119 Commits

Author SHA1 Message Date
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