Local realtime person detection for RTSP cameras

I have 3 Reolink’s and am having the save clips issue as well, so I was going to try this fix but am having issues.

Normally I’m pretty good at this, but I can’t find the “detect_objects.py” for the life of me inside of the docker container. Where is it located at?

what version are you running on?

I’m still on 0.7.1

Aah I’m trying out the new 0.8.0 beta1, so that would explain the difference!

Still can’t make the Reolink save_clips work on 0.8.0 in case anyone else comes across a solution.

Try this adding -map 0:2 argument at the end of the save clips output args.

Let me know if it works then I can upgrade to the 0.8.0 beta too.

# Optional: output args for clips streams (default: shown below)
    clips: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -map 0:2

Actually I got it to work with no messing around with parameters, I didn’t have the ‘clips’ role enabled…whoops!

Nice job on 0.8.0!

So I had some free time and jumped into this yesterday.
Got it working on indoor cams so I didn’t have to keep running outside to see if it was working and then switched to my outdoor cams where I would actually want to use this.
Had a delivery and wondered why I didn’t get a notification about it and frigate had crashed. Logs are here:

return method(self, database, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 1969, in execute
    return self._execute(database)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2141, in _execute
    cursor = database.execute(self)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3142, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3136, in execute_sql
    self.commit()
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2902, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: no such table: event
frigate.http                   ERROR   : Exception on /events/summary [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: no such table: event

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/frigate/frigate/http.py", line 65, in events_summary
    return jsonify([e for e in groups.dicts()])
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 6850, in __iter__
    self.execute()
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 1898, in inner
    return method(self, database, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 1969, in execute
    return self._execute(database)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2141, in _execute
    cursor = database.execute(self)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3142, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3136, in execute_sql
    self.commit()
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2902, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: no such table: event
frigate.http                   ERROR   : Exception on /events [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: no such table: event

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/frigate/frigate/http.py", line 141, in events
    return jsonify([model_to_dict(e) for e in events])
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 6850, in __iter__
    self.execute()
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 1898, in inner
    return method(self, database, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 1969, in execute
    return self._execute(database)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2141, in _execute
    cursor = database.execute(self)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3142, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3136, in execute_sql
    self.commit()
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 2902, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 185, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3129, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: no such table: event

Running the BETA addon on a supervised install and the manually installed integration.
Not sure why, but I couldn’t find Frigate in HACS.

The database it is talking about is called frigate.db and is in the clips directory. Any chance something happened to that file?

All of those messages are from ffmpeg. If you aren’t seeing issues, then you can set the ffmpeg log level back to fatal in your global_args.

Most definitely! I had so many clips from testing in there that I manually deleted them along with that .db file.
It was automatically remade so I guess I just thought it would be ok. I guess I need to restart the addon after doing that.
I ended up doing just that and it is working now. Glad it wasn’t anything wrong with the software and it was just my mistake.
Just wanted to post what I found in case it was something that might be an issue since this is a beta.

Thanks for the reply.

So you just enabled save slips and it works? Omitting map argument works also as ffmpeg auto selects the correct stream.

So your issue was not enabling the save slips option in the first place

That makes sense. The next beta release will include a config option to specify the location of the database file if you want to store it somewhere else.

2 Likes

I ran my library of ~3000 clips through frigate with both the MobileNet SSD (current model) and the MobileDet SSD (model in next beta) and the new model seems to be a good improvement. Note that you may see different results since these are clips from my own cameras. Based on the table below, the new default threshold will be .7. Increasing it to .75 should significantly reduce the likelihood of a false positive at the expense of missing some objects.
image

6 Likes

I changed the log level back to fatal and all those error’s aren’t showing now.

I do have this in my logs though

Exception in thread recording_maint:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 449, in wrapper
    ret = self._cache[fun]
AttributeError: _cache
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1515, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 452, in wrapper
    return fun(self)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1557, in _parse_stat_file
    with open_binary("%s/%s/stat" % (self._procfs_path, self.pid)) as f:
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 713, in open_binary
    return open(fname, "rb", **kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '/proc/5648/stat'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/opt/frigate/frigate/record.py", line 122, in run
    self.move_files()
  File "/opt/frigate/frigate/record.py", line 48, in move_files
    if process.name() != 'ffmpeg':
  File "/usr/local/lib/python3.8/dist-packages/psutil/__init__.py", line 634, in name
    name = self._proc.name()
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1515, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1610, in name
    name = self._parse_stat_file()['name']
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1522, in wrapper
    raise NoSuchProcess(self.pid, self._name)
psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=5648)

That is a rare edge case that I have fixed for the next beta already. Just restart.

1 Like

Is it this MobileDet model? https://arxiv.org/pdf/2004.14525.pdf That came out in April 2020?

The improvements looks really good – I assume your tests were done on specifically looking for Persons?

Yes. The edgetpu version was recently added. I am only testing for persons. I think I have a few false positive clips with cats and dogs in my test set, but not many. I’m not sure how much better it will handle those.

Is it simply just a matter of shutting down and restarting Frigate via docker-compose in order to pull the new image/fixes?

I do this

  1. docker-compose pull
  2. docker-compose up -d

if you have other containers in the compose file it will do a pull on all of them. You can probably tell it to just pull a specific one if you wanted.

edit: a restart will not re-pull the image

I generally recommend using the immutable tags (version specific), so the process to update would be to update the image tag in the docker-compose.yml file and run docker-compose up -d. If you are using the stable tags, then the steps from @hasshoolio work.

Ha, just learned something. I use tags and would update the compose file before the pull.
Now I know I don’t need to do that, just the up -d got the new image. Thanks!