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 Jul 15, 2017
2 parents 0f77500 + 378278d commit b6fa560
Show file tree
Hide file tree
Showing 143 changed files with 1,746 additions and 521 deletions.
4 changes: 3 additions & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ build/*
build_xcode/*
config/*
ide/*
test/bin/*
test/bin/*
cmake-build*
.idea*
Empty file modified .travis.yml
100644 → 100755
Empty file.
18 changes: 12 additions & 6 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ project(Kerberos)

# ----------------------------------------------
# Check if compiling on the raspberry pi


set(IS_RASPBERRYPI 0)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
FIND_LIBRARY(mmalcore_LIBS NAMES mmal_core PATHS /opt/vc/lib)
FIND_LIBRARY(mmalutil_LIBS NAMES mmal_util PATHS /opt/vc/lib)
FIND_LIBRARY(mmal_LIBS NAMES mmal PATHS /opt/vc/lib)

if( ( mmal_LIBS ) AND ( mmalutil_LIBS ) AND ( mmalcore_LIBS ) )
set(IS_RASPBERRYPI 1)
endif()
set(IS_RASPBERRYPI 1)
endif()
endif()
add_definitions(-DIS_RASPBERRYPI=${IS_RASPBERRYPI})

# ----------------------------------------------
# Enable MongoDB
Expand All @@ -26,7 +28,7 @@ project(Kerberos)
if(TESTS_ENABLED)
include(CTest)
endif()

# ----------------------------------------------
# Variables

Expand All @@ -38,6 +40,10 @@ project(Kerberos)
set(KERBEROS_SRC "")
set(KERBEROS_FACTORY_ENTITIES "")

set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -std=gnu++11 -Wno-pmf-conversions -Wno-unused-result" )
set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -Wall -std=gnu11" )
set( CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -Wall -std=gnu11" )

# ----------------------------------------------
# Build all the dependencies

Expand All @@ -54,11 +60,11 @@ project(Kerberos)
# Package

set(PACKAGE 0 CACHE STRING "Should the project be packaged?")

# ----------------------------------------------
# Link source and tests (if enabled)

add_subdirectory(src)
if(TESTS_ENABLED)
add_subdirectory(test)
endif()
endif()
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified cmake/External-Googletest.cmake
100644 → 100755
Empty file.
Empty file modified cmake/External-OpenCV.cmake
100644 → 100755
Empty file.
36 changes: 36 additions & 0 deletions cmake/External-OpenMax.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -----------------------------------
# Userland, ARM used by raspicam

message("Bind project: OpenMAX")

set(USERLAND_INCLUDE_DIR /opt/vc/include/)
set(USERLAND_LIBRARY_DIR /opt/vc/lib/)

include_directories(${USERLAND_INCLUDE_DIR})
link_directories(${USERLAND_LIBRARY_DIR})

# -----------------------------------
# OpenMaxIL-cpp

message("External project: OpenMaxIL-cpp")

ExternalProject_Add(openmax
GIT_REPOSITORY ${git_protocol}://github.com/dridri/OpenMaxIL-cpp
SOURCE_DIR openmax
BINARY_DIR openmax-build
UPDATE_COMMAND ""
PATCH_COMMAND ""
CMAKE_GENERATOR ${gen}
INSTALL_COMMAND ""
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/thirdparty
-DBUILD_SHARED_LIBS=OFF
)

set(OPENMAX_INCLUDE_DIR ${CMAKE_BINARY_DIR}/openmax/include/)
set(OPENMAX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/openmax-build/)

set(OPENMAX_LIBRARIES -lopenmaxil -lbcm_host -lvcsm -lvcos -lvchiq_arm -lrt -lpthread -ldl "OpenMaxIL++")

include_directories(${OPENMAX_INCLUDE_DIR})
link_directories(${OPENMAX_LIBRARY_DIR})
Empty file modified cmake/External-RaspiCam.cmake
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions cmake/External-Restclient.cmake
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
message("External project: Restclient")

ExternalProject_Add(restclient
GIT_REPOSITORY ${git_protocol}://github.com/mrtazz/restclient-cpp
GIT_TAG 0.3.0
GIT_REPOSITORY ${git_protocol}://github.com/cedricve/restclient-cpp
GIT_TAG master
SOURCE_DIR restclient
BUILD_IN_SOURCE 1
UPDATE_COMMAND ""
Expand Down
15 changes: 11 additions & 4 deletions cmake/Superbuild.cmake
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ include( ExternalProject )
if(${IS_RASPBERRYPI})

# --------------------------------------------------------------------------
# RaspiCam
# RaspiCam (not longer used, becaused switched to OpenMAX)
#

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/External-RaspiCam.cmake)
set(KERBEROS_DEPENDENCIES ${KERBEROS_DEPENDENCIES} raspicamera)
# include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/External-RaspiCam.cmake)
# set(KERBEROS_DEPENDENCIES ${KERBEROS_DEPENDENCIES} raspicamera)

# --------------------------------------------------------------------------
# OpenMax library
#

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/External-OpenMax.cmake)
set(KERBEROS_DEPENDENCIES ${KERBEROS_DEPENDENCIES} openmax)

endif()

# --------------------------------------------------------------------------
# Restclient

Expand Down
5 changes: 5 additions & 0 deletions config/capture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<frameHeight type="number">480</frameHeight>
<delay type="number">500</delay>
<angle type="number">0</angle>
<framerate type="number">20</framerate>
<sharpness type="number">0</sharpness>
<saturation type="number">0</saturation>
<contrast type="number">0</contrast>
<brightness type="number">50</brightness>
</RaspiCamera>

<VideoCapture>
Expand Down
Empty file modified config/cloud.xml
100644 → 100755
Empty file.
6 changes: 4 additions & 2 deletions config/io.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
<Video>
<fps type="number">3</fps>
<recordAfter type="number">5</recordAfter>
<maxDuration type="number">120</maxDuration>
<maxDuration type="number">30</maxDuration>
<extension type="number">mp4</extension>
<codec type="number">h264</codec>
<fileFormat type="text">timestamp_microseconds_instanceName_regionCoordinates_numberOfChanges_token</fileFormat>
<directory type="text">/etc/opt/kerberosio/capture/</directory>
<hardwareDirectory type="text">/etc/opt/kerberosio/h264/</hardwareDirectory>
<enableHardwareEncoding type="bool">true</enableHardwareEncoding>
<markWithTimestamp type="bool">false</markWithTimestamp>
<timestampColor type="text">white</timestampColor>
<privacy type="bool">false</privacy>
Expand All @@ -36,5 +38,5 @@
<Script>
<path type="text">/etc/opt/kerberosio/scripts/run.sh</path>
</Script>

</ios>
4 changes: 3 additions & 1 deletion config/stream.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<enabled type="bool">true</enabled>
<streamPort type="number">8889</streamPort>
<quality type="number">75</quality>
<fps type="number">5</fps>
<fps type="number">15</fps>
<username type="text"></username>
<password type="text"></password>
</Mjpg>

</streams>
3 changes: 2 additions & 1 deletion docker/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN ln -sf /bin/true /sbin/initctl
# Let the container know that there is no tty

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y libcurl4-openssl-dev

############################
# Clone and build machinery
Expand Down Expand Up @@ -46,4 +47,4 @@ ADD ./supervisord.conf /etc/supervisord.conf
ADD ./run.sh /run.sh
RUN chmod 755 /run.sh

CMD ["/bin/bash", "/run.sh"]
CMD ["/bin/bash", "/run.sh"]
Empty file modified docker/README.md
100644 → 100755
Empty file.
15 changes: 14 additions & 1 deletion docker/run.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#!/bin/bash

/usr/bin/supervisord -n -c /etc/supervisord.conf
autoremoval() {
while true; do
sleep 60

if [[ $(df -h | grep /dev/vda1 | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]];
then
echo "Cleaning disk"
find /etc/opt/kerberosio/capture/ -type f | sort | head -n 100 | xargs rm;
fi;
done
}
autoremoval &

/usr/bin/supervisord -n -c /etc/supervisord.conf
Empty file modified docker/supervisord.conf
100644 → 100755
Empty file.
Empty file modified exceptions/Exception.h
100644 → 100755
Empty file.
Empty file modified exceptions/Exception.hpp
100644 → 100755
Empty file.
Empty file modified exceptions/KerberosException.h
100644 → 100755
Empty file.
Empty file modified exceptions/OpenCVException.h
100644 → 100755
Empty file.
Empty file modified exceptions/SocketException.h
100644 → 100755
Empty file.
Empty file modified exceptions/TinyXMLException.h
100644 → 100755
Empty file.
Empty file modified include/easylogging/easylogging++.h
100644 → 100755
Empty file.
Empty file modified include/encode/HMAC_SHA1.h
100644 → 100755
Empty file.
Empty file modified include/encode/SHA1.h
100644 → 100755
Empty file.
Empty file modified include/encode/base64.h
100644 → 100755
Empty file.
Empty file modified include/executor/Executor.h
100644 → 100755
Empty file.
Empty file modified include/filewatcher/FileWatcher.h
100644 → 100755
Empty file.
Empty file modified include/filewatcher/FileWatcherImpl.h
100644 → 100755
Empty file.
Empty file modified include/filewatcher/FileWatcherLinux.h
100644 → 100755
Empty file.
Empty file modified include/filewatcher/FileWatcherOSX.h
100644 → 100755
Empty file.
Empty file modified include/filewatcher/FileWatcherWin32.h
100644 → 100755
Empty file.
Empty file modified include/filewatcher/Guard.h
100644 → 100755
Empty file.
Empty file modified include/kerberos/Factory.h
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion include/kerberos/Globals.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
#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.2.2"
#define VERSION "2.3.0"
#define HADES "https://hades.kerberos.io"
#define CLOUD "https://cloud.kerberos.io"
#define SYMBOL_DIRECTORY "/etc/opt/kerberosio/symbols/"
#define CONFIGURATION_PATH "/etc/opt/kerberosio/config/config.xml"
#define LOG_PATH "/etc/opt/kerberosio/logs/log.stash"

#define RUNNING_ON_A_RASPBERRYPI false
#if IS_RASPBERRYPI == 1
#define RUNNING_ON_A_RASPBERRYPI true
#endif

#endif
9 changes: 7 additions & 2 deletions include/kerberos/Helper.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// The copyright to the computer program(s) herein
// is the property of Verstraeten.io, Belgium.
// The program(s) may be used and/or copied under
// The program(s) may be used and/or copied under
// the CC-NC-ND license model.
//
// https://doc.kerberos.io/license
Expand All @@ -34,6 +34,7 @@
#include <sys/stat.h>
#include <sstream>
#include <cctype>
#include <algorithm>

namespace kerberos
{
Expand All @@ -52,10 +53,14 @@ namespace kerberos
std::string getMicroseconds();
const std::string currentDateTime(std::string timezone = "");
int compareTime(const std::string & first, const std::string & second);
const std::string random_string(size_t length);
const std::string getRootDirectory(const char * relativeDirectory);
void tokenize(const std::string & str, std::vector<std::string> & tokens, const std::string & delimiters = ",");
std::string normalizePath(const std::string & cwd, const std::string & command, const std::string & binaryPath);
std::string GetStdoutFromCommand(std::string cmd);
std::string returnPathOfLink(const char* pathname);
std::string removeUnwantedChars(std::string & text);
}
}

#endif
#endif
1 change: 1 addition & 0 deletions include/kerberos/Kerberos.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "document.h" // rapidjson
#include "capture/Stream.h"
#include "easylogging++.h"
#include "restclient-cpp/restclient.h"

namespace kerberos
{
Expand Down
46 changes: 46 additions & 0 deletions include/kerberos/System.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Class: System
// Description: Provide information about
// the current system.
// Created: 05/07/2017
// Author: Cédric Verstraeten
// Mail: [email protected]
// Website: www.verstraeten.io
//
// The copyright to the computer program(s) herein
// is the property of Verstraeten.io, Belgium.
// The program(s) may be used and/or copied under
// the CC-NC-ND license model.
//
// https://doc.kerberos.io/license
//
/////////////////////////////////////////////////////

#include "Globals.h"
#include "Helper.h"
#include <string>
#include <algorithm>

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

namespace kerberos
{
class System
{
public:

std::string static getHostname();
std::string static getDiskPercentage(std::string partition);
std::string static getTemperature();
std::string static getWifiSSID();
std::string static getWifiStrength();
std::string static getUptime();
std::string static getBoard();
std::string static isDocker();
std::string static isKiOS();
std::string static getNumberOfFiles(std::string & directory);
std::string static getCPUid();
};
}
#endif
Empty file modified include/kerberos/Types.h
100644 → 100755
Empty file.
26 changes: 16 additions & 10 deletions include/kerberos/capture/Capture.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// The copyright to the computer program(s) herein
// is the property of Verstraeten.io, Belgium.
// The program(s) may be used and/or copied under
// The program(s) may be used and/or copied under
// the CC-NC-ND license model.
//
// https://doc.kerberos.io/license
Expand Down Expand Up @@ -36,36 +36,42 @@ namespace kerberos
protected:
ImageVector m_images;
const char * name;

public:
pthread_mutex_t m_lock;
pthread_t m_captureThread;

int m_frameWidth, m_frameHeight;
int m_angle; // 90, 180, 270
int m_delay; // msec

Capture(){};
int m_framerate;
bool m_onBoardRecording;
bool m_hardwareMJPEGEncoding;

Capture():m_framerate(30),m_onBoardRecording(false),m_hardwareMJPEGEncoding(false){};
virtual ~Capture(){};
virtual void setup(kerberos::StringMap & settings) = 0;
void setup(kerberos::StringMap & settings, int width, int height, int angle);
virtual void setImageSize(int width, int height);
virtual void setRotation(int angle);
virtual void setDelay(int msec);

virtual void grab() = 0;
virtual Image retrieve() = 0;
virtual int32_t retrieveRAW(uint8_t* data) = 0;
virtual Image * takeImage() = 0;
virtual void startRecord(std::string path) = 0;
virtual void stopRecord() = 0;

ImageVector & takeImages(int numberOfImages);
ImageVector & shiftImage();
ImageVector & shiftImages(int numberOfImages);

virtual void open() = 0;
virtual void close() = 0;
virtual void update() = 0;
virtual bool isOpened() = 0;

void startGrabThread();
void stopGrabThread();
};
Expand All @@ -75,10 +81,10 @@ namespace kerberos
{
protected:
CaptureCreator(){name = ID;}

public:
static Capture* create(){return new Class();};
static const char * ID;
};
}
#endif
#endif
Loading

0 comments on commit b6fa560

Please sign in to comment.