Local realtime person detection for RTSP cameras

SOLVED: solution was to install older opencv that doesnt need the skbuild module. Great stuff works fine, need more tests but human detection showed 99% accuracy, ok it was daylight. Please Blake add multi coral and cat and dog detection support to it

Hi Blake and friends,

Iā€™m looking to try out zones and trying to plan it out but am unsure about how they interact with masks. Do masks override zones, ignore zones, or respect zones? Ie, if my zone overlaps the mask, who wins?

Most of the places I want to use zones are places I already have masksā€¦ Iā€™m guessing I have to get rid of the masks and just do everything with zones now, including making new zones for the places that used to not be masked off? Is that right?

Frigate completely ignores masked areas. They should be used to mask areas where motion should always be ignored such as the sky or trees and areas where you know detections will always be false positives. In the event frigate follows an object into a masked area, it will be filtered out as an assumed false positive.

Frigate looks for objects based on motion and previous object locations and follows them wherever they go. In the event that object crosses into a zone, the zone MQTT topic will switch to ON. When using zones, you donā€™t want to mask out all other areas of the frame. Frigate will use the detections of objects outside of the zone to refine the confidence of the object across several frames and you will get much faster triggers for objects when they enter.

1 Like

Does a restart of the container always fix it? Those are ffmpeg errors complaining about bad data from your camera. Frigate is restarting ffmpeg because it isnā€™t sending any frames.

Thanks for the effort and sharing it with us. I am running frigate stable directly on AtomicPi with Coral USB. The only changes I made from the default setting are the MQTT server address, and camera config (Neolink 410 rtcp at 4 fps); and no HA integration yet.

The person detection works well, however, I did not see the MQTT frigate/camera/events/start or end messages. is there any config needed to publish those messages ?

Following are my mosquitto.log
1599267986: Received PINGREQ from frigate
1599267986: Sending PINGRESP to frigate
1599268046: Received PINGREQ from frigate
1599268046: Sending PINGRESP to frigate
1599268106: Received PINGREQ from frigate
1599268106: Sending PINGRESP to frigate
1599268166: Received PINGREQ from frigate
1599268167: Sending PINGRESP to frigate
1599268201: Received PUBLISH from frigate (d0, q0, r0, m0, ā€˜frigate/reolinkBack/personā€™, ā€¦ (2 bytes))
1599268201: Received PUBLISH from frigate (d0, q0, r1, m0, ā€˜frigate/reolinkBack/person/snapshotā€™, ā€¦ (1009976 bytes))
1599268205: Received PUBLISH from frigate (d0, q0, r0, m0, ā€˜frigate/reolinkBack/personā€™, ā€¦ (3 bytes))
1599268205: Received PUBLISH from frigate (d0, q0, r1, m0, ā€˜frigate/reolinkBack/person/snapshotā€™, ā€¦ (1030168 bytes))
1599268228: Received PINGREQ from frigate
1599268228: Sending PINGRESP to frigate
1599268288: Received PINGREQ from frigate
1599268288: Sending PINGRESP to frigate
1599268348: Received PINGREQ from frigate
1599268348: Sending PINGRESP to frigate
1599268408: Received PINGREQ from frigate

I am guessing you are running stable instead of 0.6.0-rc1

Yes, running stable

docker run --privileged -v /dev/bus/usb:/dev/bus/usb -v /home/atomicpi/frigate/config:/config:ro -p 5000:5000 blakeblackshear/frigate:stable

The event MQTT messages are only in 0.6.0-rc1, not stable.

Thanks for the info. will do more reading then try the 0.6.0-rc1

Hi Blake, this really is an excellent piece of software. I now have it running on a Pi 4. I connected one Reolink 511 camera buĀ§t have had to run on sub channel (640x480) as using the default (2304x1296) slowed down to the point it could not keep upā€¦it works ok on the 640x480 detecting people down to 1000 pixel sq areaā€¦would adding a Coral help? Thanks Tim

Yes, restart or creating a new container in my case seems to solve the issue. I am also monitoring the camera feed via VLC and I havenā€™t seen issue with the camera stream or fps.

This may be just my environment but frigate container restart doesnā€™t work, it gets stuck at ffprobe or Starting detection process. If I wait for about 12-14 minutes, sometimes it works but often I have to create a new container. If I manually run the "ffprobe -v panic -show_error -show_streams -of json ā€œrtsp://user:[email protected]:554//h264Preview_01_subā€ on either frigateā€™s console or host terminal, it shows the result without any delay.

2020-09-01T04:41:12.258230235Z Received: 15
2020-09-01T04:41:12.275714820Z back: stop event set. exiting capture thread...
2020-09-01T04:41:12.477733394Z garage: stop event set. exiting capture thread...
2020-09-01T04:41:16.077691573Z Exiting watchdog...
2020-09-01T04:41:16.709742795Z Exiting event processor...
2020-09-01T04:41:22.161738794Z Exiting object processor...
2020-09-01T04:41:31.736858542Z On connect called
2020-09-01T04:41:32.752850082Z ffprobe -v panic -show_error -show_streams -of json "rtsp://user:[email protected]:554//h264Preview_01_sub"
2020-09-01T04:41:32.753867205Z Starting detection process: 25

The Coral will nearly eliminate CPU usage for object detection, but decoding a 4k video stream in a RPi4 may not be realistic and the Coral wonā€™t help at all on that front.

There must be something holding onto old connections that only gets cleaned up when you recreate the container. I fear this will be difficult to troubleshoot because I wonā€™t be able to reproduce it.

You should already be able to detect cats and dogs? It supports any of the objects in the modelā€¦

(To be fair, my cats and dogs are often swopped around, especially at night)

1 Like

is there any way to improve nightime person or anything detection. I tested it and i can not identify when the cam is in night mode with IRs on, so the picture is gray scale. No detection at all. Can I train it with adding self made night time photos, or anyone else did this already?

I tried RTMP instead of RTSP protocol and it seems to have resolved my container restart issue. hopefully it will also help solve the frequent ffmpeg complaining about bad data from my Reolink IP cameras. Here are the FFMPEG options I have currently, let me know if I should make any changes -

ffmpeg:
  global_args:
    - -hide_banner
    - -loglevel
    - panic
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p
  #hwaccel_args: []
  input_args:
    - -avoid_negative_ts
    - make_zero
    - -fflags
    - nobuffer
    - -flags
    - low_delay
    - -strict
    - experimental
    - -fflags
    - +genpts+discardcorrupt
    - -vsync
    - drop
    #- -r
    #- '8'
    #- -rtsp_transport
    #- tcp
    #- -stimeout
    #- '5000000'
    - -use_wallclock_as_timestamps
    - '1'
  output_args:
    - -f
    - rawvideo
    - -pix_fmt
    - rgb24

Thanks Blake

Reolink is terrible, it just hyped due to low price but its real junk. I have many Hikvisions, Dahuas, and few Reolink and issue is only with Reolink.

1 Like

I have the Reolink 511W and no issuesā€¦

under debug my coral shows 116 fps and the device is pretty warm. Please tell me if this is normal, or whats the usual fps in order to prevent burning it? currently 7 cams on it : 6 cams 4fps, 1 cam 25 fps.

CPU load is about 20% server memory 9.7% used. Looks like coral is the weakest link, as i expected since day 1 - my first post on this topic