Local realtime person detection for RTSP cameras

Hi @S-Przybylski, if I understand well you were able to enable HW acceleration on a raspberry. I’m using HA on a Raspi4 as well and before acquiring the costly Coral accelerator I would like to experiment a little bit more with “frigate” which is always working “borderline” with no HW acceleration. Would you mind sharing the steps you have done to allow me to obtain the same result? Thank you

hi all,
i have this set up and yet I could do with some help with capturing my cars on my drive.

i can see car was triggered by people walking past how can i get it to detect both cars instead of just one

Screenshot 2021-03-28 132153

@blakeblackshear, thank you for sharing your effort I’m just starting to get a glimpse of all the possibilities offered by this nice piece of software. Being far from an expert after having assembled the bare minimum (raspi4 HA, on docker and 4 dahua cameras) I am evaluating the purchase of the costly Coral but for now not having seen much of a “person” identification and after having played with some settings I found out that on the cameras there are “regions” (green rectangles which move and change over time on the screen) which I did not set. Would you please help me understand where they come from what’s their purpose and if/how I can modify them or point me to some sort of a guide. Thank you

For Pi4 try “-c:v h264_v4l2m2m”

Thank you, I failed trying that but now I finally understood what “blake” wrote in the guide about disabling the “Protection mode” (for someone with little experience like me: it’s a a virtual switch on the interface of the addon) and it seems to work now with no errors in the log. I will probably have now to decide the purchase of the coral to establish how effective all that is for my necessity. Again thank you :slight_smile: Btw do you happen to know why the “retain instruction” set to 1 doesn’t cancel the clips after one day? May I cancel them manually without the DB getting cross at me?

Firstly, Frigate looks fantastic. Amazing work.

I am setting up Frigate for the first time. My set up:

  • Intel NUC 5i5RYH
  • Docker on Ubuntu 20.04
  • Coral on order, but I’ll be using CPU for now

It’s my fist time using docker-compose, and I’d like some advice, please: Based on the documentation, I have so far modified docker-compose.yml as follows:

amd64version: '3.9'
services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: blakeblackshear/frigate:stable-amd64
    devices:
      - /dev/bus/usb:/dev/bus/usb
      - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - <path_to_config_file>:/config/config.yml:ro
      - <path_to_directory_for_media>:/mnt/servernvr
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - '5000:5000'
      - '1935:1935' # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: 'password'

Some questions:

  1. For the media directory, I will use a mounted Windows share via Samba accessible at /mnt/serverdvr. Is that the correct way to specify the path for docker-compose?
  2. I’m unsure what to put for Intel hwaccel. lshw -c video returns configuration: driver=i915. Should I specify /dev/dri/i915 or does hwaccel refer to something different. Googling “NUC 5i5RYH hwaccel” gives zero results.
  3. Am I likely to need to change amd64version?
  4. Should anything change in docker-compose when I start using Coral?

Thanks a a lot!

I would test it with a local directory first for media. You can always change it later. I’m not sure if you will have permissions problems with a Windows share. Depending on how many cameras you’re planning to run and what hardware you have it may add unnecessary strain on resources sending video back over the network. Samba is pretty slow too.
The hwaccel parameters are in the docs. There’s two different sets for intel gen10 before and after.
You need the amd64 tag even though it’s intel! Confusing isn’t it! All PC 64bit systems get referred to as this for some reason.
You define coral and everything else in the config yml file, which you also have to define the location in the docker compose. I would have a better read of the docs as you have to set your config file up before you fire the container up.

I’m having an issue where I update the mask in the frigate.yml file, and after I reboot Home Assistant, the mask editor in Frigate still shows the old mask. The mask was properly saved in the frigate.yml file. I’m not sure which mask is actually being used. Is this a known issue or has anybody else experienced this?

Edit: Restarting Home Assistant is not the same as restarting Frigate. Once I restarted Frigate, the new mask showed up in the mask editor.

Thanks, @Morphy. I don’t see in the docs that I need to create the config file before starting up the docker container, but that makes sense in retrospect. I had assumed that I’d edit the file after starting the container. So, does that mean that the container must be restarted after any changes to the config file, for example adding a camera?

I’ve had another read through the docs and now see the section about Intel hwaccel.

Think I’ll have a play around with the add-on to get more familiar before setting Frigate up on another machine.

Thanks again.

It’s in step 3 of the HassOS addon config. An addon is a container under the skin so it’s the same principle. Yes you need to restart the addon/container after any changes to the file. Hopefully we can get this in the UI soon, I’m sure it’s being worked on. If you want an easier way to manage docker, try portainer, it’s a web front end for docker and allows you to do most stuff you do via CLI, in docker.

1 Like

Hi,
how do you get it to stop detecting a car that hasn’t moved, whenever someone walk onto my drive it picks them up and also my car that hasn’t moved.

I’ve looked at the doc yet I don’t really understand the Reducing false positives section

1 Like

Has someone figured out a way to limit the notifications (with automation) once per event (using the event id).
My problem is that I would like to get a notification when a person enters my region “porch”, I don’t really want to use the type “end” as it delays the notification, and using the type “new” could miss it since I have a region set outside of the porch region. It would be great to be able to watch every event in the mqtt stack and evalute if it has been sent as a notification before.

It would be possible if saving the event_id to some temporary variables, but it would really need to be some kind of sliding window variable collection since it will add up to quite few ids over time

EDIT: I just figured out a simple solution that will do for now. I will use a an input_text to store the ids in a comma separated list and then twice or so per day just reset that list it should never be that many ids in a day that the input_text will overflow…

EDIT2: gah, just saw that 255 chars is maximum. I will probably have to clean it on every notification, but that should not be a problem, just som more yaml

@Anders_Karlstrom Is this for HA notifications? Why not just use a delay as has been mentioned in this thread numerous times.

You need to setup an object filter mask to cover the car in your driveway. That way, a car will never be detected in your driveway.

because I still want it to trigger on other cameras or other regions

You can setup the timer for specific cameras. It doesn’t have to be global.

Here is a snippet of just my driveway camera automation that includes the said timer:

condition:
    - "{{ trigger.payload_json['after']['label'] == 'person' }}"
    - "{{ trigger.payload_json['after']['camera'] == 'driveway' }}"
    - "{{ ( as_timestamp(now()) - as_timestamp(state_attr('automation.driveway_notfication', 'last_triggered')) |int(0) ) > 45 }}"

yes, that would work if I had one automation for each camera

the thing is I do want it to detect when a car pulls onto my drive, yet ignore it once it’s there and hasn’t moved.

This morning it picked a delivery man (Person) and picked up my car that hasn’t moved

This is probably a cache issue with the browser. I’ve seen it using Chrome. A restart of Chrome or hard refresh of the Frigate UI mask editor clears it.

Then you will need to use zones and alert for movement into a zone if using HA.

Frigate begins looking for objects on motion, so once motion is detected it looks EVERYWHERE to find objects except inside any objects filter masks you setup ahead of time. It doesn’t matter if those objects are moving or not. If Frigate begins looking for them it will find them without filter masks.

1 Like