1. Install Docker and install and start DeepQuestAI container in Docker
Docker can be installed on Linux, macOS and Windows. As BI-users most likely
will have a Windows PC running already, I will describe the setup process for Windows 7 (because imho someone who runs a Win10 pc containing all sensitive CCTV files probably does not care that much about privacy #nooffense). If you want to use your NVidia gpu, as far as I'm concerned, you need to run docker on linux. Here is a guide on how to use DeepQuestAI with the gpu:
Using DeepStack with NVIDIA GPU — DeepStack 0.1 documentation .
1.2 Install DeepQuestAI in Docker: open the Docker Quickstart Terminal (shortcut on the desktop) and enter 'docker pull deepquestai/deepstack' as soon as docker finish setting up everything. The installation of DeepQuestAI takes some time aswell, meanwhile you can proceed with step 1.3
1.3 Although free, DeepQuestAI needs an API key, so we have to register an account (email not needed). Create an account at
Sign Up, choose the free plan (that is sufficient for our use), go to the portal (Dashboard) and copy your API key. Notice that on the Dashboard it says 'Expires: Unlimited'.
1.4 As soon as DeepQuestAI is installed, start DeepQuestAI(from now on I'll call it DQAI
) using the command 'docker run --restart=always -e VISION-DETECTION=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack'
1.5 Docker natively uses a strange ip address 192.168.99.100, so open this address with you webbrowser and you'll see the DQAI interface, now input the API key and activate it. Notice that now, an expiry date is give (in 2 years). I don't know if the API expires or or not, but getting a new API key every 2 years isn't a great problem imho.
Now the actual software that analyzes the images is already running as a webservice, so if Docker hadn't set it up with this unusual IP address,we would be able to access DQAI not only from the server it is running, but from every computer in the network.
2. Configure the program according to your setup and requirements
2.1 Download the attached program and unzip it. The program is designed to analyze images from one camera (or at least to call only one trigger url [of one camera]), but you can run multiple programs, one for every camera, if you wish.
2.2 open the config.txt using Notepad++ or some other text editor that does not drive you crazy
. Now what you see looks like the following:
Code:
DeepStack URL and Port: "192.168.99.100:80" (format: "url: port", example: "192.168.99.100:80")
Trigger URL: "http://192.168.1.133:80/admin?trigger&camera=frontyard&user=admin&pw=secretpassword" (format: "url", example: "http://192.168.1.133:80/admin?trigger&camera=frontyard&user=admin&pw=secretpassword")
Relevant objects: "person, bicycle" (format: "object, object, ...", options: see below, example: "person, bicycle, car")
Input path: "C:/BlueIris/New/" (example: "C:/BlueIris/New/")
Output path: "C:/BlueIris/AIDetections/" (empty to disable saving cutouts with detected objects, example: "C:/BlueIris/AIDetections/")
Continue after detection of relevant object: "no" (options: "yes" or "no", explanation: if the first image with relevant objects is detected, analyse the remaining images aswell?)
Input file begins with: "" (only analyze images which names start with this text, leave empty to disable the feature, example: "backyardcam")
Start delay: "" (input how many seconds the program shall wait before starting, example: "3")
Telegram option (leave empty to disable):
Telegram Token: ""
Telegram Chat ID: ""
possible trigger objects: person, bicycle, car, motorcycle, airplane,bus, train, truck, boat, traffic light, fire hydrant, stop_sign,parking meter, bench, bird, cat, dog, horse, sheep, cow, elephant,bear, zebra, giraffe, backpack, umbrella, handbag, tie, suitcase,frisbee, skis, snowboard, sports ball, kite, baseball bat, baseball glove,skateboard, surfboard, tennis racket, bottle, wine glass, cup, fork,knife, spoon, bowl, banana, apple, sandwich, orange, broccoli, carrot,hot dog, pizza, donot, cake, chair, couch, potted plant, bed, dining table,toilet, tv, laptop, mouse, remote, keyboard, cell phone, microwave,oven, toaster, sink, refrigerator, book, clock, vase, scissors, teddy bear, hair dryer, toothbrush
Please read through the explanations and modify all parameters according to your needs and save the file. When setting up your configuration, please mind the following information:
Input path: The input path is where Blue Iris stores the alert images. We can already add this path to Blue Iris by opening the settings of Blue Iris, then 'Clips and archiving', then click on one of aux folders in the list on the left (if you click on p.e. 'Aux_7' and don't move the cursor for 1-2s, you will be able to change the displayed name) and then set it to the input path we also specified in the config.txt .
If we want the input path to be a subfolder of the folder where the program is located, we can use a relative path, p.e. "./input/" would create a new folder 'input' in the programs base directory.
Output path: If we don't specify an output folder, the program won't store the image cutouts containing detected objects (saves resources). The output path can be a relative path just like the input path.
Relevant objects: Please note that despite that fact that it is written, trigger objects containing multiple word (like 'fire hydrant') probably wont work due to the way the config file is processed by the program. It's the first actual program I wrote, so please excuse that.
Input file begins with: Blue Iris will store the alert images under names that start with the camera name, so p.e. 'aifrontyard.20180326_054241.0.64.jpg'. If we store the alert images of multiple cameras in that folder, we can filter the images from the duplicated camera out by setting the option 'Input file begins with:' to the name of our duplicated camera, in this case 'aifrontyard'.
Start delay: It makes sense to set 'Start delay' to maybe 2-5s, because BI needs a short time to save the images. If we set Blue Iris to make e.g. a snapshot every second for the next 5s after an alert, we furthermore profit from the fact, that after the program has analyzed the first images, it will check if new images are in the folder that were saved while the program was analyzing. Unless configured otherwise, it will analyze the new images aswell.
Continue after detection of relevant object: This option is quite relevant. If we just want to get an alert when something is detected, "no" is a good configuration. But this also means, that as soon as the first person is detected, the program will call the alert URL and then stop analyzing the remaining images (less CPU-heavy). So if we want to be able to see ALL objects cutouts from ALL alert images in the output path, we will want to set this feature to "yes".
Trigger URL(s): If we don't specify one or multiple 'Trigger URL(s)', no trigger call will be made. If we want to call multiple urls, we have to seperate the urls with commas. Every url has to start with '
'. Meanwhile, the trigger URL is not limited to Blue Iris, practically everything can be triggered that has such an URL that one can call for a trigger.
Alerting Blue Iris with the Trigger URL: To use the trigger url, you have to do the following in Blue Iris:
1. go to Setting->Webserver->Advanced and disable 'use secure session keys and login page'.
2. go to Settings->Users and eighter select a user and copy the password, or create a new administrator user.
3. Open the camera aproperties of the camera you want to to the AI analysis on and under General, copy the short camera name(p.e. 'frontyard').
4. Take the following url and input blue iris IP, user, password and short cam name:
[Blue Iris IP]:80/admin?trigger&camera=[shart cam name]&user=[user]&pw=[password] .
If you filled in everything, copy/paste the whole url into your webbrowser and make sure it causes an alert.
Telegram option: Leave this empty for now, if you would like to receive Telegram notifications later, then you can do it after getting everything to run properly.
Restore config.txt: If you accidently messed the config.txt up, just remove it and run testAI.exe once, it will recreate a working template.
A configuration might, for example, look like this:
Code:
DeepStack URL and Port: "192.168.99.100:80" (format: "url: port", example: "192.168.99.100:80")
Trigger URL: "http://192.168.1.133:80/admin?trigger&camera=frontyard&user=admin&pw=secretpassword" (format: "url", example: "http://192.168.1.133:80/admin?trigger&camera=frontyard&user=admin&pw=secretpassword")
Relevant objects: "person, bicycle, car, truck" (format: "object, object, ...", options: see below, example: "person, bicycle, car")
Input path: "C:/BlueIris/New/" (example: "C:/BlueIris/New/")
Output path: "C:/BlueIris/AIDetections/" (empty to disable saving cutouts with detected objects, example: "C:/BlueIris/AIDetections/")
Continue after detection of relevant object: "no" (options: "yes" or "no", explanation: if the first image with relevant objects is detected, analyse the remaining images aswell?)
Input file begins with: "aifrontyard" (only analyze images which names start with this text, leave empty to disable the feature, example: "backyardcam")
Start delay: "3" (input how many seconds the program shall wait before starting, example: "3")
Telegram option (leave empty to disable):
Telegram Token: ""
Telegram Chat ID: ""
possible trigger objects: person, bicycle, car, motorcycle, airplane,bus, train, truck, boat, traffic light, fire hydrant, stop_sign,parking meter, bench, bird, cat, dog, horse, sheep, cow, elephant,bear, zebra, giraffe, backpack, umbrella, handbag, tie, suitcase,frisbee, skis, snowboard, sports ball, kite, baseball bat, baseball glove,skateboard, surfboard, tennis racket, bottle, wine glass, cup, fork,knife, spoon, bowl, banana, apple, sandwich, orange, broccoli, carrot,hot dog, pizza, donot, cake, chair, couch, potted plant, bed, dining table,toilet, tv, laptop, mouse, remote, keyboard, cell phone, microwave,oven, toaster, sink, refrigerator, book, clock, vase, scissors, teddy bear, hair dryer, toothbrush
3. Configure Blue Iris
I anticipate you are familiar with Blue Iris, so I keep the description simple.
3.1 Firstly we have to create a camera whose only purpose is to start the AI detection program when a motion is detected. So add a new camera, give it a name that makes sense (e.g. if your original camera was called 'frontyard', call it 'aifrontyard'), and under type select 'copy from another camera' and choose the appropriate one.
3.2 Keep in mind that this cameras only job is to detect motion and then start the AI program, so disable all features on this camera that are not needed (recording, pretrigger, etc). Because Blue Iris is already prepared to work with camera clones it is not neccessary to lower the resolution to save on CPU resources. Quite the opposite: If the camera stream url isn't changed, there will be zero additional CPU usage. Instead, changing the stream url to p.e. a profile with a lower resolution will cause additional CPU load.
3.3 now go to Record, check 'JPEG snapshot each (mm:ss)', select the folder you defined as the input folder in the AI detection program, check the box 'Only when triggered' and set the interval to p.e. 0:01.0 (one image every 1 second). Furthermore, you might want to disable 'Create Alert list images when triggered', because otherwise alot of false-alarm images (remember we set the motino detection to be very sensitive) will be stored in your alerts folder.
3.4 go to 'Trigger' and set the Break time 'End trigger unless retriggered' to p.e. 5s. While setting this value, remember the following: If you set the interval in step 3.3 to 1s, then 5s means, that 5 images are created and have to be analyzed one after the other.
3.5 last but not least go to 'Alerts', check 'run a program or execute a script', click 'configure' and select testAI.exe (in the attachment) as the file to run. For the initial phase of using the AI, it might be useful to set the window to 'normal' and not to 'hide', because this facilitates troubleshooting.
Now run around in front of your cameras or - if you are terribly lazy - right click on the new camera we created and select 'Trigger now'. After the AI program did the analysis, check the trigger clips of the original camera and the image cutouts in the output folder (well if you just clicked trigger now, you should not have images outputted and an alert because - hopefully - there is no one sneaking around on your ground, trying to steal your car. Otherwise get the shotgun and .... no no no that's a bad attitude
).
If you are still to lazy to go out, you can take any jpg picture containing an object that you configured to trigger an alert, put it into the input folder and put the name of the camera (p.e. 'aifrontyard') in front of the image name. And then manually trigger the camera.
If everything works fine then you now have lowered your false detection rate significantly while enhancing the rate of correct detections.