Local realtime person detection for RTSP cameras

i had to come up with this nasty mess, including the following changes to frigate;

requires access to frigate source running as docker, or similar setups. basically you have to modify web/src/routes/Cameras.jsx… heres what i did:

edit Cameras.jsx with the following changes

  1. add these lines below all the other imports
import { route } from 'preact-router'; //CHANGES
import { useState, useEffect } from 'preact/hooks'; //CHANGES
  1. right below that, change export default function Cameras() {
    into
    export default function Cameras({ path, ...props }) {

  2. add this mess right below const { data: config } = useSWR('config');

  if(props.page)
  {
    const [show, setShow] = useState(false) 
    useEffect(() => {
      const timeout = setTimeout(() => {
        setShow(true)
      }, 1000)

      return () => clearTimeout(timeout)

    }, [show])

    if (!show) return null
    
    const fixer = String(props.url).split('?page=').pop().replace('&', '?');
    route(`${fixer}`);
  }
  1. cd into your frigate/web directory
  2. execute npm run build
    5a. if you havent or theres trouble, do npm install first, good luck with node version errors
  3. execute docker compose down ,very important as docker compose restart or docker compose up will not carry over changes for some stupid reason
  4. execute docker compose up --build -d
  5. verify it works by going to http://frigate:5000/?page=events&camera=CamName&label=person etc,etc. This should open up the events page and filter events showing only CamName persons.
    8a. Note: the arguments for frigate events as of 12/15/2022 from github repository are different, they are: ?page=events&cameras=CamName&labels=person

now you can pass a “?page=” url argument to frigate and it will take you to that page and pass arguments.
so the webcard can have /api/ha_ingress/randomstring/?page=events&camera=Cam&label=car and frigate will navigate to events and what not on its own without outside help.

More ugly hacks but i don’t see no one else trying to solve this…

1 Like