Object Detection

WARNING

Object Detection uses a lot of CPU Power. To mitigate this you can use an NVIDIA Graphics Processor. A desktop GPU, server-class GPU, or even Jetson Nano's tiny little Maxwell. Be sure to install the drivers before installing the plugin. Jetson users do not need to install CUDA drivers, they are already installed.

Install the NVIDIA Drivers and CUDA Toolkit (Ubuntu - Easy)

WARNING : Only do this if you have an NVIDIA graphics chip.
More Versions of CUDA that you can Install
  1. Install NVIDIA Drivers and CUDA Toolkit

    curl -s https://gitlab.com/Shinobi-Systems/Shinobi/raw/dev/INSTALL/cuda-10.sh | sudo sh
  2. Reboot.

    sudo reboot
Could not load dynamic library 'libcudart.so.10.0'; dlerror: libcudart.so.10.0: cannot open shared object file: No such file or directory
  1. Install NVIDIA Drivers and CUDA Toolkit

    curl -s https://gitlab.com/Shinobi-Systems/Shinobi/raw/dev/INSTALL/cuda-10.sh | sudo sh
  2. Reboot.

    sudo reboot

Install the TensorFlow plugin with or without CUDA (Ubuntu 19.10 - Easy)

TensorFlow is the most refined detection method available with Shinobi. There are numerous model sets you can choose from. The default ones provided with the installer are general purpose and detect a number of different things.

Install OpenCV without CUDA (Ubuntu - Easy)

OpenCV is an engine used for detection, you should opt to use TensorFlow instead though. This is the same install script used in the CUDA installation but if you do not have the NVIDIA Drivers and CUDA Toolkit it will install OpenCV without it.
  1. Install libraries

    curl -s https://gitlab.com/Shinobi-Systems/Shinobi/raw/dev/INSTALL/opencv-cuda.sh | sudo sh

Install OpenCV with CUDA (Ubuntu - Easy)

WARNING : Only do this if you have an NVIDIA Graphics Processor and have ran the install script provided above for the Drivers and Toolkit. If you already have them installed please be sure they are compatible with the plugins. You should opt to use TensorFlow instead.
  1. Check the driver status with NVIDIA's utility.

    nvidia-smi
  2. nvidia-smi should show you something like this.

    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 390.25 Driver Version: 390.25 |
    |-------------------------------+----------------------+----------------------+
    | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
    | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
    |===============================+======================+======================|
    | 0 GeForce GTX 1050 Off | 00000000:01:00.0 Off | N/A |
    | 30% 30C P0 N/A / 75W | 0MiB / 1999MiB | 0% Default |
    +-------------------------------+----------------------+----------------------+

    +-----------------------------------------------------------------------------+
    | Processes: GPU Memory |
    | GPU PID Type Process name Usage |
    |=============================================================================|
    | No running processes found |
    +-----------------------------------------------------------------------------+
  3. Download, Build and Install OpenCV with CUDA enabled.

    curl -s https://gitlab.com/Shinobi-Systems/Shinobi/raw/dev/INSTALL/opencv-cuda.sh | sudo sh
  4. Driver not starting? You may need to reboot. If not then you may need to install version 340 instead.

    sudo apt install nvidia-340* -y

Install OpenALPR with CUDA (Ubuntu - Easy)

WARNING : Be sure you have OpenCV built and installed with CUDA.
  1. Download, Build and Install OpenALPR with CUDA enabled.

    curl -s https://gitlab.com/Shinobi-Systems/Shinobi/raw/dev/INSTALL/openalpr-gpu-easy.sh | sudo sh

Install a Shinobi Plugin

We will use TensorFlow as the example for this section. You may need sudo infront of some commands if your user doesn't have permission to execute them.
  1. Navigate to your plugin's directory, where you downloaded the Shinobi files to.

    Example : cd /home/Shinobi/plugins/tensorflow
  2. Navigate to your Shinobi directory and install the node.js wrappers needed to run the plugin. Some plugins will complete the conf.json modifications for you within this installer.

    sh INSTALL.sh
  3. Modify the conf.json key value to anything you want, make it random.

    nano conf.json
  4. Open your main conf.json.

    nano /home/Shinobi/conf.json
  5. Add the key you created to allow the plugin to authenticate. TensorFlow123123 is the default key provided in the conf.json for the TensorFlow plugin.

    "pluginKeys":{"TensorFlow":"TensorFlow123123"}
  6. Shinobi will need to be restarted after modifying connection keys

    pm2 restart camera
  7. Start the plugin

    pm2 start shinobi-tensorflow.js
  8. When complete you will see Object Detection : TensorFlow Connected in your Monitor Settings.

Once Installed

Important information to note are as follows.

  • Monitor Settings > Global Detector Settings > Send Frames : Enabling this will push frames to your main detection.

  • Monitor Settings > Global Detector Settings > Motion Detection : Disabling this will make your Object Detection as the primary detection engine.

  • Monitor Settings > Global Detector Settings > Object Detection > Send Frames : Enabling this will push frames to your object detection engine.

  • Monitor Settings > Global Detector Settings > Object Detection > Check For Motion First : Enabling this will force check for motion before sending any images to the object detector.

Why aren't plugins just integrated?

Not everyone uses object detection and the libraries required can be bothersome to install, based on the OS. For example if I make shinobi-opencv.js a feature then everyone will be required to install OpenCV just to use basic features in Shinobi. This also allows us to swap the plugin with a custom one or run it on another machine entirely. Sharing the work between multiple machines can be a great way to optimize performance.