initial commit

This commit is contained in:
cedricve
2015-04-20 14:54:34 +02:00
commit 0bf2e11207
125 changed files with 3757 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Getting started
* [What is Kerberos.io](#what-is-kerberos-io)
* [How does it work](#how-does-it-work)
* [Installation](#installation)
* [Contribute](#contribute)
## Let's get started
In the video below you get a quick overview of how Kerberos works and how you can configure it. The video isn't technical but explains the different features Kerberos offers you.
<iframe src="https://player.vimeo.com/video/121532472?autoplay=0&color=943633" style="width:100%; height: 400px;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<a name="what-is-kerberos-io"></a>
## What's Kerberos.io?
Kerberos is a low-budget surveillance solution created for the **Rapsberry Pi**. Kerberos is open source, so you and others, can customize the source code to your needs and share it. It has a *low-energy* footprint when deploying on the Raspberry Pi and it's *easy to install*, you only need to transfer the image to your SD card and you're done.
Use your mobile phone, tablet or PC to keep an eye on your property. View the activity with our *responsive* and *user-friendly* web interface. Look at the dashboard to get a graphical overview of the past days. *Multiple* Kerberos *instances* can be installed and can be viewed with [only one web interface](/1.0.0/addons/Cloud).
<a name="how-does-it-work"></a>
## How does it work?
Kerberos is devided into two parts: the **machinery** (Back end, C++) and the **webinterface** (Front end, PHP). The machinery is responsible for the image processing and the webinterface is used to configure the machinery and to view the events that were detected by the machinery. Both parts are installed on the device, in most cases the Raspberry Pi. The machinery can trigger multiple output devices when an event occurred; it can trigger a GPIO pin, save an image to disk or send a TCP packet.
<a name="installation"></a>
## Installation
Kerberos is **easy to install**, you just have to copy the kerberos image to your SD card, plug it into your Raspberry Pi and that's it. Kerberos can be installed on other devices than the Raspberry Pi; for development or production. Therefore you will need to compile the machinery yourself and install the webinterface with your favorite webserver; nginx, apache, etc.
<a name="contribute"></a>
## Contribute
Want to contribute? You're a front end designer, user experience guru, an ambitious programmer, or a Ph.D. in Computer Vision who wants to take kerberos.io to the next level? Then we like to welcome you to the community. Contributions are taken very seriously, besides your code, testing and documentation are very important!

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
1.0.0/2_raspberry-pi-a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

29
1.0.0/2_requirements.md Normal file
View File

@@ -0,0 +1,29 @@
# Requirements
* [Which hardware do I need?](#which-hardware-do-i-need)
<a name="which-hardware-do-i-need"></a>
## Which hardware do I need?
Kerberos.io is created for the **Rapsberry Pi**. So it is obvious you will need a Raspberry Pi before you can start using Kerberos. However you can also use Kerberos.io on your local environment, but of course that is not the main goal of Kerberos.
You can select which Raspberry Pi model you need: **Raspberry Pi Model A, A+, B, B+ or Raspberry Pi 2**.
![Raspberry Pi Model A](2_raspberry-pi-a.png)
You need a **4GB or bigger SD card**, on which you will have to deploy the Kerberos.io image; look at the installation page for more information about the deployment.
![4GB SD card](2_sandisk_4gb_sd_card.png)
A **micro USB 5V** charger.
![Micro USB 5V charger](2_micro-usb-5V-charger.png)
A **USB camera** or the **Raspberry Pi camera** module.
![Raspberry Pi Camera Module](2_raspberry-camera-module.png)
*(Optional)* We can use a **WIFI dongle** instead of an ethernet cable, but this is not required. We recommend the **Edimax** ew-7811un WIFI dongle.
![Edimax WIFI dongle](2_edimax-wifi-dongle.png)
*(Optional)* The **Scorpi B+**, a flexible Mount for the Raspberry Pi Camera Board.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
1.0.0/2_scorpi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

101
1.0.0/3_installation.md Normal file
View File

@@ -0,0 +1,101 @@
# Installation
* [Install from image](#install-from-image)
* [Download the image](#download-the-image)
* [Insert your SD card](#insert-your-sd-card)
* [OSX: transfer image](#osx-transfer-image)
* [Windows: transfer image](#windows-transfer-image)
* [OSX/Linux: transfer image with terminal](#transfer-image-with-terminal)
* [(Optional) Setup WIFI connection](#setup-wifi-connection)
* [Install from source](#install-from-source)
Kerberos is **easy to install**, you just have to copy the Kerberos image to your SD card, plug the SD card into your Raspberry Pi and that's it. It can also be installed on other devices than the Raspberry Pi; for development or production. Therefore you will need to compile the machinery from source and install the webinterface with your favorite webserver.
<a name="install-from-image"></a>
## Install from image
If you want to use Kerberos.io **as a service**, this would be the preferred way. Kerberos is provided as an image, a pre-installed operating system. The only thing you have to do to make things work, is to transfer the image to your SD card. After transferring you can just plug the SD card into your Raspberry Pi and kerberos will work; isn't that great!
The're a lot of different ways to accomplish this, and they are different according the operating system you will be using to transfer the image.
<a name="download-the-image"></a>
### 1. Download the image
First you will need to download the Kerberos image; click on the image below. The Kerberos.io image contains a Linux operating system, built on Arch Linux. The image has the machinery and webinterface installed, and ofcourse all the dependencies Kerberos needs. With this image you just have to plugin the SD card in your Raspberry Pi and you're done.
#### Raspberry Pi Model A, A+, B and B+
The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video.
![Kerberos.io image](3_kerberos-image.png)
#### Raspberry Pi Model 2
The Raspberry Pi 2 is the successor to the Raspberry Pi. It builds upon the original model B+ upgrading to 1 GB of RAM, and replacing the aged ARMv6l single-core with an ARMv7l Cortex-A7 quad-core.
![Kerberos.io image](3_kerberos-image.png)
<a name="insert-your-sd-card"></a>
### 2. Insert your SD Card
Ensure that you have inserted the SD card, that you wish to clone, into the SD card reader. If your PC/Mac does'nt have an internal SD card reader, you will need to plug in an external SD card reader via a USB socket.
<a name="osx-transfer-image"></a>
### 3. OSX: transfer image
* Download the .dmg file (RPi-sd card builder v1.2)
[![RPi logo](3_rpi-logo-cloner.png)](https://mega.co.nz/#!PZc2HTTQ!eD9dtFpoKnbZqP1hkvrv43_Pvc9xadMVxRP2K-M8n88)
* Run the app
* Select the operating system distributions (.img file)
* You will prompt with this. After you connect your SD card press continue.
* Now you have to select your SD card.
* Now the program will need administrator privileges. insert your password
* Confirm that your SD card has been unmounted.
<a name="windows-transfer-image"></a>
### 3. Windows: transfer image
* Download and install the [Win32DiskImager](http://sourceforge.net/projects/win32diskimager/files/latest/download).
* Select the image file you've downloaded earlier and the drive letter of the SD card.
<a name="transfer-image-with-terminal"></a>
### 3. OSX/Linux: transfer image with terminal
#### Locate Your SD Card
Open Terminal and enter the following command to locate your SD Card:
diskutil list
Look for your SD card; you can look at the size of the disk. In most cases you will be using a 4GB or bigger SD card.
#### Unmount SD card
We located our SD card at the /dev/disk3 drive; please note that this can be another disk drive, see previous step. In Terminal, enter the following command:
diskutil unmountDisk /dev/disk3
#### Format SD card
To format the SD card, enter the following command:
sudo newfs_msdos -F 16 /dev/disk3
#### Transfer image to your SD card
In Terminal, enter the following command ensuring that you identify the correct destination disc.
sudo dd if=~/Desktop/kerberos-io.img of=/dev/disk3
<a name="setup-wifi-connection"></a>
### 4. (Optional) Setup WIFI connection
If you will be using Kerberos.io with a WIFI dongle, then check out the [F.A.Q. page](/1.0.0/FAQ#setup-wifi).
<a name="install-from-source"></a>
## Install from source
This will be the procedure if you want to contribute to Kerberos or if you want to use Kerberos on your local machine. To install Kerberos from source; you will need to [compile the machinery](/1.0.0/machinery/installation) from source and [import the webinterface](/1.0.0/web/installation) into your favorite webserver.

BIN
1.0.0/3_kerberos-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
1.0.0/3_rpi-logo-cloner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,32 @@
# Introduction
* [The web interface](#the-web-interface)
* [How does it work](#how-does-it-work)
* [Installation](#installation)
* [How to access](#how-to-access)
<a name="the-web-interface"></a>
## The web interface
Kerberos.web, the webinterface, allows you to configure the machinery and to view events that were detected by the machinery. You can use your mobile phone, tablet or desktop to view the images with the *responsive* and *intuitive* web interface.
<a name="how-does-it-work"></a>
## How does it work?
The webinterface is written in PHP using the extremely popular PHP Framework **Laravel**. It visualizes images, taken by the machinery, in a intuitive and responsive way. Besides a server-side framework, it also uses a client-side framework **Backbone** to create the dynamic behaviour. The webinterface includes the latest development tools, to increase development efficiency: RequireJS, bower, LESS, etc.
Besides visualization, the webinterface is also used to configure the machinery. On the settings page a user can select different options, for example a user could select a region where motion should be detected or could select a time range when motion could be detected, which algorithm is used, etc.
The webinterface can also be used to configure Kerberos with our [**cloud application**](/1.0.0/addons/Cloud). The setup is very easy, you only need to create an account on our cloud application, request a key, and enter it in every webinterface you want to have synced.
<a name="installation"></a>
## Installation
If Kerberos is installed from the image, the webinterface will be pre-installed and nothing is left to do. If you want to install the webinterface from source, you will need to create a new webapplication on your webbrowser and transfer the webproject.
<a name="how-to-access"></a>
## How to access
You can access the webinterface by entering the ip address of the Raspberry Pi in your favorite browser. When the webapplication is loaded you will see a login page, on which you will need to enter your credentials. The default username and password is **root**. You are able to change this password by editing the **app/config/app.php** file.
![Login page kerberos.io webinterface](1_how-to-access.png)

View File

@@ -0,0 +1,106 @@
# Installation
* [Install from source](#install-from-source)
* [Install on Arch Linux](#install-from-source-on-arch-linux)
The web interface is already installed on the Kerberos image, however you can also install the webinterface from source; you don't need to do this if you've deployed the Kerberos image on the SD card.
<a name="install-from-source"></a>
## Install from source
The web interface can be installed standalone, for example to host the web interface on an external server; e.g. to increase performance and to centralize multiple kerberos instances.
<a name="install-from-source-on-arch-linux"></a>
### Install on Arch Linux
Update the Arch Linux kernel
pacman -Syyu
Install git, nginx, php with extensions and nodejs
pacman -S git nginx php php-fpm php-gd php-mcrypt php-apc php-composer nodejs
Start nginx and php-fpm on boot
systemctl enable nginx
systemctl enable php-fpm
Edit nginx config
nano /etc/nginx/nginx.conf
Copy and paste following config
user http http;
worker_processes 1;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
http {
index index.html index.htm index.php;
include mime.types;
root /home/kerberos-web/public;
server {
server_name kerberos.rpi kerberos.rpi;
index index.php index.html index.htm;
location /{
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
Make sure you've enabled following php extensions: mcrypt, phar, gd and openssl.
nano /etc/php/php.ini
Uncomment following extensions
extension=mcrypt.so
extension=phar.so
extension=gd.so
extension=openssl.so
Add the APC extension at the end of the extensions list
extension=apcu.so
Go to home directory
cd /home
Get the source code from github
git clone https://github.com/kerberos-io/web kerberos-web
Install php packages by using composer
cd kerberos-web
composer install
Change config file: edit the "config" variable, link it to the config directory of the kerberos-io repository. If you don't have the kerberos-io repository installed on that specific server, you can make it an empty string. In this case the option "settings" won't show up in the navigation menu. Please note that the default value is set to the destination of the machinery when installed on the Raspberry Pi.
nano app/config/app.php
Change write permission on the storage directory
chmod -R 777 app/storage
Install bower globally by using node package manager, this is installed when installing nodejs.
npm -g install bower
Install Front end dependencies with bower
cd public
bower --allow-root install

View File

@@ -0,0 +1,40 @@
# Contribute
* [Versioning](#versioning)
* [Composer](#composer)
* [Laravel](#laravel)
* [Bower](#bower)
This documents describes how to contribute to Kerberos and describes all the technical stuff you will need to know. If you want to contribute you will need to install the source code on your local environment.
<a name="versioning"></a>
## Versioning
The source is managed on [Github](https://github.com/kerberos-io), and thus we are using git as our version control. For simplicity we are using following [branching model](http://nvie.com/posts/a-successful-git-branching-model/). The model includes:
* main branch
* develop branch
* hotfix and release branches
If you are a new developer, fork the development branch and send a pull request.
<a name="composer"></a>
## Composer
Make sure you have [composer installed](https://getcomposer.org/download/) on your local system. Run this in your terminal to get the latest Composer version:
curl -sS https://getcomposer.org/installer | php
Or if you don't have curl:
php -r "readfile('https://getcomposer.org/installer');" | php
<a name="laravel"></a>
## Laravel
We're using Laravel as our PHP framework. You will find all the information you need on the laravel [documentation site](http://laravel.com/docs).
<a name="bower"></a>
## Bower
Bower is used for managing our front end dependencies. Bower can be installed with npm, so make sure you have installed node.

View File

@@ -0,0 +1,40 @@
# Project structure
* [Configuration](#configuration)
* [File structure](#file-structure)
* [Server](#server)
* [Client](#client)
The web interace contains several important concepts and this is the right place where we will explain them briefly.
<a name="configuration"></a>
## Configuration
The web interface can be used to configure the machinery and therefore provides a *settings* page where algorithms, expositors, etc can be configured. The web interface will convert the configuration files into HTML elements, so when adding new algorithms or heuristics, the parameters will be reflected in the web interface automatically. The only thing you need to do is to specify a type to each parameter. You will find an equivalent *view* with the same name in the **app/views/controls** directory.
The webinterface can be used to configure Kerberos with our [**cloud application**](/1.0.0/addons/Cloud). The setup is very easy, you only need to create an account on our cloud application, request a key, and enter it in every webinterface you want to have synced. Once Kerberos is configured with the cloud application, a filewatcher, **Gruntjs**, will push new images to the cloud application immediately.
<a name="file-structure"></a>
## File structure
Laravel has been used as back end framework, so if you aren't familiar with Laravel, check out their [documentation website](http://laravel.com/docs). However we will give a briefly explanation of the most important directories.
<a name="server"></a>
### Server
* **app/config/app.php** - this file contains Kerberos specific parameters; where the configuration files can be found, the user credentials to sign in, etc.
* **app/controllers** - MVC controllers
* **app/repositories** -repositories are injected into the controller.
* **app/api.php** - contains all the URI endpoints for Ajax calls.
* **app/repositories.php** - bind repositories to a specific interface - dependency injection.
* **app/routes.php** - url routing for pages.
<a name="client"></a>
### Client
* **public/css/less** - LESS is used for the CSS.
* **public/js/app** - BackboneJS and RequireJS is used for building modular JS classes.
* **public/js/mustache** - Mustache is used for the client-side view rendering.
* **public/js/vendor** - This is where the bower extensions are installed.
* **public/capture** - A directory where images are written to by default.
* **public/bower.json** - The bower extensions used in the kerberos project.
* **public/Gruntfile.js** - We are using Grunt for our task manager.

View File

@@ -0,0 +1,20 @@
# Introduction
* [The machinery](#the-machinery)
* [How does it work](#how-does-it-work)
* [Installation](#installation)
<a name="the-machinery"></a>
## The machinery
Kerberos.io, the machinery, is a video detection framework, it uses a flexible project structure that can be expanded easily. You can use your favorite **USB webcam** or the new **Raspberry Pi camera module**. The machinery uses OpenCV within its core to create new and powerful functionality, on a efficient way.
<a name="how-does-it-work"></a>
## How does it work?
More information can be found on the [project structure page](/1.0.0/machinery/project_structure).
<a name="installation"></a>
## Installation
The machinery will be installed when deploying the image on your SD card. However you can also compile and link the machinery yourself. Look at the [installation section](/1.0.0/installation) to read more about it.

View File

@@ -0,0 +1,83 @@
# Installation
* [Install from source](#install-from-source)
* [Install on Arch Linux](#install-from-source-on-arch-linux)
* [Auto start](#start-kerberos-on-boot-archlinux)
The machinery is already installed on the Kerberos image, however you can also install the machinery from source.
<a name="install-from-source"></a>
## Install from source
The machinery can be installed standalone.
<a name="install-from-source-on-arch-linux"></a>
### Install on ArchLinux
Update the ArchLinux kernel
pacman -Syyu
Install git, subversion, development tools (c++, cmake) and V4L utils.
pacman -S git subversion cmake base-devel v4l-utils eigen
Go to home directory
cd /home
Get the source code from github
git clone https://github.com/kerberos-io/machinery kerberos-io
Compile kerberos
cd kerberos-io && mkdir build && cd build
cmake .. && make && make check
Add link library to path
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/home/kerberos-io/build/thirdparty/lib/
Give rights to config files
chmod -R 777 ../config
<a name="start-kerberos-on-boot-archlinux"></a>
#### Auto start
Create service file for kerberos
nano /etc/systemd/system/kerberos.service
Copy and paste the configuration to the kerberos.service
[Unit]
Description=Kerberos.io Video Surveillance
[Service]
Type=oneshot
ExecStart=/home/kerberos-io/bin/kerberos
[Install]
WantedBy=multi-user.target
Create timer file for kerberos
nano /etc/systemd/system/kerberos.timer
Copy and paste the configuration to the kerberos.timer
[Unit]
Description=Runs kerberos.service, 1 min after system boot.
[Timer]
OnBootSec=1min
Unit=kerberos.service
[Install]
WantedBy=multi-user.target
Enable the service to start on boot
systemctl enable kerberos.timer

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

View File

@@ -0,0 +1,360 @@
# Contribute
* [Versioning](#versioning)
* [CMake](#cmake)
* [CMake setup](#cmake-setup)
* [Src folder](#src-folder)
* [CMake folder](#cmake-folder)
* [Setup kerberos in your IDE](#setup-kerberos-in-your-ide)
* [OSX](#osx)
* [Create a new XCode project](#create-a-new-xcode-project)
* [Compile source with CMake](#compile-source-with-cmake)
* [Link headers and libraries](#link-headers-and-libraries)
* [Add source to project](#add-source-to-project)
* [Select libraries](#select-libraries)
* [Specifiy header- and library locations](#specify-header-and-library-locations)
* [Linux](#linux)
* [Adding a new class](#adding-a-new-class)
* [Create the header file](#create-the-header-file)
* [Create the source file](#create-the-source-file)
* [Modify the CMakeLists.txt file](#modifile-the-cmakelists-file)
* [Create a new entry in the config file](#create-a-new-entry-in-the-config-file)
* [Compile](#compile)
* [Adding a test](#adding-a-test)
* [Create the test file](#create-the-test-file)
This documents describes how to contribute to the machinery and describes all the technical stuff you will need to know. If you want to contribute you will need to install the source code on your local environment.
<a name="versioning"></a>
## Versioning
The source is managed on [Github](https://github.com/kerberos-io), and thus we are using git as our version control. For simplicity we are using following [branching model](http://nvie.com/posts/a-successful-git-branching-model/). The model includes:
* main branch
* develop branch
* hotfix and release branches
If you are a new developer, fork the development branch and send a pull request.
<a name="cmake"></a>
## CMake
As mentioned before on the *installation* page, the machinery is using CMake. Therefore if you want to compile the source code, you will need to have installed CMake first. When executing the **CMake** command, CMake will create the appropriate makefiles to compile the machinery.
<a name="cmake-setup"></a>
### CMake setup
At the root of the project you will find the main CMakeList.txt file, and this is where everything starts. The root CMake file will include all the other CMake files; which are located in the *src* and *cmake* folder.
<a name="src-folder"></a>
#### Src folder
The *src* folder includes the machinery. You will find a CMakeLists.txt file in the folder and every subfolder. The CMakeLists.txt is reponsible for the directory it belongs to and will contain all the necesarry commands.
<a name="cmake-folder"></a>
#### CMake folder
The *CMake* directory in the root folder, contains the cmakefiles that will download all the dependencies. The CMake files describe where the dependencies are located (Github, SVN, etc.) but also how they need to be build, configured and/or installed.
<a name="setup-kerberos-in-your-ide"></a>
## Setup kerberos in your IDE
<a name="osx"></a>
### OSX
OSX users can use the XCode IDE to contribute to the machinery. The only hard thing will be to setup the XCode configuration files; to indicate where the headers can be found and where the dynamic libraries are located.
<a name="create-a-new-xcode-project"></a>
#### Create a new XCode project
First we will create a new XCode C++ project and checkout the machinery from [Github](https://github.com/kerberos-io).
<a name="compile-source-with-cmake"></a>
#### Compile source with CMake
Once the project has been setup, we will compile the source code with CMake. Open a terminal and go to the root of the project, enter following command.
mkdir build && cd build && cmake .. && make
<a name="link-headers-and-libraries"></a>
#### Link headers and libraries
When the source has been compiled succesfully we will modify the XCode configuration of the machinery. Therefore we will need to do three things: include the header directories, link the libraries and include the source files.
<a name="add-source-to-project"></a>
##### Add source to project
Select all the source files in the **/src** directory, and drag-and-drop them in the *Compile Sources* section.
![Add source](3_add-source.png)
<a name="select-libraries"></a>
##### Select libraries
Select all the libraries in the **/build/thirdparty/lib** directory, and drag-and-drop them in the *Link Binary With Libraries* section.
![Select libraries](3_add-libraries.png)
<a name="specify-header-and-library-locations"></a>
##### Specifiy header- and library locations
Click on the project name and select the *Build Settings* page, search for the keyword **search**.
![Select criteria](3_select-search-criteria.png)
Define the header search paths.
![Select header paths](3_header-paths.png)
Define the library search paths.
![Select header paths](3_library-paths.png)
<a name="linux"></a>
### Linux
The idea is the same as the installation for OSX, so first you will need to checkout the source code and compile it with the one liner below.
mkdir build && cd build && cmake .. && make
For the time being I didn't had the time to find a good IDE for Linux and to experiment with it. So if someone else could complete the documentation for Linux environments that would be great!
<a name="adding-a-new-class"></a>
## Adding a new class
This paragraph will tell you how to create a new condition, algorithm, expositor, io or capture device. For simplicity we will show how to create a new algorithm; the steps are identical if you want to create for example a new capture device; only the directory will differ.
<a name="create-the-header-file"></a>
### Create the header file
First we will need to create a new header file in the *include/kerberos/machinery/algorithm* directory. You can copy an existing algorithm header file, and start from that. You will end up with the following header file:
//
// Class: AnotherAlgorithm
// Description: Another algorithm
// Created: ...
// Author: ...
// Mail: ...
// Website: ...
//
// The copyright to the computer program(s) herein
// is the property of kerberos.io, Belgium.
// The program(s) may be used and/or copied .
//
/////////////////////////////////////////////////////
#ifndef __AnotherAlgorithm_H_INCLUDED__ // if AnotherAlgorithm.h hasn't been included yet...
#define __AnotherAlgorithm_H_INCLUDED__ // #define this so the compiler knows it has been included
#include "machinery/algorithm/Algorithm.h"
namespace kerberos
{
char AnotherAlgorithmName[] = "AnotherAlgorithm";
class AnotherAlgorithm : public AlgorithmCreator<AnotherAlgorithmName, AnotherAlgorithm>
{
private:
Image m_result;
int m_parameter;
public:
AnotherAlgorithm(){}
void setup(const StringMap & settings);
void initialize(ImageVector & images);
Image evaluate(ImageVector & images, JSON & data);
void setParameter(int parameter);
};
}
#endif
When creating a new class you will need to inherit from it corresponding creator, for the algorithm example: AlgorithmCreator. The creator class requires two template parameters. The first one is a unqie name for the class, this name will be used to make some kind of dependency injection possible. We will use the name to setup the configuration files, and to use it to select a specific class. The second parameter is the class itself.
The inheritance of the creator class can be a little bit strange, but it is required and needed to register the class automatically with the factory. When the code gets compiled, the classes will be automatically registered with the factory, and you can create instances of those classes by using the name we've defined in the first template parameter. For example we could create a new instance of our previously created class with the following command.
Algorithm * anotherAlgorithm = Factory<Algorithm>::getInstance()->create("AnotherAlgorithm");
<a name="create-the-source-file"></a>
### Create the source file
Ofcourse we also need to have an implementation file, therefore we need to create a new source file in the *src/kerberos/machinery/algorithm* directory. Just like the previous example, you can copy an existing class and implement the member functions you've declared in the header file. An example would be:
#include "machinery/algorithm/AnotherAlgorithm.h"
namespace kerberos
{
void AnotherAlgorithm::setup(const StringMap & settings)
{
Algorithm::setup(settings);
int parameter = std::atoi(settings.at("algorithms.AnotherAlgorithm.parameter").c_str());
setParameter(parameter);
}
void AnotherAlgorithm::initialize(ImageVector & images)
{
....
}
Image AnotherAlgorithm::evaluate(ImageVector & images, JSON & data)
{
Image evaluation;
... do something ..
return evaluation;
}
void AnotherAlgorithm::setParameter(int parameter)
{
m_parameter = parameter;
}
}
<a name="modifile-the-cmakelists-file"></a>
### Modify the CMakeLists.txt file
Open the CMakeLists.txt in the *src/kerberos* directory file and append the name of the algorithm class to the *KERBEROS_FACTORY_ENTITIES* variable; for example *machinery/algorithm/AnotherAlgorithm.cpp*.
# -------------------------------------------------------
# Entities that have to be registered with the factory
# - classes are registered on compile time, so they
# don't belong to a library. New algorithms, expositors
# or Io classes belong here.
set(KERBEROS_FACTORY_ENTITIES
capture/USBCamera.cpp
machinery/condition/Time.cpp
machinery/condition/Enabled.cpp
machinery/algorithm/DifferentialCollins.cpp
machinery/algorithm/DifferentialCollinsWithColor.cpp
machinery/algorithm/AnotherAlgorithm.cpp
machinery/expositor/RectangleExpositor.cpp
machinery/expositor/HullExpositor.cpp
machinery/heuristic/Sequence.cpp
machinery/io/IoDisk.cpp
machinery/io/IoTCP.cpp
machinery/io/IoMongoDB.cpp
)
<a name="create-a-new-entry-in-the-config-file"></a>
### Create a new entry in the config file
Open the algorithm.xml file in the **config** directory, and add a new tag with exactly the same name you've used in the header file; so in our example "AnotherAlgorithm". Within the new tag we can add properties that we will be use to configure our algorithm, in our example we defined a field **parameter** so we can add this field in the config file.
One thing you will need to do is to attach a **type** to a property. The type will be used by the web interface to automatically render the properties. For simplicity we can use the type number, this will show an input box on the settings page of the web interface where we are able to add numbers.
<algorithms>
<AnotherAlgorithm>
<parameter type="number">5</parameter>
</AnotherAlgorithm>
</algorithms>
You can retrieve the parameter in the **setup** function with the settings parameter.
settings.at("algorithms.AnotherAlgorithm.parameter")
<a name="compile"></a>
### Compile
Hurray, we've made it! So now you can compile the code again, and if you're using an IDE don't forget to include the new source file! However if you are compiling from the commandline you just have to go to the build folder and write **make**.
<a name="adding-a-test"></a>
## Adding a new test
When someone adds a class for a new io device, algorithm or expositor, he/she will need to write some documentation about the class but also need to provide some unit tests. This paragraph will provide you how to write a simple test.
<a name="create-the-test-file"></a>
### Create the test file
Add a new file to the **test/** directory, prefix the file with *test_* e.g. test_condition_enabled.cpp. Include the *gtest* and *gmock* headers; and also the Factory and Type headers. Write a new test condition, this is where the assert will be executed.
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "Factory.h"
#include "Types.h"
using ::testing::AtLeast;
using ::testing::Return;
using namespace kerberos;
// ----------------------------------------
// Enabled condition: allowed function
TEST(ENABLED_CONDITION, ALLOWED)
{
Condition * condition = Factory<Condition>::getInstance()->create("Enabled");
// This is only for mocking
ImageVector images;
StringMap settings;
settings["conditions.Enabled.delay"] = "2000";
// Enable condition
settings["conditions.Enabled.active"] = "true";
condition->setup(settings);
bool canExecute = condition->allowed(images);
EXPECT_EQ(true, canExecute);
// Disable condition
settings["conditions.Enabled.active"] = "false";
condition->setup(settings);
canExecute = condition->allowed(images);
EXPECT_EQ(false, canExecute);
}
### Run tests
To execute the test you can run the **make check** in the **build/** directory. When you've added a new test file, you will need to execute the **cmake** command again.
cd build/
cmake ..
make check
You will get following output
macbook:build cedricverstraeten$ make check
[ 1%] Built target EXECUTOR_LIBRARY
[ 8%] Built target TINYXML_LIBRARY
[ 16%] Built target FILEWATCHER_LIBRARY
[ 29%] Built target opencv
[ 49%] Built target KERBEROS_CORE
[ 62%] Built target googletest
[ 75%] Built target googlemock
[100%] Built target kerberos-test
[==========] Running 6 tests from 5 test cases.
[----------] Global test environment set-up.
[----------] 1 test from ENABLED_CONDITION
[ RUN ] ENABLED_CONDITION.ALLOWED
[ OK ] ENABLED_CONDITION.ALLOWED (2002 ms)
[----------] 1 test from ENABLED_CONDITION (2002 ms total)
[----------] 2 tests from HELPER
[ RUN ] HELPER.T_TO_STRING
[ OK ] HELPER.T_TO_STRING (0 ms)
[ RUN ] HELPER.NORMALIZE_PATH
[ OK ] HELPER.NORMALIZE_PATH (0 ms)
[----------] 2 tests from HELPER (0 ms total)
[----------] 1 test from HULL_EXPOSITOR
[ RUN ] HULL_EXPOSITOR.CALCULATE
[ OK ] HULL_EXPOSITOR.CALCULATE (1 ms)
[----------] 1 test from HULL_EXPOSITOR (1 ms total)
[----------] 1 test from RECTANGLE_EXPOSITOR
[ RUN ] RECTANGLE_EXPOSITOR.CALCULATE
[ OK ] RECTANGLE_EXPOSITOR.CALCULATE (0 ms)
[----------] 1 test from RECTANGLE_EXPOSITOR (0 ms total)
[----------] 1 test from SEQUENCE_HEURISTIC
[ RUN ] SEQUENCE_HEURISTIC.IS_VALID
[ OK ] SEQUENCE_HEURISTIC.IS_VALID (1005 ms)
[----------] 1 test from SEQUENCE_HEURISTIC (1005 ms total)
[----------] Global test environment tear-down
[==========] 6 tests from 5 test cases ran. (3008 ms total)
[ PASSED ] 6 tests.
[100%] Built target check
macbook:build cedricverstraeten$

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View File

@@ -0,0 +1,131 @@
# Project structure
* [Lifecycle](#lifecycle)
* [Capture](#capture)
* [Condition](#condition)
* [Algorithm](#algorithm)
* [Expositor](#expositor)
* [Heuristic](#heuristic)
* [Io](#io)
* [Technical design](#techinal-design)
* [Configuration](#configuration)
* [Filewatcher](#filewatcher)
* [Factory](#factory)
* [Dependencies](#dependencies)
* [Image Processing](#image-processing)
* [RapidJSON](#rapidjson)
* [Testing](#testing)
* [Continous integration](#continous-integration)
* [Unit testing / Mocking](#unit-testing-mocking)
* [File structure](#file-structure)
The machinery contains several important concepts and this is the place where we will tackle them briefly.
<a name="lifecycle"></a>
## Lifecycle
The machinery is a video recognition framework and is devided into four steps:
* condition
* algorithm
* expositor
* heuristic
The steps belong to a four passway; illustrated on the image below. In each cycle a sequence of images is processed. Each step will process the sequence, and will return some result to the next step. For example: an algorithm will process the images and returns an array to the Expositor, which contains boolean values. The steps are **loosly coupled**, so they have **simple conventions**, just like the example before.
Thanks to the loosly coupling, each step can be developed indepently. So algorithms, expositors, heuristics and conditions can be switched on the fly. This makes it easier for other developers who want to contribute to kerberos. They can create a new algorithm without knowing how a specific expositor or heuristic works. They just need to be aware of the convention an algorithm should meet.
![Lifecycle](4_project_structure.png)
<a name="capture"></a>
### Capture
You can choose which capture device you will be using, you can use your old USB webcam or the hi-tech and cheap Raspberry Pi Camera Module. The capture device will take some pictures and deliver them to the algorithm if the conditions (the first step of the four passway) are valid.
<a name="condition"></a>
### Condition
The condition is the first step of the four passway. In this step kerberos will determine if it's allowed to proceed to the next step. For example a condition can be a time constraint, a brightness threshold, etc. Multiple conditions can be selected and configured with the web interface.
<a name="algorithm"></a>
### Algorithm
The algorithm is the second step of the four passway. An algorithm will execute some kind of function on a sequence of images. An example of an algorithm would be one that does motion detection or one that would detect cats or dogs.
<a name="expositor"></a>
### Expositor
After the algorithm is executed, the expositor will determine, a region, where the changes were detected. An expositor can constrain a region in terms of selecting a hull or defining a rectangle.
<a name="heuristic"></a>
### Heuristic
When the expositor detected some kind of region, a heuristic will evaluate, the current and previous detections. The heuristic is basically some kind of memory which makes decision and tells kerberos if the detection was true or false.
<a name="io"></a>
### IO
If the heuristic determined that the detection was valid, one or more IO operations can be executed. For example an image can be saved to disk or an email can be sent.
<a name="technical-design"></a>
## Technical design
Kerberos.io has some technical design concepts, the most important parts are described below.
<a name="configuration"></a>
### Configuration
When the machinery is started, the first thing it will do is reading a configuration file; an XML file. The configuration file contains which algorithm, expositor, or capture device are selected, and the parameters they require. When the configuration is done, the machinery will enter the four passway and start the recognition. The configuration file can be modified on the settings page from the web interface, but could also be modified manually; in the config directory of the machinery.
<a name="filewatcher"></a>
### Filewatcher
When the configuration file is modified, we don't need to restart the machinery ourself. The machinery uses a filewatcher, named **Guard**, that will reconfigure the machinery on the fly without restarting the machinery itself. For example, a user want to change the time constraints, or wants to enlarge the resolution of the captured images.
<a name="factory"></a>
### Factory
The machinery uses the **factory class registration pattern**. Algorithms, expositors, heurstics and conditions are registered to the factory on compilation. Thanks to this mechanism, developers don't have to modify other classes than those they've created. So for example if a developer would add a new algorithm he will just need to create a new header and implementation file, and map a unique name to the class in the implementation file; this behaviour is similar to dependency injection without using reflection; reflection is not available in C++.
<a name="dependencies"></a>
## Dependencies
Kerberos.io has some dependencies, which are installed on the fly, when compiling machinery. We are using the externalproject feature of the cmake autotool to get the different depedencies from their source control (Github, SVN, ..).
<a name="image-processing"></a>
### Image Processing
Kerberos.io is a video recognition framework and is therefore using a image processing library; OpenCV (Open Source Computer Vision). Thanks to this very powerful computer vision framework, developers can benefit from it and increase development time.
<a name="rapidjson"></a>
### Rapidjson
The machinery is using the rapidjson library to provide a flexible datastructure: JSON. The library is used within the core of kerberos, and is concerned within every step of the four pass way; except in the first step the condition, to be 100% correct.
<a name="testing"></a>
## Testing
<a name="continous-integration"></a>
### Continous integration
The machinery is deployed automatically on **travis-ci**, when a new commit/release is pushed.
<a name="unit-testing-mocking"></a>
### Unit testing / Mocking
We strongly recommend testing as a best practice in complex projects. Therefore the machinery uses the popular c++ test library: Google Test and Google Mock. The test can be found in the **test** directory. You can run the test by executing following command:
make check
<a name="file-structure"></a>
## File structure
* **bin** - contains the kerberos compiled and linked executable.
* **build** - contains all the compiled dependencies and source code.
* **cmake** - information about how to compile kerberos, and were to find the dependencies.
* **config** - configuration files that are used to configure kerberos.
* **exceptions** - custom exceptions.
* **include** - kerberos header files.
* **logs** - log file, kerberos exceptions are written to.
* **src** - kerberos source files.
* **test** - google tests

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -0,0 +1,16 @@
# Capture
* [USB camera](#usb-camera)
* [Raspberry Pi Camera Module](#raspberry-pi-camera-module)
The capture device is responsible to take images. The images are used in the four pass way.
<a name="usb-camera"></a>
## USB camera
Kerberos supports a whole range of USB cameras. You will find a complete list [here](https://web.archive.org/web/20120815172655/http://opencv.willowgarage.com/wiki/Welcome/OS/). Make sure that you've updated the settings page on the web interface, that you will be using an USB camera.
<a name="raspberry-pi-camera-module"></a>
## Raspberry Pi Camera Module
You can use the Raspberry Pi Camera Module with Kerberos, you just need to attach the camera module and you are ready to go. The Raspberry Pi Camera Module is enabled by default in the web interface. Please note that if you didn't installed Kerberos with the image, you will need to [enable the camera module](/1.0.0/FAQ#how-to-enable-camera-module) yourself.

View File

@@ -0,0 +1,16 @@
# Condition
* [Time](#time)
* [Enabled](#enabled)
The condition is the first step of Kerberos. A condition is, like the word states, a conditional statement. One or more conditions can be selected (a sequence of conditions), that have to be valid. When the sequence of conditions is valid, Kerberos will go to the next step of the four passway, the algorithm. When one of the conditions in the sequence fail, Kerberos will idle for a specific time according the condition that failed.
<a name="time"></a>
## Time
A user can set a time range for each day of the week. The condition is valid if the current time is within the time range, for that specific day.
<a name="enabled"></a>
## Enabled
A user can select a checkbox to enable Kerberos.

View File

@@ -0,0 +1,24 @@
# USB Camera
Kerberos supports a whole range of USB cameras. You will find a complete list [here](https://web.archive.org/web/20120815172655/http://opencv.willowgarage.com/wiki/Welcome/OS/). Make sure you have updated the web interface, to make Kerberos aware you will be using an USB camera. [Be carefull](http://raspberrypi.stackexchange.com/questions/340/how-much-power-can-be-provided-through-usb) that you don't attach USB devices that require more than 100mA.
## Web interface
![USB camera](1_usb-camera.png)
## Parameters
The parameters of the USB capture device can be found in the *config/capture.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<captures>
<USBCamera>
<frameWidth type="number">1280</frameWidth>
<frameHeight type="number">720</frameHeight>
</USBCamera>
</captures>
### Framewidth and -height
You can set the resolution of the capture device, make sure the resolution you've defined is valid with your camera. Please check the specs of the USB camera you're using.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,32 @@
# USB Camera
You can use the Raspberry Pi Camera Module with Kerberos. You just need to attach the camera module and you're ready to go. The Raspberry Pi Camera Module is enabled by default in the web interface.
## Web interface
![Raspberry PI Camera Module](2_raspi-camera.png)
## Parameters
The parameters of the Raspberry Pi Camera Module can be found in the *config/capture.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<captures>
<RaspiCamera>
<frameWidth type="number">800</frameWidth>
<frameHeight type="number">640</frameHeight>
<night type="number">60</night>
<day type="number">150</day>
</RaspiCamera>
</captures>
### Framewidth and -height
You can set the resolution of the camera module, make sure the resolution you've defined is valid.
### Night and day
The Raspberry Pi Camera module has additional parameters. Thanks to the MMAL library we can change the configuration of the Raspberry Pi Camera Module. The night and day parameters are gray thresholds. The night parameter defines the lower gray value/threshold; if the brightness of the image taken by the camera module will be lower than the night value, it will switch to night mode. Similar, if the brightness is higher than the day value, it will switch to day mode.
Notice that there is a kind of gray zone. If the brightness of the image is within those range, no reconfiguration will happen. This feature will be more advanced in future.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,16 @@
# Algorithm
* [Differential Images](#differential-images)
The algorithm is the second step of the four passway. An algorithm will execute some kind of function on a sequence of images and end up with a black and white image; just like the image below.
The white pixels on the image will indicate the object of interest. For example, when looking for motion, the pixels that have been changed; it depends on what the algorithm is looking for. The black pixels are background pixels.
![Black and white image](7_black-and-white-image.png)
The only convention that an algorithm should meet is that it should return a black and white image to the next step; the expositor. And of course that it requires a sequence of images as a parameter. Besides those conventions, an algorithm can do everything it wants to do. So you could create your own cat detection algorithm, marker detection, etc.
<a name="differential-images"></a>
## Differential Images
This is a trivial **motion detection algorithm**. Three images are compared, and the pixels that have been changed are marked as white pixels, pixels that are black are background images.

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,29 @@
# Time
It can be helpful to enable or disable Kerberos at specific times. Therefore the time condition makes it possible to select a time range for each day of the week. When the current time is within the time range, Kerberos will be enabled.
## Web interface
![Time condition](1_time-condition.png)
## Parameters
The parameters of the Time condition can be found in the *config/condition.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<conditions>
<Time>
<times type="timeselection">13:00,15:00-0:01,20:58-0:01,20:59-0:01,19:20-0:01,21:59-0,0-0,0</times>
<delay type="number">10000</delay>
</Time>
</conditions>
### Times
The times property contains a list of times, delimited by a "-". The first item in the list will specify the time range for the first day of the week (Monday), the last item for the last day of the week (Sunday). The begin- and end-time, for a specific day, are delimited by a "," where the first element will specify that start time and the second one specifies the end time.
### Delay
The delay value is used when the condition failed, so when the current time isn't in the selected time range for that day. In that case Kerberos will idle for the specified delay time. The value of the delay is expressed in miliseconds.

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -0,0 +1,30 @@
# Enabled
This condition makes it possible to disable/enable Kerberos, with a simple true/false parameter. This is helpful when you're expecting a lot of activity, and you don't want Kerberos to trigger all those events.
## Web interface
![Enabled condition](2_enabled-condition.png)
## Parameters
The parameters of the Time condition can be found in the *config/condition.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<conditions>
<Enabled>
<active type="bool">true</active>
<delay type="number">5000</delay>
</Enabled>
</conditions>
### Active
The active field is boolean value (true/false). When the active field is true, Kerberos is enabled, if not kerberos is disabled.
### Delay
The delay value is used when the condition failed, so when enabled is set to false. In that case Kerberos will idle for the specfied delay time. The value of the delay is expressed in miliseconds.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -0,0 +1,44 @@
# Differential images
This algorithm is **a very simple method to detect motion**; in terms of *understanding* but also *processing*. Just like the name says, it's the result of comparing images. When the images are compared, we know the pixels that have been changed and if the amount of pixels that changed is big enough, one can say that something happened and thus motion was detected.
To get a more technical explanation: the algoritm will substract 2 or more images, and once that is done it will end up with a black and white image. The white pixels will mark the pixels that where different/changed and the black pixels are the pixels that have not changed; background pixels. Please note that there are several different combinations of substracting images. However for the kerberos.io project, we will use the method of *Collins et al.* as this method erases the phenomenon "ghosting".
![Differential images](1_differential_images.png)
In the image above the method of *Collins et al.* is illustrated. For this method we will process three images. The images are a sequence (from left to right), so the first (A) image was taken before the second (B) one, and the second (B) before the third (C) one. Next we will do a first comparision (C-B) of the third (C) image and the second (B) image, and after that we will do a second comparison (C-A) of the third (C) image and first (A) image.
After the comparison we will end up with two difference images (C-B) and (C-A); both will mark the white pixels as changed pixels and black as non-changed pixels. To finish the algorithm we will do a logical AND-operation of the two difference images; this will give us the final black and white image ((C-B)&&(C-A)).
The main idea of the Colins et al. method, is that it will erase "ghosting". In the last step we are doing a logical AND-operation, by doing this we will only keep the pixels, that changed in the first two images; therefore we can elimante false positives.
A more detailed explanation can be found [here](http://blog.cedric.ws/opencv-simple-motion-detection).
## Web interface
![Differential algoritmh](1_differential-images.png)
## Parameters
The parameters of the Differential image algorithm can be found in the *config/algorithm.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<algorithms>
<DifferentialCollins>
<erode type="number">5</erode>
<threshold type="number">20</threshold>
</DifferentialCollins>
</algorithms>
### Erode
The erode parameter represents a structural element (a morphological operation), which will be used to minimize the changed pixels; more information about eroding can be found [here](http://docs.opencv.org/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.html). The idea of the eroding is that pixels which are isolated will be removed; this means that when only one pixel changed, that pixel will reverted to the non-changed state. But for example when a large change happens and a lot of adjacent pixels are changed, the eroding will not be able to revert them.
The higher the number of the erode parameter, the more aggressive the eroding will be. So high erode values, will make it possible that also large changes will be reverted to the non-changed state.
### Threshold
When doing the comparison of two images, we won't end up with a clean black and white image. In most of the cases the values will be between 0 and 255; so gray values. This means that the value **0** will mean that both pixels where the same in both image, and values **255** mean that both pixels where totally different in both images. Of course we will also have values between 0-255, so pixels that are a little bit different in both images. So to make the resulting black and white image, we will need to apply a threshold value.
The threshold will specify how much a pixel has to be different in the two images. So for example when the threshold is 30, it means that the difference between two pixels has to be equal or more then 30. The higher the threshold the more the pixel needs to be different, to be marked as changed.

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,29 @@
# Rectangle
This rectangle is a trivial expositor. A rectangle region can be defined to constrain the locations of pixels of interest; for example if you only want to have detection at your front door. The rectangle repositor will return the bounding rectangle of the pixels of interest.
## Web interface
![Rectangle expositor](1_rectangle-expositor.png)
## Parameters
The parameters of the rectangle expositor can be found in the *config/expositor.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<expositors>
<Rectangle>
<region>
<x1 type="number">0</x1>
<y1 type="number">0</y1>
<x2 type="number">1280</x2>
<y2 type="number">720</y2>
</region>
</Rectangle>
</expositors>
### Region
The region parameter contains 4 values; x1, y1, x2 and y2 respectively. The values x1 and y1 indicate the x- and y-coordinate of the left upper starting point. The values x2 and y2 are the bottom right coordinates. A virtual rectangle will be drawn from (x1,y1) to (x2,y2). Pixels of interest that lie within this rectangle are valid pixels; if not they are invalid.

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

View File

@@ -0,0 +1,24 @@
# Hull
This hull is a more complex expositor than the rectangle. A hull can be selected with the web interface, you can select one or more coordinates to create a flexible region. The coordinates can be adjusted afterwards and be removed by double clicking on the coordinate. You can expand the hull by removing the start coordinate, which is marked by the white bullet.
## Web interface
![Hull expositor](2_hull-expositor.png)
## Parameters
The parameters of the hull expositor can be found in the *config/expositor.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<expositors>
<Hull>
<region type="hullselection">347,361|627,266|975,328|1091,328|1148,413|1158,516|1121,534|962,567|699,648|531,700|243,613|423,550|665,453|850,470|666,361|467,385|325,460|165,372</region>
</Hull>
</expositors>
### Region
The region parameter contains n values. Each value represents a coordinate (x,y) and are seperated by the "|" delimiter. These coordinates are used to calculate the concave hull. Pixels of interest that lie within the concave hull are valid pixels; if not they are invalid.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,34 @@
# Sequence
This is a trivial heuristic. The sequence heuristic will store a single integer in memory, that will count the numbers of valid detections. When the heuristic will detect a false detection, it will decrease the count. The sequence heuristic will return true, if a threshold is reached; for example when something was detected three times in a row.
## Web interface
![Sequence heuristic](1_sequence-heuristic.png)
## Parameters
The parameters of the Sequence heuristic can be found in the *config/heuristic.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<heuristics>
<Sequence>
<minimumChanges type="number">1</minimumChanges>
<minimumDuration type="number">1</minimumDuration>
<noMotionDelayTime type="number">2000</noMotionDelayTime>
</Sequence>
</heuristics>
### Minimum changes
The heuristic will only return true if enough changes have been detected. The minimum of changes indicates the minimum number of pixels that have to been changed, to be a valid detection.
### Minimum durations
The minimum number of detections in a row to be a valid detection.
### No motion delay time
When the heuristic failed, due to not enough pixels changed or not x detections in a row, the heuristic will idle for some time.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,28 @@
# Disk
An image can be saved to disk.
## Web interface
![Disk io](1_disk-io.png)
## Parameters
The parameters of the Disk output device can be found in the **config/io**.xml file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<ios>
<Disk>
<fileFormat type="text">timestamp_microseconds_instanceName_regionCoordinates_numberOfChanges_token.jpg</fileFormat>
<directory type="directory">/home/kerberos-web/public/capture>
</Disk>
</ios>
### File format
The format that will be used for the name of the image. One or more variables can be defined and will be replaced by the machinery. Note that when you're using a variables name in the file format, that this name should be defined in the JSON object.
### Directory
The directory where the image will be saved to.

View File

@@ -0,0 +1,37 @@
# TCP/IP client
The TCP/IP client will send a TCP package to a server.
## Web interface
![TCP socket io](2_tcp-io.png)
## Parameters
The parameters of the TCP/IP client can be found in the config/io.xml file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<ios>
<TCPSocket>
<server type="number">127.0.0.1</server>
<port type="number">1337</port>
<message type="text">it's so fluffy</message>
</TCPSocket>
</ios>
### Server
The ip of the TCP server.
### Port
This is the port of the TCP server.
### Message
You can send some data to a TCP server.
## Examples
More information can be found [here](/1.0.0/addons/TCP_listener).

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,33 @@
# GPIO
A GPIO pin can be set as output device.
## Web interface
![GPIO io](3_gpio-io.png)
## Parameters
The parameters of the GPIO pin can be found in the config/io.xml file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<ios>
<GPIO>
<pin type="number">17</pin>
<periods type="number">5</periods>
<periodTime type="number">100000</periodTime>
</GPIO>
</ios>
### Pin
The pin that will be triggered.
### Periods
The number of times the pin will be triggered.
### Period time
The time in microseconds that the pin will be set *high*.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 KiB

View File

@@ -0,0 +1,20 @@
# Expositor
* [Rectangle](#rectangle)
* [Hull](#hull)
After the algorithm is executed, the expositor will determine, a region, where the changes are located. Just like the algorithm, the expositor has some simple conventions.
An expositor receives a black and white image as parameter and should modify a JSON object with all the information it processed. The JSON object **must include**: the bounding rectangle(s) of the positions where the pixels of interest are located and the number of pixels of interest. But can also include other optional parameters.
<a name="rectangle"></a>
## Rectangle
This is a trivial expositor. A rectangle region can be defined to constrain the locations of pixels of interest. The rectangle repositor will return the region of the pixels of interest.
<a name="hull"></a>
## Hull
A hull region can be defined to constrain the locations of pixels of interest. This is a more advanced expositor, which can be configured by using the web interface. The hull repositor will return the region of the pixels of interest.
![Expositor select hull](8_expositor-select-hull.png)

View File

@@ -0,0 +1,13 @@
# Heuristic
* [Sequence](#sequence)
When the expositor detected one or more regions, a heuristic will evaluate, the current and previous evaluations. This step is less loosly coupled as the connection between algorithms and expositors, because it can require specific parameters from the expositor or algorithm.
However, the main convention is that an expositor would always modify a JSON object with minimal information; as explained above, one or more regions and the number of pixels of interest. For flexibility, one can choose to add additional parameters or remove (required) parameters. Therefore it is possible that some expositors can't be used with some heuristics; we strongly disrecommend this feature.
To keep things simple: a heuristic is some kind of memory which makes decision and tells Kerberos if the evaluation was true or false.
<a name="sequence"></a>
## Sequence
This is a trivial heuristic. The sequence heuristic returns true if the recognition was positive for x times in a row.

View File

@@ -0,0 +1,19 @@
# Output
* [Image](#image)
* [GPIO](#gpio)
* [TCP/IP client](#tcp-ip-client)
If the heuristic determined that the evaluation was valid, one or more IO operations can be executed. You configure which IO operations that will be executed, by modifying the configuration file or using the web interface.
<a name="image"></a>
## Image
This will save an image to disk. The directory where the images will be saved to, can be set in the configuration file or by using the webinterface.
<a name="gpio"></a>
## GPIO
You can trigger a specific GPIO pin on the Raspberry Pi.
<a name="tcp-ip-client"></a>
## TCP/IP client
The TCP/IP client will send a TCP packet to a server.

View File

@@ -0,0 +1,107 @@
# TCP Listener
One of the addons you can use in combination with Kerberos is a TCP Listener. The TCP listener can execute a specific action when it received a TCP packet from Kerberos (TCP Client).
## Examples
### Text-To-Speech
You can use node to build a simple TCP server, this is a lot easier than if we would have to do it in C; but ofcourse that's also possible. A cool feature would be to use the **say.js** library. You can use say.js on OSX/Linux to execute speech to text. So you could send a message from the Kerberos instance to the node TCP server, and on receiving the message you could make your TCP server speak.
For example you can configure the Kerberos TCP client with a message "There's someone at the frontdoor". When Kerberos detects something it will execute the TCP client and send a TCP packet - which includes the message - to the predefined IP address of the TCP server, afterwards the TCP server will use the say.js library to actually say the message.
<iframe src="//player.vimeo.com/video/122785370?autoplay=0&color=943633" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="width:100%; height: 400px;"></iframe>
You could place another Raspberry Pi in your living room, which would run a TCP server with node and with some speakers attached; see the configuration below. But you can also use your local working station, like I've did in the video above.
cd /home && mkdir tcp-client && cd tcp-client
Install the festival library and voice package
pacman -S festival festival-english
pacman -S alsa-utils
Update the festival.scm file, add following lines at the end of the file */usr/share/festival/festival.scm*.
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")
Don't forget to install say and time first.
npm install say date-utils
Create a new node file
nano kerberos-listener.js
and copy-paste the code below
// Import libraries
var net = require('net');
var say = require('say');
require('date-utils');
// Variables
var listenerPort = 1337;
var time1 = new Date();
net.createServer(function (socket)
{
// Handle incoming messages from the magnet controller.
socket.once('data', function (data)
{
var time2 = new Date();
var timeBetween = time1.getSecondsBetween(time2);
if(timeBetween > 30)
{
say.speak('Victoria', data);
}
time1 = time2;
});
}).listen(listenerPort);
// Put a friendly message on the terminal of the server.
console.log("Kerberos.io listener running at port 1337\n");
### Auto-start tcp listener
Create a new service file.
nano /etc/systemd/system/kerberos-listener.service
Copy and paste following configuration in the service file.
[Unit]
Description=Kerberos listen for tcp packets
[Service]
Type=oneshot
ExecStart=/usr/bin/node /home/tcp-client/kerberos-listener.js &
[Install]
WantedBy=multi-user.target
Activate the service file.
systemctl enable kerberos-listener.service
### Pushbullet notifications
You can expand the Text-To-Speech feature (described above), with pushbullet notifications. Pushbullet is a free notifcation service, which you can use to send messages to your devices; smartphone, tablet, and/or workingstation. You can download the pushbullet node library with **npm**, and use it in the TCP listener.
npm install pushbullet
When the library is installed correctly, you can use following code in the TCP listener.
var PushBullet = require('pushbullet');
var pusher = new PushBullet('your key');
pusher.devices(function(error, response)
{
var devices = response.devices;
devices.forEach(function(device)
{
pusher.note(device.device_iden, "Kerberos.io: " + data.toString(), data.toString());
});
});

View File

@@ -0,0 +1,60 @@
# Cloud
Once Kerberos is installed on the Raspberry Pi, the machinery and webinterface are available. A user can browse to the IP address (e.g. http://192.168.0.13) of the Raspberry Pi to configure the machinery and view the events that were taken by the machinery. To browse to the Raspberry Pi, a user has to be in the same internal network as where the Raspberry Pi is located; otherwise the webpage wouldn't be accessible. To make the Raspberry Pi accessible for the public, you will need to do some additional configurations on your router.
Another solution would be to use the cloud service that Kerberos is offering; A user pays a monthly fee to use the Kerberos cloud service. The events that are triggered by the machinery will be sent to our service, and are accessible by using the Kerberos cloud application. You can attach multiple Kerberos instances to the cloud service with only one license.
## Video
<iframe src="https://player.vimeo.com/video/121532472?autoplay=0&color=943633#t=13m32s" style="width:100%; height: 400px;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
## How it works?
Kerberos is using AWS S3 to store their images. When the machinery detected something, it will save an image to disk, and maybe trigger some other IO devices. In its turn the filewatcher, Grunt, will pick up those new files and push them to the appropriate S3 bucket, by using your credentials; the credentials you've received from the cloud application, have only permissions to write and list objects to/from your bucket.
When the file (image) is stored in the bucket, AWS Lambda will do some validation and post processing. Lambda will check if the file is realy an image, if the size is not to big, and do some post processing like facerecognition. If the image is valid, the image will be copied to our production bucket, and additional information is stored in dynamoDB.
The cloud application is attached to the production bucket, so only images that are verified will show up in the cloud application. When a user accesses the cloud application, the images from the production bucket are listed. Images that are loaded in the browser will be signed, for a specific time, before they are actually rendered. The signing will expire after 100 seconds.
## Install from source
If you installed Kerberos from the image, you don't need to follow this tutorial as the service is installed natively.
cd /home
Create a new directory
mkdir cloud && cd cloud
Checkout sync repository
git clone https://github.com/kerberos-io/sync-s3 .
Install node plugins
npm install
npm install -g grunt-cli
## Auto-start grunt
Create service file for cloud
nano /etc/systemd/system/cloud.service
Copy and paste the configuration to the cloud.service
[Unit]
Description=Sync kerberos.io events
[Service]
Type=oneshot
ExecStart= /usr/bin/grunt --gruntfile /home/cloud/Gruntfile.js sync --force &
[Install]
WantedBy=multi-user.target
Enable the service to start on boot
systemctl enable cloud.service

18
1.0.0/4_release_notes.md Normal file
View File

@@ -0,0 +1,18 @@
# Release notes
* [1.0.0](#1-0-0)
<a name="1-0-0"></a>
## 1.0.0
First commit of Kerberos.io
#### New
* Camera support: **USBCamera** (V4L), **Raspberry Pi camera module** (MMAL).
* Conditions: **Enabled** (turn on/off Kerberos) and active **Time** per day.
* Algorithms: **Differential Images**.
* Heuristics: **Sequence**.
* Expositors: Select a **Hull** or **Rectangle**.
* Outputs: Write image to **Disk**, trigger an **GPIO** output pin and send a **TCP/IP packet**.
* Cloud: send your images to the **Kerberos.io cloud aplication**.

229
1.0.0/5_FAQ.md Normal file
View File

@@ -0,0 +1,229 @@
# FAQ
The FAQ, Frequently Asked Questions, page contains **technical solutions** for common problems concerning the installation of Kerberos. This page does **NOT** contain non-technical questions and answers; The Raspberry Pi doesn't turn on, I don't have WIFI access, etc. Therefore you can access our [**knowledge base**](https://kerberosio.zendesk.com).
* [How to expand SD card root partition](#expand-sd-card)
* [Arch Linux](#expand-sd-card-archlinux)
* [How to backup SD card](#backup-sd-card)
* [How to setup WIFI connection on Raspberry Pi](#setup-wifi)
* [How to enable Raspberry Pi Camera Module](#how-to-enable-camera-module)
* [Arch Linux](#how-to-enable-camera-module-archlinux)
<a name="expand-sd-card"></a>
## How to expand SD card root partition
<a name="expand-sd-card-archlinux"></a>
### Arch Linux
After logging in you view the status of filesystem (the output can be different):
[root@alarmpi build]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.7G 1.6G 0 100% /
devtmpfs 214M 0 214M 0% /dev
tmpfs 218M 0 218M 0% /dev/shm
tmpfs 218M 312K 218M 1% /run
tmpfs 218M 0 218M 0% /sys/fs/cgroup
tmpfs 218M 0 218M 0% /tmp
/dev/mmcblk0p1 90M 27M 64M 30% /boot
tmpfs 44M 0 44M 0% /run/user/0
Using the command fdisk will edit the filesystem /dev/mmcblk0:
[root@alarmpi ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.23.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):
List the information and delete partition 2:
Command (m for help): p
Disk /dev/mmcblk0: 7.2 GiB, 7746879488 bytes, 15130624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x417ee54b
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 186367 184320 90M c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 3667967 3481600 1.7G 5 Extended
/dev/mmcblk0p5 188416 3667967 3479552 1.7G 83 Linux
Command (m for help): d
Partition number (1,2,5, default 5): 5
Partition 5 has been deleted.
Command (m for help):
Command (m for help): d
Partition number (1,2,5, default 5): 2
Partition 2 has been deleted.
Command (m for help):
Create a new extended partition a logical volume:
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (2-4, default 2): 2
First sector (186368-15564799, default 186368): (press enter)
Using default value 186368
Last sector, +sectors or +size(186368 - 15564799, default 15564799): (press enter)
Using default value 15564799
Partition 2 of type Extended and of size 7.3 GiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (188416-15564799, default 188416):
Using default value 188416
Last sector, +sectors or +(188416-15564799, default 15564799):
Using default value 15564799
Partition 5 of type Linux and of size 7.3 GiB is set
Check whether top block starts in the same place as the original (start)
Command (m for help): p
Disk /dev/mmcblk0: 7969 MB, 7969177600 bytes, 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00057540
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 15564799 7689216 5 Extended
/dev/mmcblk0p5 188416 15564799 7688192 83 Linux
Command (m for help):
If it starts again (in this case on 186368 p2 a 188416 p5) write changes and reboot.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@alarmpi ~]# reboot
After booting the system we online enlarge root partitions
[root@alarmpi ~]# resize2fs /dev/mmcblk0p5
resize2fs 1.42.8 (20-Jun-2013)
Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p5 is now 1922048 blocks long.
Check and it is done :-)
[root@alarmpi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.3G 447M 6.5G 7% /
devtmpfs 83M 0 83M 0% /dev
tmpfs 231M 0 231M 0% /dev/shm
tmpfs 231M 236K 231M 1% /run
tmpfs 231M 0 231M 0% /sys/fs/cgroup
tmpfs 231M 0 231M 0% /tmp
/dev/mmcblk0p1 90M 24M 67M 27% /boot
<a name="backup-sd-card"></a>
## How to backup SD card
You can backup your SD card, by typing following command in your terminal. This can be helpful, if you want to restore it later; for example when your SD card is broken.
sudo dd if=/dev/disk2 of=~/Desktop/kerberos-io.img bs=1m
<a name="setup-wifi"></a>
## How to setup WIFI connection
### Installed Kerberos.io from image
When kerberos is installed with the image, you can edit the wireless.conf file on the SD card. Insert the SD card in your workstation and open the file **/boot/wireless.conf**. You will see a similar config like below, edit the ESSID property with the name of your WIFI connection and the property Key with the WIFI password.
Description='A simple WPA encrypted wireless connection'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID='network-name'
Key='plain-text-password'
IP=static
Address='192.168.0.x/24'
Gateway='192.168.0.1'
DNS=('192.168.0.1')
# Uncomment this if your ssid is hidden
#Hidden=yes
### Installed Kerberos.io from source
#### Archlinux
We will use the netctl tool for this. First copy the wireless-wpa example from the examples directory to the boot directory.
cp /etc/netctl/examples/wireless-wpa /boot/wireless.conf
Make a symbol link to the netctl homedirectory and activate the netctl profile, so the WIFI connection will be made on boot up.
ln -s /boot/wireless.conf /etc/netctl/wlan
systemctl enable netctl-auto @wlan0.service
Edit the **/boot/wireless.conf** file with your WIFI credentials, please note that moving the wireless.conf to the /boot directory also makes us possible to change the credentials directly from the SD card itself. So you don't need to turn on the Raspberry Pi if you want to change the credentials.
The last step is to disable power management: edit the config file,
nano /etc/modprobe.d/8192cu.conf
and copy-paste the line below.
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
Arch Linux shows strange behaviour when enabling WLAN. For some reason, cron will be triggered every minute and will consume a lot of CPU power. This problem has something to do with the timeserver ntpd. A simple fix to avoid this issue is to install the fake hardware clock. First you will need to install fake-hwclock.
pacman -S fake-hwclock
Enable fake-hwclock on startup.
systemctl enable fake-hwclock fake-hwclock-save.timer
systemctl start fake-hwclock
Install timeserver client
pacman -S ntp
Enable ntp on startup
systemctl enable ntpd.service
<a name="how-to-enable-camera-module"></a>
## How to enable Raspberry Pi Camera Module
<a name="how-to-enable-camera-module-archlinux"></a>
### Arch Linux
To enable the camera module, you will need to add these lines to your /boot/config.txt. Note that this is already done when you've installed Kerberos by transferring image.
gpu_mem=128
start_file=start_x.elf
fixup_file=fixup_x.dat
disable_camera_led=1

21
1.0.0/6_license.md Normal file
View File

@@ -0,0 +1,21 @@
# The MIT License
Copyright (c) 2014-2015 Kerberos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

47
README.md Executable file
View File

@@ -0,0 +1,47 @@
#KERBEROS.IO - documentation
This repository contains all the documentation that is displayed on the [documentation website](http://kerberos.io/docs). The documentation is written in [markdown](http://markdowntutorial.com/) The documentation includes information about: how kerberos works, how to install it and also some technical information for developers who are willing to contribute; for example how to add a new algorithm or a new output device.
## Folder structure
Changes are added to the **development** branch first, and will be added to the **master** branch if stable. The document folder structure looks like this:
* branch1
* document
* document
* ...
* document
* folder
* document
* folder
* document
* ...
* document
* folder
* ...
* folder
* ...
* folder
* branch 2
* ...
* branch n
Directories and documents can start with a number, followed by an underscore, to order the documents; for example *1\_documentation* and *2\_more\_documentation*. Please note that documents always come first, and thus directories second. Thus directories and documents are sorted separately; just like the folder structure above.
## Contribute
Writing documentation is required if you send a pull-request. No code, how excellent it may be, will be merged without documentation or tests. This will give the other contributors a better understandig of how your code works and what its purpose is.
## How to write documentation
To create uniform documentation some guidelines are introduced:
* a document starts with a title.
* the title is followed by a listing of the subsections on the page.
* images start with a prefix similar to the document they belong to; for example: document "1_c" has two images *"1\_c\_this\_is \_an\_image"* and *"1\_c\_unicorn"*.
* images belong to the same directory as the document they belong to.
* documentation for new algorithms, expositors, heuristics, etc will be using following template.
* Global description of the class
* Web interface (image)
* Parameters (xml + description of each parameter)

34
dev/1_getting_started.md Normal file
View File

@@ -0,0 +1,34 @@
# Getting started
* [What is Kerberos.io](#what-is-kerberos-io)
* [How does it work](#how-does-it-work)
* [Installation](#installation)
* [Contribute](#contribute)
## Let's get started
In the video below you get a quick overview of how Kerberos works and how you can configure it. The video isn't technical but explains the different features Kerberos offers you.
<iframe src="https://player.vimeo.com/video/121532472?autoplay=0&color=943633" style="width:100%; height: 400px;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<a name="what-is-kerberos-io"></a>
## What's Kerberos.io?
Kerberos is a low-budget surveillance solution created for the **Rapsberry Pi**. Kerberos is open source, so you and others, can customize the source code to your needs and share it. It has a *low-energy* footprint when deploying on the Raspberry Pi and it's *easy to install*, you only need to transfer the image to your SD card and you're done.
Use your mobile phone, tablet or PC to keep an eye on your property. View the activity with our *responsive* and *user-friendly* web interface. Look at the dashboard to get a graphical overview of the past days. *Multiple* Kerberos *instances* can be installed and can be viewed with [only one web interface](/dev/addons/Cloud).
<a name="how-does-it-work"></a>
## How does it work?
Kerberos is devided into two parts: the **machinery** (Back end, C++) and the **webinterface** (Front end, PHP). The machinery is responsible for the image processing and the webinterface is used to configure the machinery and to view the events that were detected by the machinery. Both parts are installed on the device, in most cases the Raspberry Pi. The machinery can trigger multiple output devices when an event occurred; it can trigger a GPIO pin, save an image to disk or send a TCP packet.
<a name="installation"></a>
## Installation
Kerberos is **easy to install**, you just have to copy the kerberos image to your SD card, plug it into your Raspberry Pi and that's it. Kerberos can be installed on other devices than the Raspberry Pi; for development or production. Therefore you will need to compile the machinery yourself and install the webinterface with your favorite webserver; nginx, apache, etc.
<a name="contribute"></a>
## Contribute
Want to contribute? You're a front end designer, user experience guru, an ambitious programmer, or a Ph.D. in Computer Vision who wants to take kerberos.io to the next level? Then we like to welcome you to the community. Contributions are taken very seriously, besides your code, testing and documentation are very important!

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
dev/2_raspberry-pi-a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

29
dev/2_requirements.md Normal file
View File

@@ -0,0 +1,29 @@
# Requirements
* [Which hardware do I need?](#which-hardware-do-i-need)
<a name="which-hardware-do-i-need"></a>
## Which hardware do I need?
Kerberos.io is created for the **Rapsberry Pi**. So it is obvious you will need a Raspberry Pi before you can start using Kerberos. However you can also use Kerberos.io on your local environment, but of course that is not the main goal of Kerberos.
You can select which Raspberry Pi model you need: **Raspberry Pi Model A, A+, B, B+ or Raspberry Pi 2**.
![Raspberry Pi Model A](2_raspberry-pi-a.png)
You need a **4GB or bigger SD card**, on which you will have to deploy the Kerberos.io image; look at the installation page for more information about the deployment.
![4GB SD card](2_sandisk_4gb_sd_card.png)
A **micro USB 5V** charger.
![Micro USB 5V charger](2_micro-usb-5V-charger.png)
A **USB camera** or the **Raspberry Pi camera** module.
![Raspberry Pi Camera Module](2_raspberry-camera-module.png)
*(Optional)* We can use a **WIFI dongle** instead of an ethernet cable, but this is not required. We recommend the **Edimax** ew-7811un WIFI dongle.
![Edimax WIFI dongle](2_edimax-wifi-dongle.png)
*(Optional)* The **Scorpi B+**, a flexible Mount for the Raspberry Pi Camera Board.

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
dev/2_scorpi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

101
dev/3_installation.md Normal file
View File

@@ -0,0 +1,101 @@
# Installation
* [Install from image](#install-from-image)
* [Download the image](#download-the-image)
* [Insert your SD card](#insert-your-sd-card)
* [OSX: transfer image](#osx-transfer-image)
* [Windows: transfer image](#windows-transfer-image)
* [OSX/Linux: transfer image with terminal](#transfer-image-with-terminal)
* [(Optional) Setup WIFI connection](#setup-wifi-connection)
* [Install from source](#install-from-source)
Kerberos is **easy to install**, you just have to copy the Kerberos image to your SD card, plug the SD card into your Raspberry Pi and that's it. It can also be installed on other devices than the Raspberry Pi; for development or production. Therefore you will need to compile the machinery from source and install the webinterface with your favorite webserver.
<a name="install-from-image"></a>
## Install from image
If you want to use Kerberos.io **as a service**, this would be the preferred way. Kerberos is provided as an image, a pre-installed operating system. The only thing you have to do to make things work, is to transfer the image to your SD card. After transferring you can just plug the SD card into your Raspberry Pi and kerberos will work; isn't that great!
The're a lot of different ways to accomplish this, and they are different according the operating system you will be using to transfer the image.
<a name="download-the-image"></a>
### 1. Download the image
First you will need to download the Kerberos image; click on the image below. The Kerberos.io image contains a Linux operating system, built on Arch Linux. The image has the machinery and webinterface installed, and ofcourse all the dependencies Kerberos needs. With this image you just have to plugin the SD card in your Raspberry Pi and you're done.
#### Raspberry Pi Model A, A+, B and B+
The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. Its a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video.
![Kerberos.io image](3_kerberos-image.png)
#### Raspberry Pi Model 2
The Raspberry Pi 2 is the successor to the Raspberry Pi. It builds upon the original model B+ upgrading to 1 GB of RAM, and replacing the aged ARMv6l single-core with an ARMv7l Cortex-A7 quad-core.
![Kerberos.io image](3_kerberos-image.png)
<a name="insert-your-sd-card"></a>
### 2. Insert your SD Card
Ensure that you have inserted the SD card, that you wish to clone, into the SD card reader. If your PC/Mac does'nt have an internal SD card reader, you will need to plug in an external SD card reader via a USB socket.
<a name="osx-transfer-image"></a>
### 3. OSX: transfer image
* Download the .dmg file (RPi-sd card builder v1.2)
[![RPi logo](3_rpi-logo-cloner.png)](https://mega.co.nz/#!PZc2HTTQ!eD9dtFpoKnbZqP1hkvrv43_Pvc9xadMVxRP2K-M8n88)
* Run the app
* Select the operating system distributions (.img file)
* You will prompt with this. After you connect your SD card press continue.
* Now you have to select your SD card.
* Now the program will need administrator privileges. insert your password
* Confirm that your SD card has been unmounted.
<a name="windows-transfer-image"></a>
### 3. Windows: transfer image
* Download and install the [Win32DiskImager](http://sourceforge.net/projects/win32diskimager/files/latest/download).
* Select the image file you've downloaded earlier and the drive letter of the SD card.
<a name="transfer-image-with-terminal"></a>
### 3. OSX/Linux: transfer image with terminal
#### Locate Your SD Card
Open Terminal and enter the following command to locate your SD Card:
diskutil list
Look for your SD card; you can look at the size of the disk. In most cases you will be using a 4GB or bigger SD card.
#### Unmount SD card
We located our SD card at the /dev/disk3 drive; please note that this can be another disk drive, see previous step. In Terminal, enter the following command:
diskutil unmountDisk /dev/disk3
#### Format SD card
To format the SD card, enter the following command:
sudo newfs_msdos -F 16 /dev/disk3
#### Transfer image to your SD card
In Terminal, enter the following command ensuring that you identify the correct destination disc.
sudo dd if=~/Desktop/kerberos-io.img of=/dev/disk3
<a name="setup-wifi-connection"></a>
### 4. (Optional) Setup WIFI connection
If you will be using Kerberos.io with a WIFI dongle, then check out the [F.A.Q. page](/1.0.0/FAQ#setup-wifi).
<a name="install-from-source"></a>
## Install from source
This will be the procedure if you want to contribute to Kerberos or if you want to use Kerberos on your local machine. To install Kerberos from source; you will need to [compile the machinery](/1.0.0/machinery/installation) from source and [import the webinterface](/1.0.0/web/installation) into your favorite webserver.

BIN
dev/3_kerberos-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
dev/3_rpi-logo-cloner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,32 @@
# Introduction
* [The web interface](#the-web-interface)
* [How does it work](#how-does-it-work)
* [Installation](#installation)
* [How to access](#how-to-access)
<a name="the-web-interface"></a>
## The web interface
Kerberos.web, the webinterface, allows you to configure the machinery and to view events that were detected by the machinery. You can use your mobile phone, tablet or desktop to view the images with the *responsive* and *intuitive* web interface.
<a name="how-does-it-work"></a>
## How does it work?
The webinterface is written in PHP using the extremely popular PHP Framework **Laravel**. It visualizes images, taken by the machinery, in a intuitive and responsive way. Besides a server-side framework, it also uses a client-side framework **Backbone** to create the dynamic behaviour. The webinterface includes the latest development tools, to increase development efficiency: RequireJS, bower, LESS, etc.
Besides visualization, the webinterface is also used to configure the machinery. On the settings page a user can select different options, for example a user could select a region where motion should be detected or could select a time range when motion could be detected, which algorithm is used, etc.
The webinterface can also be used to configure Kerberos with our [**cloud application**](/dev/addons/Cloud). The setup is very easy, you only need to create an account on our cloud application, request a key, and enter it in every webinterface you want to have synced.
<a name="installation"></a>
## Installation
If Kerberos is installed from the image, the webinterface will be pre-installed and nothing is left to do. If you want to install the webinterface from source, you will need to create a new webapplication on your webbrowser and transfer the webproject.
<a name="how-to-access"></a>
## How to access
You can access the webinterface by entering the ip address of the Raspberry Pi in your favorite browser. When the webapplication is loaded you will see a login page, on which you will need to enter your credentials. The default username and password is **root**. You are able to change this password by editing the **app/config/app.php** file.
![Login page kerberos.io webinterface](1_how-to-access.png)

View File

@@ -0,0 +1,106 @@
# Installation
* [Install from source](#install-from-source)
* [Install on Arch Linux](#install-from-source-on-arch-linux)
The web interface is already installed on the Kerberos image, however you can also install the webinterface from source; you don't need to do this if you've deployed the Kerberos image on the SD card.
<a name="install-from-source"></a>
## Install from source
The web interface can be installed standalone, for example to host the web interface on an external server; e.g. to increase performance and to centralize multiple kerberos instances.
<a name="install-from-source-on-arch-linux"></a>
### Install on Arch Linux
Update the Arch Linux kernel
pacman -Syyu
Install git, nginx, php with extensions and nodejs
pacman -S git nginx php php-fpm php-gd php-mcrypt php-apc php-composer nodejs
Start nginx and php-fpm on boot
systemctl enable nginx
systemctl enable php-fpm
Edit nginx config
nano /etc/nginx/nginx.conf
Copy and paste following config
user http http;
worker_processes 1;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
http {
index index.html index.htm index.php;
include mime.types;
root /home/kerberos-web/public;
server {
server_name kerberos.rpi kerberos.rpi;
index index.php index.html index.htm;
location /{
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
Make sure you've enabled following php extensions: mcrypt, phar, gd and openssl.
nano /etc/php/php.ini
Uncomment following extensions
extension=mcrypt.so
extension=phar.so
extension=gd.so
extension=openssl.so
Add the APC extension at the end of the extensions list
extension=apcu.so
Go to home directory
cd /home
Get the source code from github
git clone https://github.com/kerberos-io/web kerberos-web
Install php packages by using composer
cd kerberos-web
composer install
Change config file: edit the "config" variable, link it to the config directory of the kerberos-io repository. If you don't have the kerberos-io repository installed on that specific server, you can make it an empty string. In this case the option "settings" won't show up in the navigation menu. Please note that the default value is set to the destination of the machinery when installed on the Raspberry Pi.
nano app/config/app.php
Change write permission on the storage directory
chmod -R 777 app/storage
Install bower globally by using node package manager, this is installed when installing nodejs.
npm -g install bower
Install Front end dependencies with bower
cd public
bower --allow-root install

View File

@@ -0,0 +1,40 @@
# Contribute
* [Versioning](#versioning)
* [Composer](#composer)
* [Laravel](#laravel)
* [Bower](#bower)
This documents describes how to contribute to Kerberos and describes all the technical stuff you will need to know. If you want to contribute you will need to install the source code on your local environment.
<a name="versioning"></a>
## Versioning
The source is managed on [Github](https://github.com/kerberos-io), and thus we are using git as our version control. For simplicity we are using following [branching model](http://nvie.com/posts/a-successful-git-branching-model/). The model includes:
* main branch
* develop branch
* hotfix and release branches
If you are a new developer, fork the development branch and send a pull request.
<a name="composer"></a>
## Composer
Make sure you have [composer installed](https://getcomposer.org/download/) on your local system. Run this in your terminal to get the latest Composer version:
curl -sS https://getcomposer.org/installer | php
Or if you don't have curl:
php -r "readfile('https://getcomposer.org/installer');" | php
<a name="laravel"></a>
## Laravel
We're using Laravel as our PHP framework. You will find all the information you need on the laravel [documentation site](http://laravel.com/docs).
<a name="bower"></a>
## Bower
Bower is used for managing our front end dependencies. Bower can be installed with npm, so make sure you have installed node.

View File

@@ -0,0 +1,40 @@
# Project structure
* [Configuration](#configuration)
* [File structure](#file-structure)
* [Server](#server)
* [Client](#client)
The web interace contains several important concepts and this is the right place where we will explain them briefly.
<a name="configuration"></a>
## Configuration
The web interface can be used to configure the machinery and therefore provides a *settings* page where algorithms, expositors, etc can be configured. The web interface will convert the configuration files into HTML elements, so when adding new algorithms or heuristics, the parameters will be reflected in the web interface automatically. The only thing you need to do is to specify a type to each parameter. You will find an equivalent *view* with the same name in the **app/views/controls** directory.
The webinterface can be used to configure Kerberos with our [**cloud application**](/dev/addons/Cloud). The setup is very easy, you only need to create an account on our cloud application, request a key, and enter it in every webinterface you want to have synced. Once Kerberos is configured with the cloud application, a filewatcher, **Gruntjs**, will push new images to the cloud application immediately.
<a name="file-structure"></a>
## File structure
Laravel has been used as back end framework, so if you aren't familiar with Laravel, check out their [documentation website](http://laravel.com/docs). However we will give a briefly explanation of the most important directories.
<a name="server"></a>
### Server
* **app/config/app.php** - this file contains Kerberos specific parameters; where the configuration files can be found, the user credentials to sign in, etc.
* **app/controllers** - MVC controllers
* **app/repositories** -repositories are injected into the controller.
* **app/api.php** - contains all the URI endpoints for Ajax calls.
* **app/repositories.php** - bind repositories to a specific interface - dependency injection.
* **app/routes.php** - url routing for pages.
<a name="client"></a>
### Client
* **public/css/less** - LESS is used for the CSS.
* **public/js/app** - BackboneJS and RequireJS is used for building modular JS classes.
* **public/js/mustache** - Mustache is used for the client-side view rendering.
* **public/js/vendor** - This is where the bower extensions are installed.
* **public/capture** - A directory where images are written to by default.
* **public/bower.json** - The bower extensions used in the kerberos project.
* **public/Gruntfile.js** - We are using Grunt for our task manager.

View File

@@ -0,0 +1,20 @@
# Introduction
* [The machinery](#the-machinery)
* [How does it work](#how-does-it-work)
* [Installation](#installation)
<a name="the-machinery"></a>
## The machinery
Kerberos.io, the machinery, is a video detection framework, it uses a flexible project structure that can be expanded easily. You can use your favorite **USB webcam** or the new **Raspberry Pi camera module**. The machinery uses OpenCV within its core to create new and powerful functionality, on a efficient way.
<a name="how-does-it-work"></a>
## How does it work?
More information can be found on the [project structure page](/dev/machinery/project_structure).
<a name="installation"></a>
## Installation
The machinery will be installed when deploying the image on your SD card. However you can also compile and link the machinery yourself. Look at the [installation section](/dev/installation) to read more about it.

View File

@@ -0,0 +1,83 @@
# Installation
* [Install from source](#install-from-source)
* [Install on Arch Linux](#install-from-source-on-arch-linux)
* [Auto start](#start-kerberos-on-boot-archlinux)
The machinery is already installed on the Kerberos image, however you can also install the machinery from source.
<a name="install-from-source"></a>
## Install from source
The machinery can be installed standalone.
<a name="install-from-source-on-arch-linux"></a>
### Install on ArchLinux
Update the ArchLinux kernel
pacman -Syyu
Install git, subversion, development tools (c++, cmake) and V4L utils.
pacman -S git subversion cmake base-devel v4l-utils eigen
Go to home directory
cd /home
Get the source code from github
git clone https://github.com/kerberos-io/machinery kerberos-io
Compile kerberos
cd kerberos-io && mkdir build && cd build
cmake .. && make && make check
Add link library to path
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/home/kerberos-io/build/thirdparty/lib/
Give rights to config files
chmod -R 777 ../config
<a name="start-kerberos-on-boot-archlinux"></a>
#### Auto start
Create service file for kerberos
nano /etc/systemd/system/kerberos.service
Copy and paste the configuration to the kerberos.service
[Unit]
Description=Kerberos.io Video Surveillance
[Service]
Type=oneshot
ExecStart=/home/kerberos-io/bin/kerberos
[Install]
WantedBy=multi-user.target
Create timer file for kerberos
nano /etc/systemd/system/kerberos.timer
Copy and paste the configuration to the kerberos.timer
[Unit]
Description=Runs kerberos.service, 1 min after system boot.
[Timer]
OnBootSec=1min
Unit=kerberos.service
[Install]
WantedBy=multi-user.target
Enable the service to start on boot
systemctl enable kerberos.timer

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

View File

@@ -0,0 +1,360 @@
# Contribute
* [Versioning](#versioning)
* [CMake](#cmake)
* [CMake setup](#cmake-setup)
* [Src folder](#src-folder)
* [CMake folder](#cmake-folder)
* [Setup kerberos in your IDE](#setup-kerberos-in-your-ide)
* [OSX](#osx)
* [Create a new XCode project](#create-a-new-xcode-project)
* [Compile source with CMake](#compile-source-with-cmake)
* [Link headers and libraries](#link-headers-and-libraries)
* [Add source to project](#add-source-to-project)
* [Select libraries](#select-libraries)
* [Specifiy header- and library locations](#specify-header-and-library-locations)
* [Linux](#linux)
* [Adding a new class](#adding-a-new-class)
* [Create the header file](#create-the-header-file)
* [Create the source file](#create-the-source-file)
* [Modify the CMakeLists.txt file](#modifile-the-cmakelists-file)
* [Create a new entry in the config file](#create-a-new-entry-in-the-config-file)
* [Compile](#compile)
* [Adding a test](#adding-a-test)
* [Create the test file](#create-the-test-file)
This documents describes how to contribute to the machinery and describes all the technical stuff you will need to know. If you want to contribute you will need to install the source code on your local environment.
<a name="versioning"></a>
## Versioning
The source is managed on [Github](https://github.com/kerberos-io), and thus we are using git as our version control. For simplicity we are using following [branching model](http://nvie.com/posts/a-successful-git-branching-model/). The model includes:
* main branch
* develop branch
* hotfix and release branches
If you are a new developer, fork the development branch and send a pull request.
<a name="cmake"></a>
## CMake
As mentioned before on the *installation* page, the machinery is using CMake. Therefore if you want to compile the source code, you will need to have installed CMake first. When executing the **CMake** command, CMake will create the appropriate makefiles to compile the machinery.
<a name="cmake-setup"></a>
### CMake setup
At the root of the project you will find the main CMakeList.txt file, and this is where everything starts. The root CMake file will include all the other CMake files; which are located in the *src* and *cmake* folder.
<a name="src-folder"></a>
#### Src folder
The *src* folder includes the machinery. You will find a CMakeLists.txt file in the folder and every subfolder. The CMakeLists.txt is reponsible for the directory it belongs to and will contain all the necesarry commands.
<a name="cmake-folder"></a>
#### CMake folder
The *CMake* directory in the root folder, contains the cmakefiles that will download all the dependencies. The CMake files describe where the dependencies are located (Github, SVN, etc.) but also how they need to be build, configured and/or installed.
<a name="setup-kerberos-in-your-ide"></a>
## Setup kerberos in your IDE
<a name="osx"></a>
### OSX
OSX users can use the XCode IDE to contribute to the machinery. The only hard thing will be to setup the XCode configuration files; to indicate where the headers can be found and where the dynamic libraries are located.
<a name="create-a-new-xcode-project"></a>
#### Create a new XCode project
First we will create a new XCode C++ project and checkout the machinery from [Github](https://github.com/kerberos-io).
<a name="compile-source-with-cmake"></a>
#### Compile source with CMake
Once the project has been setup, we will compile the source code with CMake. Open a terminal and go to the root of the project, enter following command.
mkdir build && cd build && cmake .. && make
<a name="link-headers-and-libraries"></a>
#### Link headers and libraries
When the source has been compiled succesfully we will modify the XCode configuration of the machinery. Therefore we will need to do three things: include the header directories, link the libraries and include the source files.
<a name="add-source-to-project"></a>
##### Add source to project
Select all the source files in the **/src** directory, and drag-and-drop them in the *Compile Sources* section.
![Add source](3_add-source.png)
<a name="select-libraries"></a>
##### Select libraries
Select all the libraries in the **/build/thirdparty/lib** directory, and drag-and-drop them in the *Link Binary With Libraries* section.
![Select libraries](3_add-libraries.png)
<a name="specify-header-and-library-locations"></a>
##### Specifiy header- and library locations
Click on the project name and select the *Build Settings* page, search for the keyword **search**.
![Select criteria](3_select-search-criteria.png)
Define the header search paths.
![Select header paths](3_header-paths.png)
Define the library search paths.
![Select header paths](3_library-paths.png)
<a name="linux"></a>
### Linux
The idea is the same as the installation for OSX, so first you will need to checkout the source code and compile it with the one liner below.
mkdir build && cd build && cmake .. && make
For the time being I didn't had the time to find a good IDE for Linux and to experiment with it. So if someone else could complete the documentation for Linux environments that would be great!
<a name="adding-a-new-class"></a>
## Adding a new class
This paragraph will tell you how to create a new condition, algorithm, expositor, io or capture device. For simplicity we will show how to create a new algorithm; the steps are identical if you want to create for example a new capture device; only the directory will differ.
<a name="create-the-header-file"></a>
### Create the header file
First we will need to create a new header file in the *include/kerberos/machinery/algorithm* directory. You can copy an existing algorithm header file, and start from that. You will end up with the following header file:
//
// Class: AnotherAlgorithm
// Description: Another algorithm
// Created: ...
// Author: ...
// Mail: ...
// Website: ...
//
// The copyright to the computer program(s) herein
// is the property of kerberos.io, Belgium.
// The program(s) may be used and/or copied .
//
/////////////////////////////////////////////////////
#ifndef __AnotherAlgorithm_H_INCLUDED__ // if AnotherAlgorithm.h hasn't been included yet...
#define __AnotherAlgorithm_H_INCLUDED__ // #define this so the compiler knows it has been included
#include "machinery/algorithm/Algorithm.h"
namespace kerberos
{
char AnotherAlgorithmName[] = "AnotherAlgorithm";
class AnotherAlgorithm : public AlgorithmCreator<AnotherAlgorithmName, AnotherAlgorithm>
{
private:
Image m_result;
int m_parameter;
public:
AnotherAlgorithm(){}
void setup(const StringMap & settings);
void initialize(ImageVector & images);
Image evaluate(ImageVector & images, JSON & data);
void setParameter(int parameter);
};
}
#endif
When creating a new class you will need to inherit from it corresponding creator, for the algorithm example: AlgorithmCreator. The creator class requires two template parameters. The first one is a unqie name for the class, this name will be used to make some kind of dependency injection possible. We will use the name to setup the configuration files, and to use it to select a specific class. The second parameter is the class itself.
The inheritance of the creator class can be a little bit strange, but it is required and needed to register the class automatically with the factory. When the code gets compiled, the classes will be automatically registered with the factory, and you can create instances of those classes by using the name we've defined in the first template parameter. For example we could create a new instance of our previously created class with the following command.
Algorithm * anotherAlgorithm = Factory<Algorithm>::getInstance()->create("AnotherAlgorithm");
<a name="create-the-source-file"></a>
### Create the source file
Ofcourse we also need to have an implementation file, therefore we need to create a new source file in the *src/kerberos/machinery/algorithm* directory. Just like the previous example, you can copy an existing class and implement the member functions you've declared in the header file. An example would be:
#include "machinery/algorithm/AnotherAlgorithm.h"
namespace kerberos
{
void AnotherAlgorithm::setup(const StringMap & settings)
{
Algorithm::setup(settings);
int parameter = std::atoi(settings.at("algorithms.AnotherAlgorithm.parameter").c_str());
setParameter(parameter);
}
void AnotherAlgorithm::initialize(ImageVector & images)
{
....
}
Image AnotherAlgorithm::evaluate(ImageVector & images, JSON & data)
{
Image evaluation;
... do something ..
return evaluation;
}
void AnotherAlgorithm::setParameter(int parameter)
{
m_parameter = parameter;
}
}
<a name="modifile-the-cmakelists-file"></a>
### Modify the CMakeLists.txt file
Open the CMakeLists.txt in the *src/kerberos* directory file and append the name of the algorithm class to the *KERBEROS_FACTORY_ENTITIES* variable; for example *machinery/algorithm/AnotherAlgorithm.cpp*.
# -------------------------------------------------------
# Entities that have to be registered with the factory
# - classes are registered on compile time, so they
# don't belong to a library. New algorithms, expositors
# or Io classes belong here.
set(KERBEROS_FACTORY_ENTITIES
capture/USBCamera.cpp
machinery/condition/Time.cpp
machinery/condition/Enabled.cpp
machinery/algorithm/DifferentialCollins.cpp
machinery/algorithm/DifferentialCollinsWithColor.cpp
machinery/algorithm/AnotherAlgorithm.cpp
machinery/expositor/RectangleExpositor.cpp
machinery/expositor/HullExpositor.cpp
machinery/heuristic/Sequence.cpp
machinery/io/IoDisk.cpp
machinery/io/IoTCP.cpp
machinery/io/IoMongoDB.cpp
)
<a name="create-a-new-entry-in-the-config-file"></a>
### Create a new entry in the config file
Open the algorithm.xml file in the **config** directory, and add a new tag with exactly the same name you've used in the header file; so in our example "AnotherAlgorithm". Within the new tag we can add properties that we will be use to configure our algorithm, in our example we defined a field **parameter** so we can add this field in the config file.
One thing you will need to do is to attach a **type** to a property. The type will be used by the web interface to automatically render the properties. For simplicity we can use the type number, this will show an input box on the settings page of the web interface where we are able to add numbers.
<algorithms>
<AnotherAlgorithm>
<parameter type="number">5</parameter>
</AnotherAlgorithm>
</algorithms>
You can retrieve the parameter in the **setup** function with the settings parameter.
settings.at("algorithms.AnotherAlgorithm.parameter")
<a name="compile"></a>
### Compile
Hurray, we've made it! So now you can compile the code again, and if you're using an IDE don't forget to include the new source file! However if you are compiling from the commandline you just have to go to the build folder and write **make**.
<a name="adding-a-test"></a>
## Adding a new test
When someone adds a class for a new io device, algorithm or expositor, he/she will need to write some documentation about the class but also need to provide some unit tests. This paragraph will provide you how to write a simple test.
<a name="create-the-test-file"></a>
### Create the test file
Add a new file to the **test/** directory, prefix the file with *test_* e.g. test_condition_enabled.cpp. Include the *gtest* and *gmock* headers; and also the Factory and Type headers. Write a new test condition, this is where the assert will be executed.
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "Factory.h"
#include "Types.h"
using ::testing::AtLeast;
using ::testing::Return;
using namespace kerberos;
// ----------------------------------------
// Enabled condition: allowed function
TEST(ENABLED_CONDITION, ALLOWED)
{
Condition * condition = Factory<Condition>::getInstance()->create("Enabled");
// This is only for mocking
ImageVector images;
StringMap settings;
settings["conditions.Enabled.delay"] = "2000";
// Enable condition
settings["conditions.Enabled.active"] = "true";
condition->setup(settings);
bool canExecute = condition->allowed(images);
EXPECT_EQ(true, canExecute);
// Disable condition
settings["conditions.Enabled.active"] = "false";
condition->setup(settings);
canExecute = condition->allowed(images);
EXPECT_EQ(false, canExecute);
}
### Run tests
To execute the test you can run the **make check** in the **build/** directory. When you've added a new test file, you will need to execute the **cmake** command again.
cd build/
cmake ..
make check
You will get following output
macbook:build cedricverstraeten$ make check
[ 1%] Built target EXECUTOR_LIBRARY
[ 8%] Built target TINYXML_LIBRARY
[ 16%] Built target FILEWATCHER_LIBRARY
[ 29%] Built target opencv
[ 49%] Built target KERBEROS_CORE
[ 62%] Built target googletest
[ 75%] Built target googlemock
[100%] Built target kerberos-test
[==========] Running 6 tests from 5 test cases.
[----------] Global test environment set-up.
[----------] 1 test from ENABLED_CONDITION
[ RUN ] ENABLED_CONDITION.ALLOWED
[ OK ] ENABLED_CONDITION.ALLOWED (2002 ms)
[----------] 1 test from ENABLED_CONDITION (2002 ms total)
[----------] 2 tests from HELPER
[ RUN ] HELPER.T_TO_STRING
[ OK ] HELPER.T_TO_STRING (0 ms)
[ RUN ] HELPER.NORMALIZE_PATH
[ OK ] HELPER.NORMALIZE_PATH (0 ms)
[----------] 2 tests from HELPER (0 ms total)
[----------] 1 test from HULL_EXPOSITOR
[ RUN ] HULL_EXPOSITOR.CALCULATE
[ OK ] HULL_EXPOSITOR.CALCULATE (1 ms)
[----------] 1 test from HULL_EXPOSITOR (1 ms total)
[----------] 1 test from RECTANGLE_EXPOSITOR
[ RUN ] RECTANGLE_EXPOSITOR.CALCULATE
[ OK ] RECTANGLE_EXPOSITOR.CALCULATE (0 ms)
[----------] 1 test from RECTANGLE_EXPOSITOR (0 ms total)
[----------] 1 test from SEQUENCE_HEURISTIC
[ RUN ] SEQUENCE_HEURISTIC.IS_VALID
[ OK ] SEQUENCE_HEURISTIC.IS_VALID (1005 ms)
[----------] 1 test from SEQUENCE_HEURISTIC (1005 ms total)
[----------] Global test environment tear-down
[==========] 6 tests from 5 test cases ran. (3008 ms total)
[ PASSED ] 6 tests.
[100%] Built target check
macbook:build cedricverstraeten$

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View File

@@ -0,0 +1,131 @@
# Project structure
* [Lifecycle](#lifecycle)
* [Capture](#capture)
* [Condition](#condition)
* [Algorithm](#algorithm)
* [Expositor](#expositor)
* [Heuristic](#heuristic)
* [Io](#io)
* [Technical design](#techinal-design)
* [Configuration](#configuration)
* [Filewatcher](#filewatcher)
* [Factory](#factory)
* [Dependencies](#dependencies)
* [Image Processing](#image-processing)
* [RapidJSON](#rapidjson)
* [Testing](#testing)
* [Continous integration](#continous-integration)
* [Unit testing / Mocking](#unit-testing-mocking)
* [File structure](#file-structure)
The machinery contains several important concepts and this is the place where we will tackle them briefly.
<a name="lifecycle"></a>
## Lifecycle
The machinery is a video recognition framework and is devided into four steps:
* condition
* algorithm
* expositor
* heuristic
The steps belong to a four passway; illustrated on the image below. In each cycle a sequence of images is processed. Each step will process the sequence, and will return some result to the next step. For example: an algorithm will process the images and returns an array to the Expositor, which contains boolean values. The steps are **loosly coupled**, so they have **simple conventions**, just like the example before.
Thanks to the loosly coupling, each step can be developed indepently. So algorithms, expositors, heuristics and conditions can be switched on the fly. This makes it easier for other developers who want to contribute to kerberos. They can create a new algorithm without knowing how a specific expositor or heuristic works. They just need to be aware of the convention an algorithm should meet.
![Lifecycle](4_project_structure.png)
<a name="capture"></a>
### Capture
You can choose which capture device you will be using, you can use your old USB webcam or the hi-tech and cheap Raspberry Pi Camera Module. The capture device will take some pictures and deliver them to the algorithm if the conditions (the first step of the four passway) are valid.
<a name="condition"></a>
### Condition
The condition is the first step of the four passway. In this step kerberos will determine if it's allowed to proceed to the next step. For example a condition can be a time constraint, a brightness threshold, etc. Multiple conditions can be selected and configured with the web interface.
<a name="algorithm"></a>
### Algorithm
The algorithm is the second step of the four passway. An algorithm will execute some kind of function on a sequence of images. An example of an algorithm would be one that does motion detection or one that would detect cats or dogs.
<a name="expositor"></a>
### Expositor
After the algorithm is executed, the expositor will determine, a region, where the changes were detected. An expositor can constrain a region in terms of selecting a hull or defining a rectangle.
<a name="heuristic"></a>
### Heuristic
When the expositor detected some kind of region, a heuristic will evaluate, the current and previous detections. The heuristic is basically some kind of memory which makes decision and tells kerberos if the detection was true or false.
<a name="io"></a>
### IO
If the heuristic determined that the detection was valid, one or more IO operations can be executed. For example an image can be saved to disk or an email can be sent.
<a name="technical-design"></a>
## Technical design
Kerberos.io has some technical design concepts, the most important parts are described below.
<a name="configuration"></a>
### Configuration
When the machinery is started, the first thing it will do is reading a configuration file; an XML file. The configuration file contains which algorithm, expositor, or capture device are selected, and the parameters they require. When the configuration is done, the machinery will enter the four passway and start the recognition. The configuration file can be modified on the settings page from the web interface, but could also be modified manually; in the config directory of the machinery.
<a name="filewatcher"></a>
### Filewatcher
When the configuration file is modified, we don't need to restart the machinery ourself. The machinery uses a filewatcher, named **Guard**, that will reconfigure the machinery on the fly without restarting the machinery itself. For example, a user want to change the time constraints, or wants to enlarge the resolution of the captured images.
<a name="factory"></a>
### Factory
The machinery uses the **factory class registration pattern**. Algorithms, expositors, heurstics and conditions are registered to the factory on compilation. Thanks to this mechanism, developers don't have to modify other classes than those they've created. So for example if a developer would add a new algorithm he will just need to create a new header and implementation file, and map a unique name to the class in the implementation file; this behaviour is similar to dependency injection without using reflection; reflection is not available in C++.
<a name="dependencies"></a>
## Dependencies
Kerberos.io has some dependencies, which are installed on the fly, when compiling machinery. We are using the externalproject feature of the cmake autotool to get the different depedencies from their source control (Github, SVN, ..).
<a name="image-processing"></a>
### Image Processing
Kerberos.io is a video recognition framework and is therefore using a image processing library; OpenCV (Open Source Computer Vision). Thanks to this very powerful computer vision framework, developers can benefit from it and increase development time.
<a name="rapidjson"></a>
### Rapidjson
The machinery is using the rapidjson library to provide a flexible datastructure: JSON. The library is used within the core of kerberos, and is concerned within every step of the four pass way; except in the first step the condition, to be 100% correct.
<a name="testing"></a>
## Testing
<a name="continous-integration"></a>
### Continous integration
The machinery is deployed automatically on **travis-ci**, when a new commit/release is pushed.
<a name="unit-testing-mocking"></a>
### Unit testing / Mocking
We strongly recommend testing as a best practice in complex projects. Therefore the machinery uses the popular c++ test library: Google Test and Google Mock. The test can be found in the **test** directory. You can run the test by executing following command:
make check
<a name="file-structure"></a>
## File structure
* **bin** - contains the kerberos compiled and linked executable.
* **build** - contains all the compiled dependencies and source code.
* **cmake** - information about how to compile kerberos, and were to find the dependencies.
* **config** - configuration files that are used to configure kerberos.
* **exceptions** - custom exceptions.
* **include** - kerberos header files.
* **logs** - log file, kerberos exceptions are written to.
* **src** - kerberos source files.
* **test** - google tests

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -0,0 +1,16 @@
# Capture
* [USB camera](#usb-camera)
* [Raspberry Pi Camera Module](#raspberry-pi-camera-module)
The capture device is responsible to take images. The images are used in the four pass way.
<a name="usb-camera"></a>
## USB camera
Kerberos supports a whole range of USB cameras. You will find a complete list [here](https://web.archive.org/web/20120815172655/http://opencv.willowgarage.com/wiki/Welcome/OS/). Make sure that you've updated the settings page on the web interface, that you will be using an USB camera.
<a name="raspberry-pi-camera-module"></a>
## Raspberry Pi Camera Module
You can use the Raspberry Pi Camera Module with Kerberos, you just need to attach the camera module and you are ready to go. The Raspberry Pi Camera Module is enabled by default in the web interface. Please note that if you didn't installed Kerberos with the image, you will need to [enable the camera module](/1.0.0/FAQ#how-to-enable-camera-module) yourself.

View File

@@ -0,0 +1,16 @@
# Condition
* [Time](#time)
* [Enabled](#enabled)
The condition is the first step of Kerberos. A condition is, like the word states, a conditional statement. One or more conditions can be selected (a sequence of conditions), that have to be valid. When the sequence of conditions is valid, Kerberos will go to the next step of the four passway, the algorithm. When one of the conditions in the sequence fail, Kerberos will idle for a specific time according the condition that failed.
<a name="time"></a>
## Time
A user can set a time range for each day of the week. The condition is valid if the current time is within the time range, for that specific day.
<a name="enabled"></a>
## Enabled
A user can select a checkbox to enable Kerberos.

View File

@@ -0,0 +1,24 @@
# USB Camera
Kerberos supports a whole range of USB cameras. You will find a complete list [here](https://web.archive.org/web/20120815172655/http://opencv.willowgarage.com/wiki/Welcome/OS/). Make sure you have updated the web interface, to make Kerberos aware you will be using an USB camera. [Be carefull](http://raspberrypi.stackexchange.com/questions/340/how-much-power-can-be-provided-through-usb) that you don't attach USB devices that require more than 100mA.
## Web interface
![USB camera](1_usb-camera.png)
## Parameters
The parameters of the USB capture device can be found in the *config/capture.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<captures>
<USBCamera>
<frameWidth type="number">1280</frameWidth>
<frameHeight type="number">720</frameHeight>
</USBCamera>
</captures>
### Framewidth and -height
You can set the resolution of the capture device, make sure the resolution you've defined is valid with your camera. Please check the specs of the USB camera you're using.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,32 @@
# USB Camera
You can use the Raspberry Pi Camera Module with Kerberos. You just need to attach the camera module and you're ready to go. The Raspberry Pi Camera Module is enabled by default in the web interface.
## Web interface
![Raspberry PI Camera Module](2_raspi-camera.png)
## Parameters
The parameters of the Raspberry Pi Camera Module can be found in the *config/capture.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<captures>
<RaspiCamera>
<frameWidth type="number">800</frameWidth>
<frameHeight type="number">640</frameHeight>
<night type="number">60</night>
<day type="number">150</day>
</RaspiCamera>
</captures>
### Framewidth and -height
You can set the resolution of the camera module, make sure the resolution you've defined is valid.
### Night and day
The Raspberry Pi Camera module has additional parameters. Thanks to the MMAL library we can change the configuration of the Raspberry Pi Camera Module. The night and day parameters are gray thresholds. The night parameter defines the lower gray value/threshold; if the brightness of the image taken by the camera module will be lower than the night value, it will switch to night mode. Similar, if the brightness is higher than the day value, it will switch to day mode.
Notice that there is a kind of gray zone. If the brightness of the image is within those range, no reconfiguration will happen. This feature will be more advanced in future.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,16 @@
# Algorithm
* [Differential Images](#differential-images)
The algorithm is the second step of the four passway. An algorithm will execute some kind of function on a sequence of images and end up with a black and white image; just like the image below.
The white pixels on the image will indicate the object of interest. For example, when looking for motion, the pixels that have been changed; it depends on what the algorithm is looking for. The black pixels are background pixels.
![Black and white image](7_black-and-white-image.png)
The only convention that an algorithm should meet is that it should return a black and white image to the next step; the expositor. And of course that it requires a sequence of images as a parameter. Besides those conventions, an algorithm can do everything it wants to do. So you could create your own cat detection algorithm, marker detection, etc.
<a name="differential-images"></a>
## Differential Images
This is a trivial **motion detection algorithm**. Three images are compared, and the pixels that have been changed are marked as white pixels, pixels that are black are background images.

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,29 @@
# Time
It can be helpful to enable or disable Kerberos at specific times. Therefore the time condition makes it possible to select a time range for each day of the week. When the current time is within the time range, Kerberos will be enabled.
## Web interface
![Time condition](1_time-condition.png)
## Parameters
The parameters of the Time condition can be found in the *config/condition.xml* file, but you can also use the web interface to modify the parameters. Below you see a default configuration file.
<conditions>
<Time>
<times type="timeselection">13:00,15:00-0:01,20:58-0:01,20:59-0:01,19:20-0:01,21:59-0,0-0,0</times>
<delay type="number">10000</delay>
</Time>
</conditions>
### Times
The times property contains a list of times, delimited by a "-". The first item in the list will specify the time range for the first day of the week (Monday), the last item for the last day of the week (Sunday). The begin- and end-time, for a specific day, are delimited by a "," where the first element will specify that start time and the second one specifies the end time.
### Delay
The delay value is used when the condition failed, so when the current time isn't in the selected time range for that day. In that case Kerberos will idle for the specified delay time. The value of the delay is expressed in miliseconds.

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Some files were not shown because too many files have changed in this diff Show More