Motion Detection

If your shinobi-motion.js plugin is crashing try : setting the dimenions to 320x240. Pressing save, then modifying your regions if you have to and once again saving the settings.

Use Built-In

Based on Kevin Godell's pam-diff and pipe2pam. You no longer need to connect a plugin. Just switch Monitor Settings > Detector > Built-In to Yes and away you go.

If you choose to use Built-In Motion Detection then please review the "Once Installed" section of this page.

Otherwise following along below to use the plugin method and you can use your own or one of the ones provided.

Install Cario2 on Ubuntu / Debian

Cairo2 is the base engine used for detection.

  1. Install libraries

    sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++

Install Cario2 on CentOS / Fedora

  1. Install libraries

    sudo yum install cairo-devel libjpeg-turbo-devel giflib-devel -y
  2. Try this only if installing the plugin fails

    yum groupinstall "Development tools"

Install the Shinobi Plugin

  1. Navigate to your Shinobi directory and install the node.js wrappers needed to run the plugin. --unsafe-perm has been added because some machines aren't able to install without.

    sudo npm install [email protected] moment --unsafe-perm
  2. Setup the configuration file for the plugin.

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

    nano plugins/motion/conf.json
  4. 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
  5. Start the Motion plugin

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

Once Installed and Running

Setting the Indifference value is the key value to making your Motion Detector run correctly. The Indifference value varies based on the camera data being processed.

  • Indoor or Outdoor

  • Lighting Conditions

  • Frame Size

  • Noise Level of the Environment

  • Noise Level of the Picture Quality

  • Choice of Motion Detector : Plugin, Built-In, or Third Party

Kevin Godell's (Built-In) Motion Detector :The indifference value is the percentage of change in a region. A full frame detection is considered a detection on a region that covers the entire frame. The Indifference value is still represented in the red bar below.

  • Example of Use : Imagine you created a region 4 times pixel density of your left hand. Set the indifference to 25 (the pixel density of your left hand). Then wave both your hands in view and you should see a motion meter rating of atleast 50.

Moe's (shinobi-motion.js) Motion Detector Deprecated : This method was made by @soundstep originally for the browser. It seems to get a mushed number from the RGB values in the image. This is what I call Indifference and where I got the idea to name it that. The value will go up and down drastically to the point where I don't really know what the threshold actually is.

  • Example of Use : At my old home I lived at a busy street. I would have cars and people going by the camera all day. The motion meter (red bar under my monitor stream) was hovering around 40 to 50 from the shadows and grain of the 640x480 stream. When people would actually come up to my door it would shoot up to 70+. My choice was to set to 60 and it worked great... for that one camera.

Here are some important fields and elements to be aware of in the Shinobi panel.

  • UI Element > Motion Meter : When motion occurs a red bar will appear under your stream to indicate how much motion has happened.

  • Monitor Settings > Detector > Save to SQL : This will save events to the database so they can be reviewed in the Power Video Viewer.

  • Monitor Settings > Detector > How to Record : This chooses how the detector engine will choose to create or keep videos for review.

  • Monitor Settings > Detector > How to Record > Hotswap Modes : Monitor should be set to Watch-Only. Records when motion is found. By default it will record for 10 minutes then switch back to Watch-Only. This method does not have buffer frames. To get some frames before a specific event you can try using "Delete Motionless" instead.

  • Monitor Settings > Detector > How to Record > Delete Motionless Video : Monitor should be set to Record. This records all the time, Checks if motion happened when the segment closes and then deletes it if no motion is found.

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

  • Monitor Settings > Detector > Indifference : The opposite of sensitivity. Until what level of confidence should the plugin allow motion until setting off a trigger. This is also the global indifference value.

  • Monitor Settings > Detector > Region Editor > Indifference : If this value is left blank the global indifference value will be used.

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.

Support Shinobi development by subscribing to Shinobi Honor for the cost of two chocolate bars (USD).