Local realtime person detection for RTSP cameras

Strange, I got the message with brower_mod, variable, and frigate. Which is weird since frigate has an integration. I tried multiple restarts but all got the same message. I upgraded from 2021.5.4. did I miss anything in between?

My frigate integrations stopped working when I upgraded to 2021.8.3 last weekend so I went back to 2021.7.4. There was a message posted in this thread about 16 days ago that indicated a fix was already in the works. I will try upgrading to 2021.8.6 tomorrow.

Good to know Iā€™m not the only one. Let me know if you experience the same thing. I didnā€™t see any updates on the aforementioned integration, so that why I wanted to see if it was isolated to me or others were experiencing it

Sorry for probably stupid question. I really donā€™t understand why this object mask doesnā€™t enabled (at the right place&shape) even if I restart Frigate. Config.yml:

  Mokki2:
    ffmpeg:
      inputs:
        - path: rtsp://admin:[email protected]:1111/cam/realmonitor?channel=1&subtype=0
          roles:
            - clips
            - rtmp
            - detect
    width: 1920
    height: 1080
    fps: 5
    clips:
      enabled: true
      pre_capture: 15
      post_capture: 15
      retain:
        default: 2
    motion:
      mask:
        - 255,28,259,143,37,197,0,181
        - 1858,89,1858,33,1444,38,1447,92
    snapshots:
      enabled: true
      bounding_box: true
    objects:
      track:
        - person
        - dog
        - car
        - bicycle
        - bird
      filters:
        car:
          mask:
            - 1237,537,1550,559,1567,465,1246,430

What I see when checking:

So mask is totally wrong shape and wron position and I get multiple events from parked car:

image

And one thing moreā€¦ if I want add (to specific camera) option save audio alsoā€¦ how to do that (I know " need to override the output args to remove -an") but I donā€™t have any output args anywhere so how to override that?

:thinking: No new messages at 4d??? :thinking: Whatā€™s going on??

I really like the concept of Frigate. However, Iā€™ve never gotten good video playback with Frigate. Iā€™m using an RTMP stream from Reolink RLC-410W camera. The stream is set to be 1920x1080@15fps. Ffprobe shows 1920x1072@15fps. The Frigate UI live preview shows ā€œDisplaying at 2.6fpsā€ (on average). Why? The recorded clips play back at a similar framerate.

The host CPU is 50% max and Iā€™m using Coral USB which appears to be working.

Go into ā€œdebugā€ > the camera in question (Mokki2 ? ) > show options > Mask & Zone creator > and click on the mask you created, it should show up on the image above. I see you have a motion mask and an object mask, try and isolate them, perhaps remove them all and add them back one at a time.

As for the output args, you can find them here.

I managed create object mask to the right place for putting it twice to the config.yml and after that removed second oneā€¦

What comes to the output args - I know where I can find themā€¦ Is that audio argument global argument or per camera?

Alsoā€¦ sorry my poor Englishā€¦How can I remove output args -an if I donā€™t have any output args? This is something I donā€™t understandā€¦

So here is start of my configā€¦ If I want to add audio ā€œetupihaā€ camera what should be read and where? And what if I want to save audio for all cameras?

detectors:
  coral:
    type: edgetpu
    device: usb

mqtt:
  host: 192.168.1.60
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: xxx
  password: xxx

cameras:
  eteinen:
    ffmpeg:
      inputs:
        - path: rtsp://xxx:[email protected]:554/stream1
          roles:
            - rtmp
            - detect
    width: 1920
    height: 1080
    fps: 5

  etupiha:
    ffmpeg:
      inputs:
        - path: rtsp://xxx:[email protected]:554/Streaming/Channels/1
          roles:
            - clips
            - rtmp
            - detect
    width: 1920
    height: 1080
    fps: 5
    clips:
      enabled: true
      pre_capture: 15
      post_capture: 15
      retain:
        default: 2
    motion:
      mask: 0,771,257,420,407,351,625,162,694,138,673,0,670,0,656,0,344,0,167,0,0,0
    snapshots:
      enabled: true

Look like really hard to get hold an Coral USB , everywhere out of stock. Iā€™m thinking to get the m.2 version and run frigate on docker container. Any recommendation on hardware that can use m.2 version and to handle 8 unit cameras?

Frigate 8, I did a pull from the hass integration repo and with 2021.8.8 here and same issue

Setup failed for frigate: Unable to import component: cannot import name ā€˜Messageā€™ from ā€˜homeassistant.components.mqtt.modelsā€™ (/usr/src/homeassistant/homeassistant/components/mqtt/models.py)

Found this 2021.8.0 - Unable to import component: cannot import name 'Message' from 'homeassistant.components.mqtt.models' Ā· Issue #124 Ā· blakeblackshear/frigate-hass-integration Ā· GitHub will see what Iā€™ve got wrong

solved - it helps if i properly copy the files to the hass directory :slight_smile:

Iā€™ve been watching my Detection FPS chart since I swapped my USB Coral Accelerator from using USB 2.0 ā†’ USB 3.0. The overall Detection FPS ceiling has risen to 80 fps (for 7 cameras) but Iā€™ve noticed something that I donā€™t understand. Iā€™m using all my cameras at 8 fps but the detection fps chart in Home Assistant shows that a single camera can have a detection fps of 40+ on its ownā€¦ how does that work? Shouldnā€™t each camera top out at 8 if thatā€™s what the limit is?

Overall:
image

Per camera:
image

I assume, that as it doesnā€™t send the entire image for object detection - but rather the sections that are resized to 300x300 - there can/are multiple object detections, per entire image, at once often happening.

Defenetly not a job for a Intel NUC or similar. I am running frigate on a Lenovo ThinkCentre M700 Tiny that has m.2 port plus SATA and i5-6500T.
With 5 * 1080p cams the CPU is idle at around 12%.

That makes much more sense. Thanks @iMiMx

Got my Coral USB device, will try it now. Is there any tutorial beside Ggithub?

Just updated. Thanks!

Ok I am doing my first configuration.

In Home Assistant I have a bunch of Hikvision cameras for which I use the generic platform, I guess those are not good for Frigate?


  - platform: generic
    name: "East one"
    still_image_url: http://admin:[email protected]/ISAPI/Streaming/channels/101/picture
    stream_source: rtsp://admin:[email protected]:554/ch1/main/av_stream

Iā€™m running my HA in virtualbox, my host machine is an i7 16gb ram windows 10 pc. Planning to add a m.2 coral for frigate so should I install frigate as HA addon or will it possible to run on a separate docker with Docker Desktop for Windows?

Not sure if this is possible, never seen it on this forum. The Frigate docs are advising against virtualization, but instead run on host machine under Linux.

So im a bit stuck. Used frigate with cpu as a test and it worked great. Got the coral usb and I simply cannot get frigate to find it. Hoping someone has experienced this and has some tips to try.

Things I have already tried:
unplug and plug it (coral usb) back in
reboot host
change usb ports
using docker
using podman
using podman-compose
removing detector portion of config - still fails to find it, but doesnt keep restarting the container

ubuntu 20.04 x64 bit
podman (tried docker as well)

lsusb -v

Bus 002 Device 002: ID 1a6e:089a Global Unichip Corp. 
podman exec -t frigate find /dev/bus
/dev/bus
/dev/bus/usb
/dev/bus/usb/001
/dev/bus/usb/001/001
/dev/bus/usb/001/002
/dev/bus/usb/001/003
/dev/bus/usb/002
/dev/bus/usb/002/001
/dev/bus/usb/002/002

config.yml:

mqtt:
  host: 192.168.1.10
  port: 1883
  user: frigate
  password: passphrase
cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://rspuser:{FRIGATE_RTSP_PASSWORD}@192.168.1.210:8554/unicast
          roles:
            - clips
            - detect
            - rtmp
    width: 1280
    height: 720
    fps: 5
    zones:
      zone_0:
        coordinates: 618,643,621,189,443,202,441,599
      zone_1:
        coordinates: 1241,720,1255,167,895,172,868,626
      zone_2:
        coordinates: 457,254,373,252,355,452,452,498
clips:
  retain:
    default: 20
    objects:
      person: 45
detectors:
  coral:
    type: edgetpu
    device: usb
  cpu:
    type: cpu

docker-compose.yml

version: "3.9"
services:
  frigate:
    container_name: frigate
    restart: unless-stopped
    image: blakeblackshear/frigate:stable-amd64
    devices:
       - /dev/bus/usb/:/dev/bus/usb/
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/frigate/config.yml:/config/config.yml:ro
      - /sanman/Podman/cameras:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "1935:1935"
    environment:
      FRIGATE_RTSP_PASSWORD: "12345"
podman logs frigate
 * Starting nginx nginx
   ...done.
frigate.app                    WARNING : Camera front_door has clips assigned to an input, but clips is not enabled.
Starting migrations
peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
peewee_migrate                 INFO    : There is nothing to migrate
frigate.mqtt                   INFO    : MQTT connected
detector.coral                 INFO    : Starting detection process: 35
cameras@ajalon-Rampage-Formula:~$ podman logs frigate
 * Starting nginx nginx
   ...done.
frigate.app                    WARNING : Camera front_door has clips assigned to an input, but clips is not enabled.
Starting migrations
peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
peewee_migrate                 INFO    : There is nothing to migrate
frigate.mqtt                   INFO    : MQTT connected
detector.coral                 INFO    : Starting detection process: 35
detector.cpu                   INFO    : Starting detection process: 37
frigate.app                    INFO    : Camera processor started for front_door: 40
frigate.edgetpu                INFO    : Attempting to load TPU as usb
Process detector:coral:
frigate.edgetpu                INFO    : No EdgeTPU detected.
frigate.app                    INFO    : Capture process started for front_door: 41
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 152, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 111, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/frigate/frigate/edgetpu.py", line 124, in run_detector
    object_detector = LocalObjectDetector(tf_device=tf_device, num_threads=num_threads)
  File "/opt/frigate/frigate/edgetpu.py", line 63, in __init__
    edge_tpu_delegate = load_delegate('libedgetpu.so.1.0', device_config)
  File "/usr/local/lib/python3.8/dist-packages/tflite_runtime/interpreter.py", line 154, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1.0

frigate.watchdog               INFO    : Detection appears to have stopped. Exiting frigate...
frigate.app                    INFO    : Stopping...

So I have the issue if frigate docker is using the Quicksync option in frigate.
If I do:

cat /proc/cpuinfo  | grep "model name" | head -1
model name      : Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz

And according to Intel ARK it is enabled in the CPU.
But. I dont know if Frigate is utilizing itā€¦
In config.yml I have this:

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

But even if I remove these lines the CPU usage is the sameā€¦ How do I know if the right ffmpeg settings are used?

1 Like