Local realtime person detection for RTSP cameras

if you would have time and energy i could advise to test with other software too NVR+Det+Coral but on the other hand this Blackeware is totally good, maybe even the best among the free stuff

Iā€™m not running in debug mode, or whatever the option that prints more to the log is but as far as I can see everything executes normally sans the connection to the TPU.

Normally the log looks as below when it detects the TPU, it happens within the next line. When it doesnā€™t detect thereā€™s a long period before the message is printed about falling back to the CPU(well after the camera connection is established, after what is assume is a time out.)

Yes, just a single camera. I wanted to test it out before going all in.

Attempting to load TPU as usb
TPU found

My coral arrived today. I ended up ordering it off of Amazon.ca Took roughly 3 weeks to arrive.

Without the TPU plugged in, it falls back to CPU mode almost instantly. It is trying to connect to your TPU and failing. Almost everything runs in completely separate processes (not threads, separate pids), so the TPU process is running in parallel. The only thing I can think of is the camera process starting and hogging all the I/O bandwidth and causing an issue with the USB bus.

1 Like

That certainly sounds plausible. It also makes sense in that the higher resolutions simply wonā€™t run on the pi(they fall back to the cpu.)

Thanks for the help!

Also, thanks for the amazing work on this!

hi,
im currently planning camera set up with home assistant, Main thing id like to use it for is

  • object/person detection as real time as possible
  • making qood quality pictures every day to make a timelapse of the area

Appreciate any recommendations of what will work for this?

More informaiton on your system would be good: CPU, ram, how you run docker.
Also, output on this command on the docker host:

dmesg|grep usb

White LED must be blinking when the TPU receives some data. If not blinking, means something is broken.

NUC5i5RYH
i5-5250u running at around 10% utilized
16g ram
SSD
Iā€™m running HA supervised on ubuntu

Itā€™s currently running with a solid LED, and has been since day one. The only time it stops working is when the LED is blinking. What this means, I donā€™t know but I can tell you Iā€™m looking at it right now running inference in ~8.1ms and the LED is solid.

Iā€™ll grab a printout from the host later today when I get a chance. Thanks for the help

The Led only blinks when it is being used. Frigate does not use it unless there is motion. I guess it is possible that the latest driver changed the behavior if you built the image yourself. If you did, try running the pre-built image instead.

i just noticed missed a scooter. Are these considered motorcycle or bicycle object or person?

Iā€™m trying to get Nvidia support in the container for ffmpeg decoding.

I have it working with the sample nvidia container, but it doesnā€™t work from inside frigate:

Unknown decoder ā€˜h264_cuvidā€™

I wanted to ask what the best course of action is to get it working. Build a new container from source maybe? I tried pulling the GitHub repo, but itā€™s failing on the docker build for wheels:

manifest for blakeblackshear/frigate-wheels:amd64 not found: manifest unknown: manifest unknown

Any assistance would be appreciated!

Did you try checking out master and running make amd64nvidia_all?

I use the HA add on which builds directly from your github(I assume.)

Unfortunately this problem re-occurred last night. I donā€™t have any logs to share at this time, as I had to get the host back up and running immediately(it runs my Home Assistant.)

When the problem happens it completely locks up the host pc. It happens at approx 2.5 days of runtime, and has happened every single time Iā€™ve run frigate for this long.

I will be pulling all the information required as soon as I get a chance and submitting to github.

As a thought, when it is running normally the coral stick doesnā€™t blink. When I experience the failure it blinks continuously. Based on what you have said about how the program works, and is only sending data when motion is detected. Could it be possible that the motion detection part of the program is continuously sending data to the coral device?

I know all of this is just conjecture without proper data, and will be pulling it as soon as life gives me time to do so.

Not unless there is continuous motion. The Coral runs object detection exclusively. It is not involved in motion detection or decoding the video feeds. When motion is detected, Frigate selects the portion of the frame with motion and sends it to the Coral.

Given the time period is so consistent, you could try disabling save_clips to see if that is related. Do you have any stats on memory/cpu/disk usage to see if something is climbing over that timeframe?

I will try disabling the save clips and see what happens. There certainly wasnā€™t continuous motion. The cpu and memory usage was not out of the ordinary(not climbing) leading up to the failure. Unfortunately I was not able to reach the host in anyway after it happened so I do not have stats from when it was happening.

Thanks Blake! All working now. I complied from the master and enabled the nvidia runtime in docker with this tutorial: https://github.com/NVIDIA/nvidia-container-runtime

 * Serving Flask app "detect_objects" (lazy loading)
 * Environment: development
 * Debug mode: off
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:[email protected]:554/Streaming/Channels/101 -f rawvideo -pix_fmt yuv420p pipe:
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel panic -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:[email protected]:554/Streaming/Channels/101 -f rawvideo -pix_fmt yuv420p pipe:
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...


hi blake. thanks for the great Frigate . my setup with pi4 8GB and USB coral setup via addon, 3 hikvision rtsp 1280x720, 4fps was running flawless for 48 hrs . detection was good and pi4 cpu barely reach 50% consumption and inference speed was good . Frigate Add ON was set to AUTO upgrade
.
.
this morning. since cpu is ok and everything was alright, i added 4th camera with same setting. then something happened. everything failed. i change to new SD card and reinstall every thing including hass with only one camera and minimal setting setting. and these are the log error. it seem the ffmpeg processā€¦ keep on restarting and failing. here is my setting: removed previos masking setting etc

web_port: 5000
detectors:
  coral:
    type: edgetpu
    device: usb
save_clips:
  clips_dir: /media/frigate
mqtt:
  host: 192.168.1.3
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: mqtt
  password: passwd
ffmpeg:
  hwaccel_args:
    - '-c:v'
    - h264_v4l2m2m
cameras:
  back:
    ffmpeg:
      input: 'rtsp://admin:[email protected]:554/Streaming/Channels/101'
objects:
  track:
    - person
    - cat
  filters:
    person:
      min_area: 5000
      max_area: 100000
      min_score: 0.5
      threshold: 0.85
    cat:
      min_area: 0
      max_area: 100000
      min_score: 0.5
      threshold: 0.85

is there new update to hass.io add on? any clue?

There was not an update to the addon. See what the ffmpeg logs say: https://github.com/blakeblackshear/frigate#ffmpeg-didnt-return-a-frame-something-is-wrong

[h264_v4l2m2m @ 0x55694c3a30] requesting formats: output=H264 capture=YU12
Input #0, rtsp, from 'rtsp://admin:[email protected]:554/Streaming/Channels/101':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 1605672742.540322, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 1280x720 [SAR 189:190 DAR 168:95], 4 fps, 25 tbr, 90k tbn, 8 tbc
[h264_v4l2m2m @ 0x559dcee410] Using device /dev/video10
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264_v4l2m2m @ 0x559dcee410] driver 'bcm2835-codec' on card 'bcm2835-codec-decode' in mplane mode
[h264_v4l2m2m @ 0x559dcee410] requesting formats: output=H264 capture=YU12
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Press [q] to stop, [?] for help
No frames received from gate in 5 seconds. Exiting ffmpeg...
Waiting for ffmpeg to exit gracefully...
No frames received from back in 5 seconds. Exiting ffmpeg...
Waiting for ffmpeg to exit gracefully...
FFmpeg didnt exit. Force killing...
gate: ffmpeg sent a broken frame. something is wrong.
gate: ffmpeg process is not running. exiting capture thread...
FFmpeg didnt exit. Force killing...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel info -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:[email protected]:554/Streaming/Channels/101 -f rawvideo -pix_fmt yuv420p pipe:
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel info -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:[email protected]:554/Streaming/Channels/101 -f rawvideo -pix_fmt yuv420p pipe:
frame=  185 fps=3.7 q=-0.0 size=  249750kB time=00:00:54.00 bitrate=37888.0kbits/s speed=1.08x    
frame=  188 fps=3.7 q=-0.0 size=  253800kB time=00:00:54.75 bitrate=37975.0kbits/s speed=1.08x    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=  190 fps=3.7 q=-0.0 size=  256500kB time=00:00:55.25 bitrate=38031.6kbits/s speed=1.08x    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=  193 fps=3.7 q=-0.0 size=  260550kB time=00:00:56.00 bitrate=38114.7kbits/s speed=1.08x    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=  196 fps=3.7 q=-0.0 size=  264600kB time=00:00:56.75 bitrate=38195.7kbits/s speed=1.08x    
frame=  198 fps=3.7 q=-0.0 size=  267300kB time=00:00:57.25 bitrate=38248.4kbits/s speed=1.08x    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=  201 fps=3.7 q=-0.0 size=  271350kB time=00:00:58.00 bitrate=38325.8kbits/s speed=1.07x    
frame=  204 fps=3.7 q=-0.0 size=  275400kB time=00:00:58.75 bitrate=38401.3kbits/s speed=1.07x    
frame=  206 fps=3.7 q=-0.0 size=  278100kB time=00:00:59.25 bitrate=38450.6kbits/s speed=1.07x    
frame=  209 fps=3.7 q=-0.0 size=  282150kB time=00:01:00.00 bitrate=38522.9kbits/s speed=1.07x    
frame=  212 fps=3.7 q=-0.0 size=  286200kB time=00:01:00.75 bitrate=38593.4kbits/s speed=1.07x    
frame=  214 fps=3.7 q=-0.0 size=  288900kB time=00:01:01.25 bitrate=38639.5kbits/s speed=1.07x    
frame=  217 fps=3.7 q=-0.0 size=  292950kB time=00:01:02.00 bitrate=38707.2kbits/s speed=1.07x    
frame=  220 fps=3.7 q=-0.0 size=  297000kB time=00:01:02.75 bitrate=38773.3kbits/s speed=1.07x    
frame=  222 fps=3.7 q=-0.0 size=  299700kB time=00:01:03.25 bitrate=38816.5kbits/s speed=1.07x    
frame=  225 fps=3.8 q=-0.0 size=  303750kB time=00:01:04.00 bitrate=38880.0kbits/s speed=1.07x    
frame=  228 fps=3.8 q=-0.0 size=  307800kB time=00:01:04.75 bitrate=38942.0kbits/s speed=1.07x    
frame=  230 fps=3.8 q=-0.0 size=  310500kB time=00:01:05.25 bitrate=38982.6kbits/s speed=1.07x    
frame=  233 fps=3.8 q=-0.0 size=  314550kB time=00:01:06.00 bitrate=39042.3kbits/s speed=1.06x    
frame=  236 fps=3.8 q=-0.0 size=  318600kB time=00:01:06.75 bitrate=39100.7kbits/s speed=1.06x    
frame=  238 fps=3.8 q=-0.0 size=  321300kB time=00:01:07.25 bitrate=39138.9kbits/s speed=1.06x    
frame=  241 fps=3.8 q=-0.0 size=  325350kB time=00:01:08.00 bitrate=39195.1kbits/s speed=1.06x    
frame=  244 fps=3.8 q=-0.0 size=  329400kB time=00:01:08.75 bitrate=39250.1kbits/s speed=1.06x    
frame=  246 fps=3.8 q=-0.0 size=  332100kB time=00:01:09.25 bitrate=39286.1kbits/s speed=1.06x    
frame=  249 fps=3.8 q=-0.0 size=  336150kB time=00:01:10.00 bitrate=39339.2kbits/s speed=1.06x    
frame=  252 fps=3.8 q=-0.0 size=  340200kB time=00:01:10.75 bitrate=39391.1kbits/s speed=1.06x    
frame=  254 fps=3.8 q=-0.0 size=  342900kB time=00:01:11.25 bitrate=39425.1kbits/s speed=1.06x    
frame=  257 fps=3.8 q=-0.0 size=  346950kB time=00:01:12.00 bitrate=39475.2kbits/s speed=1.06x    
frame=  260 fps=3.8 q=-0.0 size=  351000kB time=00:01:12.75 bitrate=39524.3kbits/s speed=1.06x    
frame=  262 fps=3.8 q=-0.0 size=  353700kB time=00:01:13.25 bitrate=39556.5kbits/s speed=1.06x    
frame=  265 fps=3.8 q=-0.0 size=  357750kB time=00:01:14.00 bitrate=39603.9kbits/s speed=1.06x    
frame=  268 fps=3.8 q=-0.0 size=  361800kB time=00:01:14.75 bitrate=39650.4kbits/s speed=1.06x    
frame=  270 fps=3.8 q=-0.0 size=  364500kB time=00:01:15.25 bitrate=39680.9kbits/s speed=1.06x    
frame=  273 fps=3.8 q=-0.0 size=  368550kB time=00:01:16.00 bitrate=39725.8kbits/s speed=1.06x    
frame=  276 fps=3.8 q=-0.0 size=  372600kB time=00:01:16.75 bitrate=39769.9kbits/s speed=1.06x    
frame=  278 fps=3.8 q=-0.0 size=  375300kB time=00:01:17.25 bitrate=39798.8kbits/s speed=1.05x    
frame=  281 fps=3.8 q=-0.0 size=  379350kB time=00:01:18.00 bitrate=39841.5kbits/s speed=1.05x    
frame=  284 fps=3.8 q=-0.0 size=  383400kB time=00:01:18.75 bitrate=39883.3kbits/s speed=1.05x    
frame=  286 fps=3.8 q=-0.0 size=  386100kB time=00:01:19.25 bitrate=39910.8kbits/s speed=1.05x    
frame=  289 fps=3.8 q=-0.0 size=  390150kB time=00:01:20.00 bitrate=39951.4kbits/s speed=1.05x    
frame=  292 fps=3.8 q=-0.0 size=  394200kB time=00:01:20.75 bitrate=39991.2kbits/s speed=1.05x    
frame=  294 fps=3.8 q=-0.0 size=  396900kB time=00:01:21.25 bitrate=40017.3kbits/s speed=1.05x    
frame=  297 fps=3.8 q=-0.0 size=  400950kB time=00:01:22.00 bitrate=40055.9kbits/s speed=1.05x    
frame=  300 fps=3.8 q=-0.0 size=  405000kB time=00:01:22.75 bitrate=40093.8kbits/s speed=1.05x    
frame=  302 fps=3.8 q=-0.0 size=  407700kB time=00:01:23.25 bitrate=40118.7kbits/s speed=1.05x    
frame=  305 fps=3.8 q=-0.0 size=  411750kB time=00:01:24.00 bitrate=40155.4kbits/s speed=1.05x    
frame=  308 fps=3.8 q=-0.0 size=  415800kB time=00:01:24.75 bitrate=40191.5kbits/s speed=1.05x    
frame=  310 fps=3.8 q=-0.0 size=  418500kB time=00:01:25.25 bitrate=40215.3kbits/s speed=1.05x    
frame=  313 fps=3.8 q=-0.0 size=  422550kB time=00:01:26.00 bitrate=40250.3kbits/s speed=1.05x    
frame=  316 fps=3.8 q=-0.0 size=  426600kB time=00:01:26.75 bitrate=40284.8kbits/s speed=1.05x    
frame=  318 fps=3.8 q=-0.0 size=  429300kB time=00:01:27.25 bitrate=40307.5kbits/s speed=1.05x    
frame=  321 fps=3.8 q=-0.0 size=  433350kB time=00:01:28.00 bitrate=40340.9kbits/s speed=1.05x    
frame=  324 fps=3.8 q=-0.0 size=  437400kB time=00:01:28.75 bitrate=40373.9kbits/s speed=1.05x    
frame=  326 fps=3.8 q=-0.0 size=  440100kB time=00:01:29.25 bitrate=40395.5kbits/s speed=1.05x    
frame=  329 fps=3.8 q=-0.0 size=  444150kB time=00:01:30.00 bitrate=40427.5kbits/s speed=1.05x    
frame=  332 fps=3.8 q=-0.0 size=  448200kB time=00:01:30.75 bitrate=40459.0kbits/s speed=1.05x    
frame=  334 fps=3.8 q=-0.0 size=  450900kB time=00:01:31.25 bitrate=40479.7kbits/s speed=1.05x    
frame=  337 fps=3.8 q=-0.0 size=  454950kB time=00:01:32.00 bitrate=40510.3kbits/s speed=1.05x    
frame=  340 fps=3.8 q=-0.0 size=  459000kB time=00:01:32.75 bitrate=40540.5kbits/s speed=1.05x    
frame=  342 fps=3.8 q=-0.0 size=  461700kB time=00:01:33.25 bitrate=40560.3kbits/s speed=1.04x    
frame=  345 fps=3.8 q=-0.0 size=  465750kB time=00:01:34.00 bitrate=40589.6kbits/s speed=1.04x    
frame=  348 fps=3.8 q=-0.0 size=  469800kB time=00:01:34.75 bitrate=40618.5kbits/s speed=1.04x    
frame=  350 fps=3.8 q=-0.0 size=  472500kB time=00:01:35.25 bitrate=40637.5kbits/s speed=1.04x    
frame=  353 fps=3.8 q=-0.0 size=  476550kB time=00:01:36.00 bitrate=40665.6kbits/s speed=1.04x    
frame=  356 fps=3.8 q=-0.0 size=  480600kB time=00:01:36.75 bitrate=40693.3kbits/s speed=1.04x    
frame=  358 fps=3.8 q=-0.0 size=  483300kB time=00:01:37.25 bitrate=40711.5kbits/s speed=1.04x    
frame=  361 fps=3.8 q=-0.0 size=  487350kB time=00:01:38.00 bitrate=40738.5kbits/s speed=1.04x    
frame=  364 fps=3.8 q=-0.0 size=  491400kB time=00:01:38.75 bitrate=40765.1kbits/s speed=1.04x    
frame=  366 fps=3.8 q=-0.0 size=  494100kB time=00:01:39.25 bitrate=40782.5kbits/s speed=1.04x    
frame=  369 fps=3.8 q=-0.0 size=  498150kB time=00:01:40.00 bitrate=40808.4kbits/s speed=1.04x    
frame=  372 fps=3.8 q=-0.0 size=  502200kB time=00:01:40.75 bitrate=40834.0kbits/s speed=1.04x    
frame=  374 fps=3.8 q=-0.0 size=  504900kB time=00:01:41.25 bitrate=40850.8kbits/s speed=1.04x    
frame=  377 fps=3.8 q=-0.0 size=  508950kB time=00:01:42.00 bitrate=40875.7kbits/s speed=1.04x    
frame=  380 fps=3.8 q=-0.0 size=  513000kB time=00:01:42.75 bitrate=40900.2kbits/s speed=1.04x    
frame=  382 fps=3.8 q=-0.0 size=  515700kB time=00:01:43.25 bitrate=40916.4kbits/s speed=1.04x    
Input #0, rtsp, from 'rtsp://admin:[email protected]:554/Streaming/Channels/101':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 1605672792.528800, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 1280x720 [SAR 189:190 DAR 168:95], 4 fps, 25 tbr, 90k tbn, 8 tbc
[h264_v4l2m2m @ 0x559fa35410] Using device /dev/video10
[h264_v4l2m2m @ 0x559fa35410] driver 'bcm2835-codec' on card 'bcm2835-codec-decode' in mplane mode
[h264_v4l2m2m @ 0x559fa35410] requesting formats: output=H264 capture=YU12
Input #0, rtsp, from 'rtsp://admin:[email protected]:554/Streaming/Channels/101':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 1605672792.545533, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 1280x720 [SAR 189:190 DAR 168:95], 4 fps, 25 tbr, 90k tbn, 8 tbc
[h264_v4l2m2m @ 0x55b11b2410] Using device /dev/video10
[h264_v4l2m2m @ 0x55b11b2410] driver 'bcm2835-codec' on card 'bcm2835-codec-decode' in mplane mode
[h264_v4l2m2m @ 0x55b11b2410] requesting formats: output=H264 capture=YU12
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Press [q] to stop, [?] for help
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Press [q] to stop, [?] for help
No frames received from gate in 5 seconds. Exiting ffmpeg...
Waiting for ffmpeg to exit gracefully...
No frames received from back in 5 seconds. Exiting ffmpeg...
Waiting for ffmpeg to exit gracefully...
FFmpeg didnt exit. Force killing...FFmpeg didnt exit. Force killing...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
gate: ffmpeg sent a broken frame. something is wrong.
gate: ffmpeg sent a broken frame. something is wrong.
gate: ffmpeg process is not running. exiting capture thread...


now running 3 cam . it was OK for prev 48 hrs. CPU now at 37% and temp 5 C. any idea?

I would start by trying to get a single camera to work again. I donā€™t see anything obvious in the logs, but it is hard to tell with the output from multiple cameras. Also, try removing the hwaccel args.