Object Detection

  WARNING : Object Detection uses a lot of CPU power. The base of Shinobi's detection is done by OpenCV. If you can build OpenCV with CUDA support you will have far greater performance.

Install OpenCV without CUDA (Ubuntu - Easy)

OpenCV is the base engine used for detection. You will find most object detection software uses OpenCV or something based on it. 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 a Nvidia graphics chip.

  1. First you need to install the NVIDIA CUDA drivers. If you are on Ubuntu server don't be alarmed when the desktop environment appears. This is a side effect of installing NVIDIA drivers apparently.

    sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
    sudo echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" | sudo tee -a /etc/apt/sources.list
    sudo apt update
    sudo apt -y install cuda-drivers
  2. Reboot.

    sudo reboot
  3. Install CUDA Toolkit 9.1

    sudo apt-get -y install cuda-toolkit-9-1
  4. Check the driver status with NVIDIA's utility.

    nvidia-smi
  5. 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 |
    +-----------------------------------------------------------------------------+
  6. Download, Build and Install OpenCV with CUDA enabled.

    curl -s https://gitlab.com/Shinobi-Systems/Shinobi/raw/dev/INSTALL/opencv-cuda.sh | sudo sh
  7. 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 the OpenCV Shinobi Plugin

  1. Navigate to your Shinobi directory, where you downloaded the Shinobi files to.

    Example : cd /home/Shinobi
  2. Navigate to your Shinobi directory and install the node.js wrappers needed to run the plugin.

    sudo sh plugins/opencv/INSTALL.sh
  3. Setup the configuration file for the plugin.

    cp plugins/opencv/conf.sample.json plugins/opencv/conf.json
  4. OPTIONAL : Modify the conf.json to match your current listening port. Default is 8080.

    nano plugins/opencv/conf.json
  5. Check that your main configuration file, for the main Shinobi app, has a Plugin Key set. If one is not set the plugin will not work. You may review conf.sample.json to see the default setup.

    nano conf.json
  6. Start the OpenCV plugin

    sudo pm2 start plugins/opencv/shinobi-opencv.js
  7. When complete you will see Detector : OpenCV Connected in your Monitor Settings. Shinobi does not need to be restarted unless you modified the PluginKeys in conf.json

Once Installed

Important information to note are as follows.

  • Monitor Settings > Detector > Send Frames : Enabling this will push frames to your detection plugin for analyzation, in this case OpenCV.

  • Monitor Settings > Detector > Detect Objects : Enabling this will reveal a list of usable cascades. If you do not have any cascades a link will be provided in the dashboard or you can get on over to the public repository on Github.

Why aren't plugins just integrated?

Not everyone uses motion detection or object tracking 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.