Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Verstraeten committed Sep 2, 2016
2 parents de3c0c8 + c045f14 commit 11a45d3
Show file tree
Hide file tree
Showing 27 changed files with 970 additions and 81 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ project(Kerberos)
# ---------------------------
# XCode system library

link_directories("/usr/local/lib")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_directories("/usr/local/lib")
endif()

# ---------
# Package
Expand Down
11 changes: 6 additions & 5 deletions cmake/External-OpenCV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ ExternalProject_Add(opencv
-DBUILD_opencv_core=ON
-DBUILD_opencv_imgproc=ON
-DBUILD_opencv_highgui=ON
-DBUILD_opencv_video=OFF
-DBUILD_opencv_video=ON
-DBUILD_opencv_apps=OFF
-DBUILD_opencv_flann=OFF
-DBUILD_opencv_flann=ON
-DBUILD_opencv_gpu=OFF
-DBUILD_opencv_ml=OFF
-DBUILD_opencv_ml=ON
-DBUILD_opencv_legacy=OFF
-DBUILD_opencv_calib3d=OFF
-DBUILD_opencv_features2d=OFF
-DBUILD_opencv_features2d=ON
-DBUILD_opencv_java=OFF
-DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_photo=OFF
Expand All @@ -38,6 +38,7 @@ ExternalProject_Add(opencv
-DBUILD_SHARED_LIBS:BOOL=OFF
-DBUILD_TESTS:BOOL=OFF
-DBUILD_PERF_TESTS:BOOL=OFF
-DBUILD_opencv_contrib=ON
-DCMAKE_BUILD_TYPE:STRING=Release
-DWITH_FFMPEG:BOOL=ON
-DWITH_IPP:BOOL=OFF
Expand All @@ -56,7 +57,7 @@ else()
set(OPENCV_LIBRARY_DIR ${CMAKE_BINARY_DIR}/thirdparty/x86/vc12/lib)
endif()

set(OPENCV_LIBRARIES opencv_imgproc opencv_core opencv_highgui opencv_videoio opencv_imgcodecs)
set(OPENCV_LIBRARIES opencv_imgproc opencv_core opencv_highgui opencv_video opencv_videoio opencv_imgcodecs opencv_features2d)

include_directories(${OPENCV_INCLUDE_DIR})
link_directories(${OPENCV_LIBRARY_DIR})
Expand Down
10 changes: 10 additions & 0 deletions config/algorithm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@
<threshold type="number">15</threshold>
</DifferentialCollins>

<BackgroundSubtraction>
<shadows type="text">true</shadows>
<history type="number">50</history>
<nmixtures type="number">5</nmixtures>
<ratio type="number">1</ratio>
<erode type="number">5</erode>
<dilate type="number">7</dilate>
<threshold type="number">20</threshold>
</BackgroundSubtraction>

</algorithms>
10 changes: 9 additions & 1 deletion config/capture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@
</USBCamera>

<RaspiCamera>
<frameWidth type="number">1280</frameWidth>
<frameHeight type="number">720</frameHeight>
<delay type="number">500</delay>
<angle type="number">0</angle>
</RaspiCamera>

<VideoCapture>
<frameWidth type="number">800</frameWidth>
<frameHeight type="number">640</frameHeight>
<path type="text">0</path>
<delay type="number">500</delay>
<angle type="number">0</angle>
</RaspiCamera>
</VideoCapture>

</captures>
1 change: 1 addition & 0 deletions config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<logging type="bool">false</logging>
<timezone type="timezone">Europe-Brussels</timezone>
<capture file="capture.xml">RaspiCamera</capture>
<stream file="stream.xml">Mjpg</stream>
<condition file="condition.xml" type="multiple">Enabled</condition>
<algorithm file="algorithm.xml">DifferentialCollins</algorithm>
<expositor file="expositor.xml">Hull</expositor>
Expand Down
10 changes: 10 additions & 0 deletions config/heuristic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,15 @@
<minimumDuration type="number">2</minimumDuration>
<noMotionDelayTime type="number">1000</noMotionDelayTime>
</Sequence>

<Counter>
<appearance type="number">5</appearance>
<maxDistance type="number">90</maxDistance>
<minArea type="number">1400</minArea>
<onlyTrueWhenCounted type="bool">true</onlyTrueWhenCounted>
<minimumChanges type="number">20</minimumChanges>
<noMotionDelayTime type="number">1000</noMotionDelayTime>
<markers type="twolines">100,100|100,200|200,100|200,200</markers>
</Counter>

</heuristics>
2 changes: 2 additions & 0 deletions config/io.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<Disk>
<fileFormat type="text">timestamp_microseconds_instanceName_regionCoordinates_numberOfChanges_token.jpg</fileFormat>
<directory type="text">/etc/opt/kerberosio/capture/</directory>
<markWithTimestamp type="bool">false</markWithTimestamp>
<timestampColor type="text">white</timestampColor>
</Disk>
<GPIO>
<pin type="number">17</pin>
Expand Down
10 changes: 10 additions & 0 deletions config/stream.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<streams>

<Mjpg>
<enabled type="bool">true</enabled>
<streamPort type="number">8889</streamPort>
<quality type="number">75</quality>
</Mjpg>

</streams>
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM phusion/baseimage:latest
FROM phusion/baseimage:0.9.16

MAINTAINER "Cédric Verstraeten" <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion include/kerberos/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifndef __Version_H_INCLUDED__ // if Version.h hasn't been included yet...
#define __Version_H_INCLUDED__ // #define this so the compiler knows it has been included

#define VERSION "2.0.0"
#define VERSION "2.1.0"
#define HADES "https://hades.kerberos.io"
#define SYMBOL_DIRECTORY "/etc/opt/kerberosio/symbols/"
#define CONFIGURATION_PATH "/etc/opt/kerberosio/config/config.xml"
Expand Down
3 changes: 2 additions & 1 deletion include/kerberos/Kerberos.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ namespace kerberos
void configure(const std::string & configuration);
void configureCapture(StringMap & settings);
void configureCloud(StringMap & settings);
void startStreamThread();
void configureStream(StringMap & settings);
void startStreamThread();
void stopStreamThread();
void startIOThread();
void stopIOThread();
Expand Down
1 change: 1 addition & 0 deletions include/kerberos/capture/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace kerberos
void difference(const Image & image, Image & result);
void bitwiseAnd(const Image & image, Image & result);
void erode(const Image & kernel);
void dilate(const Image & kernel);
void threshold(const int threshold);
int brightness();
static cv::Mat createKernel(int width, int height)
Expand Down
13 changes: 8 additions & 5 deletions include/kerberos/capture/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#define PORT unsigned short
#define SOCKET int
#define HOSTENT struct hostent
Expand All @@ -42,8 +43,10 @@ namespace kerberos
std::vector<SOCKET> clients;
SOCKET sock;
fd_set master;
int timeout; // master sock timeout, shutdown after timeout millis.
int quality; // jpeg compression [1..100]
bool m_enabled;
int m_streamPort;
int m_timeout; // master sock timeout, shutdown after timeout millis.
int m_quality; // jpeg compression [1..100]

int _write( int sock, char *s, int len )
{
Expand All @@ -57,19 +60,19 @@ namespace kerberos

public:

Stream(int port = 0) : sock(INVALID_SOCKET), timeout(10), quality(50)
Stream() : sock(INVALID_SOCKET), m_timeout(10), m_quality(70)
{
FD_ZERO( &master );
if (port) open(port);
}

~Stream()
{
release();
}

void configureStream(StringMap & settings);
bool release();
bool open(int port);
bool open();
bool isOpened();
bool connect();
void write(Image image);
Expand Down
63 changes: 63 additions & 0 deletions include/kerberos/capture/VideoCapture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// Class: VideoCapture
// Description: Class that plays a video file.
// Created: 17/05/2016
// Author: Cédric Verstraeten
// Mail: [email protected]
// Website: www.cedric.ws
//
// The copyright to the computer program(s) herein
// is the property of Cédric Verstraeten, Belgium.
// The program(s) may be used and/or copied .
//
/////////////////////////////////////////////////////

#ifndef __VideoCapture_H_INCLUDED__ // if VideoCapture.h hasn't been included yet...
#define __VideoCapture_H_INCLUDED__ // #define this so the compiler knows it has been included

#include "capture/Capture.h"
#include "Executor.h"

namespace kerberos
{
char VideoCaptureName[] = "VideoCapture";
class VideoCapture : public CaptureCreator<VideoCaptureName, VideoCapture>
{
private:
cv::VideoCapture * m_video;
std::string m_path;

public:
VideoCapture()
{
try
{
m_video = new cv::VideoCapture();
}
catch(cv::Exception & ex)
{
throw OpenCVException(ex.msg.c_str());
}
}

VideoCapture(int width, int height);
virtual ~VideoCapture(){};
void setup(StringMap & settings);
void setImageSize(int width, int height);
void setRotation(int angle){Capture::setRotation(angle);}
void setDelay(int msec){Capture::setDelay(msec);}
void setPath(std::string path){m_path=path;}
std::string getPath(){return m_path;}

void grab();
Image retrieve();
Image * takeImage();

void open();
void close();
void update();
bool isOpened();
};
}

#endif
45 changes: 45 additions & 0 deletions include/kerberos/machinery/algorithm/BackgroundSubtraction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Class: BackgroundSubtraction
// Description: An algorithm to detect motion using background subtraction.
// Created: 17/05/2016
// Author: Cédric Verstraeten
// Mail: [email protected]
// Website: www.kerberos.io
//
// 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 __BackgroundSubtraction_H_INCLUDED__ // if BackgroundSubtraction.h hasn't been included yet...
#define __BackgroundSubtraction_H_INCLUDED__ // #define this so the compiler knows it has been included

#include "machinery/algorithm/Algorithm.h"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/video/video.hpp"

namespace kerberos
{
char BackgroundSubtractionName[] = "BackgroundSubtraction";
class BackgroundSubtraction : public AlgorithmCreator<BackgroundSubtractionName, BackgroundSubtraction>
{
private:
int m_threshold;
Image m_erodeKernel;
Image m_dilateKernel;
Image m_backgroud;
cv::Ptr<cv::BackgroundSubtractorMOG2> m_subtractor;

public:
BackgroundSubtraction(){}
void setup(const StringMap & settings);

void setErodeKernel(int width, int height);
void setDilateKernel(int width, int height);
void setThreshold(int threshold);
void initialize(ImageVector & images);
Image evaluate(ImageVector & images, JSON & data);
};
}
#endif
Loading

0 comments on commit 11a45d3

Please sign in to comment.