NVR with realtime local object detection for IP cameras
Go to file
gtsiam 4bb420d049
Add service manager infrastructure (#14150)
* Add service manager infrastructure

The changes are (This will be a bit long):
- A ServiceManager class that spawns a background thread and deals with
  service lifecycle management. The idea is that service lifecycle code
  will run in async functions, so a single thread is enough to manage
  any (reasonable) amount of services.

- A Service class, that offers start(), stop() and restart() methods
  that simply notify the service manager to... well. Start, stop or
  restart a service.

(!) Warning: Note that this differs from mp.Process.start/stop in that
  the service commands are sent asynchronously and will complete
  "eventually". This is good because it means that business logic is
  fast when booting up and shutting down, but we need to make sure
  that code does not rely on start() and stop() being instant
  (Mainly pid assignments).

  Subclasses of the Service class should use the on_start and on_stop
  methods to monitor for service events. These will be run by the
  service manager thread, so we need to be careful not to block
  execution here. Standard async stuff.

(!) Note on service names: Service names should be unique within a
  ServiceManager. Make sure that you pass the name you want to
  super().__init__(name="...") if you plan to spawn multiple instances
  of a service.

- A ServiceProcess class: A Service that wraps a multiprocessing.Process
  into a Service. It offers a run() method subclasses can override and
  can support in-place restarting using the service manager.

And finally, I lied a bit about this whole thing using a single thread.
I can't find any way to run python multiprocessing in async, so there is
a MultiprocessingWaiter thread that waits for multiprocessing events and
notifies any pending futures. This was uhhh... fun? No, not really.
But it works. Using this part of the code just involves calling the
provided wait method. See the implementation of ServiceProcess for more
details.

Mirror util.Process hooks onto service process

Remove Service.__name attribute

Do not serialize process object on ServiceProcess start.

asd

* Update frigate dictionary

* Convert AudioProcessor to service process
2024-10-21 10:00:38 -05:00
.cspell Add service manager infrastructure (#14150) 2024-10-21 10:00:38 -05:00
.devcontainer Removed usage of PyYAML for config parsing. (#13883) 2024-09-22 10:56:57 -05:00
.github Various fixes (#14410) 2024-10-17 11:02:27 -05:00
.vscode Fix vscode launch configuration (#13795) 2024-09-17 10:42:10 -05:00
config
docker Various fixes (#14410) 2024-10-17 11:02:27 -05:00
docs Semantic search docs update (#14438) 2024-10-18 08:07:29 -06:00
frigate Add service manager infrastructure (#14150) 2024-10-21 10:00:38 -05:00
migrations
notebooks
web fix websocket from spreading stale state (#14466) 2024-10-20 20:38:11 -06:00
.dockerignore
.gitignore Removed usage of PyYAML for config parsing. (#13883) 2024-09-22 10:56:57 -05:00
.pylintrc
audio-labelmap.txt
benchmark_motion.py
benchmark.py Custom classes for Process and Metrics (#13950) 2024-09-27 07:53:23 -05:00
CODEOWNERS
cspell.json Work through most of the cspell warnings in python (#13794) 2024-09-17 10:41:46 -05:00
docker-compose.yml
labelmap.txt
LICENSE
Makefile Formatting improvements (#13765) 2024-09-17 07:39:44 -05:00
netlify.toml
package-lock.json
process_clip.py Removed usage of PyYAML for config parsing. (#13883) 2024-09-22 10:56:57 -05:00
pyproject.toml
README.md

logo

Frigate - NVR With Realtime Object Detection for IP Cameras

A complete and local NVR designed for Home Assistant with AI object detection. Uses OpenCV and Tensorflow to perform realtime object detection locally for IP cameras.

Use of a Google Coral Accelerator is optional, but highly recommended. The Coral will outperform even the best CPUs and can process 100+ FPS with very little overhead.

  • Tight integration with Home Assistant via a custom component
  • Designed to minimize resource use and maximize performance by only looking for objects when and where it is necessary
  • Leverages multiprocessing heavily with an emphasis on realtime over processing every frame
  • Uses a very low overhead motion detection to determine where to run object detection
  • Object detection with TensorFlow runs in separate processes for maximum FPS
  • Communicates over MQTT for easy integration into other systems
  • Records video with retention settings based on detected objects
  • 24/7 recording
  • Re-streaming via RTSP to reduce the number of connections to your camera
  • WebRTC & MSE support for low-latency live view

Documentation

View the documentation at https://docs.frigate.video

Donations

If you would like to make a donation to support development, please use Github Sponsors.

Screenshots

Live dashboard

Live dashboard

Streamlined review workflow

Streamlined review workflow

Multi-camera scrubbing

Multi-camera scrubbing

Built-in mask and zone editor

Multi-camera scrubbing