Skip to content

Plugins

Moe edited this page Feb 5, 2017 · 26 revisions

Using a Plugin

We will use shinobi-opencv.js, a node.js plugin, for the example.

  1. Locate the plugin and install its required dependencies.
  • In this case it is OpenCV 2.4.9 and the npm called opencv.
  1. OpenCV 2.4.9 will be installed with install_opencv_2.4.sh
    • Run chmod +x install_opencv_2.4.sh to make executable.
  2. sudo npm install opencv as regular user to install the node.js npm for opencv.
  3. Run the plugin after camera.js is running.
  • pm2 start plugins/opencv/shinobi-opencv.js
  1. You should see OpenCV Connected inside the orange Detector box. More options should also have appeared.

Contributing a Plugin

Criteria for a plugin

  • Shinobi must be able to run if the plugin is not present.
  • Exceptions will only be made if the plugin is better off as a feature in which case it shouldn't be classified as a plugin.
  • Required dependencies must have an installation process included
  • Plugin must be a separate process (a daemon)
  • Plugin interfaces with camera.js through socket.io-client.
  • OpenCV plugin can be reviewed as an example.
  • Instructions must be provided for simple installation and usage.
  • Options for plugin must be hidden unless plugin is connected to camera.js.
  • Plugin cannot undermine the overall performance of Shinobi.
  • Reviewed, tested, and accepted by peers or a senior developer in the Slack community chat.

Why Socket.io for transport?

  • Well mainly because this allows for a plug and play feel.
  • Not having to restart the server for a plugin makes sense.
  • Fast and reliable data transfer.
  • It was previously attempted that we use UDP ports to achieve the same result but found there was quality loss.
  • Socket.io is supported by many languages, not just Node.js
  • Write your plugin in Python, C++, whatever. As long as it communicates with camera.js through socket.io the data exchange remains the same.
  • Since each plugin is it's own process it can be run on another machine entirely.
  • You could have one machine do camera.js functions and another do opencv requests.
Clone this wiki locally