AI motion detection with BlueIris: an alternate approach

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
For those interested in experimenting I've got a new release available under the danecreekphotography/node-deepstackai-triggers:dev Docker image tag that adds support for annotated images like this:

1592099860236.png

(Yes, this is a dog.)

Since it was a pretty hefty change I wouldn't mind some people playing with it before I promote it to the latest tag. It runs great on my dedicated BlueIris PC, but is a little sluggish on my laptop under a VM. Here's the details from the (unreleased) release notes:

Annotated images that show the objects and confidence percentage for things that fired the triggers are now available for Telegram messages. To enable the annotated image in Telegram messages set the new annotateImage property to true on the handler configuration. The annotated images are also exposed via a web server on port 4242 using their original file name for use by external services, for example http://localhost:4242/Dog_20200523-075000.jpg. While this should work without any additional configuration there are new environment variables available to control the web server port as well as retention of the annotated images. By default the images are kept for 60 minutes before being deleted. This can all be disabled by setting the DISABLE_ANNOTATIONS environment variable.
I'll be honest: I probably won't run with this on day-to-day. It was a fun challenge to add the feature request but isn't particularly useful to me :) Also there is a definite performance hit since the annotated image must be available before any of the notifications are fired to web URLs, MQTT, or Telegram and it takes awhile to generate.

If you encounter any issues with this build please report it in the github repo. Thanks!
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Version 2.1.0 is now available with a host of goodies:

  • Pushover notification support! See the wiki for how to enable it and how to configure it on a trigger.
  • Annotated images to show the detected objects and confidence percentage! This is kinda slow though so it's off by default. The annotated image can get sent in the Telegram or Pushover notification, or can be retrieved from an internal web server running on port 4242.
  • MQTT messages now include the trigger's name in the name property.
  • The length of time it takes to analyze an image is now calculated and available in various places: in the default MQTT message, in the mustache variables, and output on log messages.
  • For people using this with the images stored on a network share there's a new environment variable, CHOKIDAR_AWAITWRITEFINISH, that resolves problems where the image was getting sent to analysis before it was actually finished writing to the folder. There is a performance penalty for turning this on, however, so it's off by default. Don't turn it on unless you're seeing problems with Deepstack failures due to invalid images.
  • A warning when using Telegram triggers got cleaned up.
There are no breaking changes in this release. To update do docker compose pull then re-start the containers.
 
Joined
Jun 12, 2020
Messages
12
Reaction score
3
Location
Indiana
I am having a lot of issues getting Docker for Windows 10 to work. At first I could not switch from Linux to Windows because it said I didn't have containers enabled. I've since reinstalled an older version which allows me to work on Windows with containers enabled but now I'm getting an error pulling this image because Linux can't be used.

Anyone else have install issues?
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
To run on windows:

1. Upgrade to Windows 10 version 2004
2. Enable Windows Subsystem for Linux 2
3. Install the latest Docker Desktop

That's all you need and won't have any issues.
 

Splat

n3wb
Joined
Jun 8, 2020
Messages
9
Reaction score
7
Location
Australia
Version 2.1.0 is now available with a host of goodies:

  • Pushover notification support! See the wiki for how to enable it and how to configure it on a trigger.
  • Annotated images to show the detected objects and confidence percentage! This is kinda slow though so it's off by default. The annotated image can get sent in the Telegram or Pushover notification, or can be retrieved from an internal web server running on port 4242.
  • MQTT messages now include the trigger's name in the name property.
  • The length of time it takes to analyze an image is now calculated and available in various places: in the default MQTT message, in the mustache variables, and output on log messages.
  • For people using this with the images stored on a network share there's a new environment variable, CHOKIDAR_AWAITWRITEFINISH, that resolves problems where the image was getting sent to analysis before it was actually finished writing to the folder. There is a performance penalty for turning this on, however, so it's off by default. Don't turn it on unless you're seeing problems with Deepstack failures due to invalid images.
  • A warning when using Telegram triggers got cleaned up.
There are no breaking changes in this release. To update do docker compose pull then re-start the containers.
Thanks for the ongoing updates. I've not had a chance to give the new features a run but I will do so over the weekend.

Keep up your great contribution to the community.
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Version 2.2.0 is out. Only one change in this release, based on a feature request:

* Setting the retain property in mqtt.conf to true makes all MQTT messages get sent with the retain flag on. Default is false.

There are no breaking changes in this release. To update do docker compose pull then re-start the containers.

Note that the next release will be 3.0.0 and will break everyone I'm consolidating all the separate settings files for each of the services plus the environment variables into a single settings.json file. Triggers will still live in triggers.json. It was just getting too confusing to manage so many settings files every time a new service got added and it just isn't friendly for new users to have to make changes to a docker file, a settings file, and environment variables to do anything other than the basic setup.
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
As promised/warned version 3.0.0 is now out. This was a fundamental change to how settings are managed to set the project up for success long-term. You will need to make a new settings.json file to use this release. The triggers.json file is unchanged.

A sample, annotated, settings.json is available in the git repo. Complete documentation on the new settings file is also available on the wiki. While it's a bit of a pain to have to make the new file it does re-use what was already in the various other files (e.g. the mqtt.json content just moves over to settings.json) and this moves all of the Docker environment variables (except TZ) to a single easier to manage file.

Release notes:

Breaking changes
  • Settings are now kept in a single settings.json file instead of separate ones for each handler. You will need to create a settings.json file to use this release and will need to modify your Docker configuration to mount the settings file either as a secret or have it present in your /config folder. A sample is included in the sampleConfiguration folder as a base to start from. It is essentially what was in the separate files previously now just merged into one file. Additionally all environment variables except for TZ are now just settings in this file. Any other environment variables for the trigger container can be removed from your Docker configuration.
  • The source code repository's latest builds now produce out of the main branch. This means the location of the schema files has moved. If your triggers.json file has master in the $schema property you will need to update it to say main instead.
Non-breaking changes
  • All the schema file references are updated to reflect the new main branch name.
  • The ability to disable verbose logging is back. Somehow between version 1.8.0 and now it broke.
To update:

1. Run docker-compose pull
2. Create your settings.json file
3. Include it in the Docker container either via a settings secret or via mount point in the same folder as triggers.json
4. Run docker-compose up
 

Splat

n3wb
Joined
Jun 8, 2020
Messages
9
Reaction score
7
Location
Australia
As promised/warned version 3.0.0 is now out. This was a fundamental change to how settings are managed to set the project up for success long-term. You will need to make a new settings.json file to use this release. The triggers.json file is unchanged.

A sample, annotated, settings.json is available in the git repo. Complete documentation on the new settings file is also available on the wiki. While it's a bit of a pain to have to make the new file it does re-use what was already in the various other files (e.g. the mqtt.json content just moves over to settings.json) and this moves all of the Docker environment variables (except TZ) to a single easier to manage file.

Release notes:

Breaking changes
  • Settings are now kept in a single settings.json file instead of separate ones for each handler. You will need to create a settings.json file to use this release and will need to modify your Docker configuration to mount the settings file either as a secret or have it present in your /config folder. A sample is included in the sampleConfiguration folder as a base to start from. It is essentially what was in the separate files previously now just merged into one file. Additionally all environment variables except for TZ are now just settings in this file. Any other environment variables for the trigger container can be removed from your Docker configuration.
  • The source code repository's latest builds now produce out of the main branch. This means the location of the schema files has moved. If your triggers.json file has master in the $schema property you will need to update it to say main instead.
Non-breaking changes
  • All the schema file references are updated to reflect the new main branch name.
  • The ability to disable verbose logging is back. Somehow between version 1.8.0 and now it broke.
To update:

1. Run docker-compose pull
2. Create your settings.json file
3. Include it in the Docker container either via a settings secret or via mount point in the same folder as triggers.json
4. Run docker-compose up
Thanks for the latest revision the configuration is much cleaner. Testing so far and things look to be working fine.

Looking to test the image tag function over the weekend.
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Thanks for the latest revision the configuration is much cleaner. Testing so far and things look to be working fine.
Yeah, I had one of those "why didn't I do it this way from the start" moments. It's so much easier to add new settings, and it's way less hassle to set up for new users. Also reduces the edits to the Docker configuration to just the timezone.

I have another change in the dev tag image that auto-reloads settings and triggers when the files change. No more restarting the Docker containers!
 

Robotpedlr

n3wb
Joined
May 25, 2020
Messages
3
Reaction score
2
Location
Seattle, WA
Excited to try this, but a little over my head when you get to the Docker stuff. I have BI set up and running per the Hookup video. Any chance someone on here will make a YouTube video of the steps for the AI part per Neile's approach?
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Is your BI set up on a straight Windows box, no virtual machine funny business?

Are you on Windows 10?
 

Robotpedlr

n3wb
Joined
May 25, 2020
Messages
3
Reaction score
2
Location
Seattle, WA
Yes fresh install win 10 box. BI5 with everything running Exactly like the hook up video (1 camera stream at HD and another separate camera stream for SD on each). . I have 4 x 4K Annie IP cameras.

set up Deepstack (non docker set up) and AI per the video (which is working) but would like your set up that launches everything after reboot.
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Ok you're in great shape then. Make sure you are running the latest version of Windows 10 (version 2004). Stop running the non-Docker Deepstack. Follow the instructions at danecreekphotography/node-deepstackai-trigger.

You won't have to edit anything in settings.json. Edit docker-compose.yaml to point to your image folder and set your timezone. There's tons of comments in the file showing you where to make the edits. Edit triggers.json to be what you want, most should be 1:1 mappings from what you have for AI Tool. The sample provided has the basics necessary to watch for files in the input folder and call a web address, just like AI Tool.
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Version 3.1.0 is now available:

  • Triggers can now be manually activated via a REST API, and can be configured to retrieve a camera snapshot from a REST API instead of watching for image files that appear in a folder. This is useful for NVR systems other than BlueIris that don't support writing a snapshot automatically when motion is detected and can only call a REST API as the motion activated action.
  • Changes to settings.json and triggers.json are automatically detected and cause a reload. No need to restart the Docker container anymore! Just save the file and the system should notice the change and reload with the new configuration..
  • Occasional crashes when enableAnnotations is on are fixed.
  • Requests to end the system (e.g. via ctrl+c) are handled gracefully now.
  • The internal web server can now be enabled independently from annotated images using the enableWebServer setting. It's off by default, and enabled automatically when enableAnnotations is on for backwards compatibility reasons.
There are no breaking changes in this release. If you are already on version 3.0.0 then simply docker-compose pull then docker-compose up.
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
In terms of performance they should be essentially equivalent. The performance is largely driven by the time it takes to analyze each image and both approaches use the same DeepstackAI solution for that piece.

In terms of features this approach has a lot more options and capabilities in terms of notifications, message formats, etc. It also has the advantage of being a Docker image so it can run on any system (although I still personally run it in Docker on Windows), and has auto-restart capability via Docker.

One camera vs. duplicated cameras makes no difference either with this solution or AI Tool. All both systems care about is a folder with images in it to process and a web URL to call when something is detected.
 

IAmATeaf

Known around here
Joined
Jan 13, 2019
Messages
3,303
Reaction score
3,276
Location
United Kingdom
Does this also support masks like AITools?

Got the week off this week so may have a play with both.
 

joshwah

Pulling my weight
Joined
Apr 25, 2019
Messages
298
Reaction score
146
Location
australia
Thanks for the reply @neile -- one thing i liked about AI tools is that it has the UI where I can review the images etc.. does yours do the same? Do you have any screenshots of the UI?
 

Robotpedlr

n3wb
Joined
May 25, 2020
Messages
3
Reaction score
2
Location
Seattle, WA
Making progress (I think) followed steps to edit files (only trigger file as default time zone and AIinput locations already matched in docker compose). But when I try to run docker-compose up in CMD, I get this error

C:\Users\mark2>docker-compose up
ERROR: yaml.parser.ParserError: expected '<document start>', but found '<block mapping start>'
in ".\..\..\docker-compose.yml", line 427, column 11
 

neile

Getting the hang of it
Joined
May 15, 2020
Messages
132
Reaction score
67
Thanks for the reply @neile -- one thing i liked about AI tools is that it has the UI where I can review the images etc.. does yours do the same? Do you have any screenshots of the UI?
Mine is explicitly a headless design, to run as a service. There is no UI.
 
Top