diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9486fbd8..bed5086f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@
# define the minimum cmake version (as required by cmake)
cmake_minimum_required(VERSION 2.8)
-set(CMAKE_TOOLCHAIN_FILE /home/johan/raspberrypi/Toolchain-RaspberryPi.cmake)
+set(CMAKE_TOOLCHAIN_FILE /opt/raspberrypi/Toolchain-RaspberryPi.cmake)
# Define the main-project name
project(Hyperion)
@@ -29,6 +29,15 @@ set(CMAKE_BUILD_TYPE "Release")
# enable C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")
+# Configure the use of QT4
+find_package(Qt4 COMPONENTS QtCore REQUIRED QUIET)
+
+SET(QT_DONT_USE_QTGUI TRUE)
+SET(QT_USE_QTCONSOLE TRUE)
+include(${QT_USE_FILE})
+add_definitions(${QT_DEFINITIONS})
+link_directories(${CMAKE_FIND_ROOT_PATH}/lib/arm-linux-gnueabihf)
+
configure_file(bin/install_hyperion.sh ${LIBRARY_OUTPUT_PATH} @ONLY)
configure_file(config/hyperion.config.json ${LIBRARY_OUTPUT_PATH} @ONLY)
configure_file(config/hyperion.schema.json ${LIBRARY_OUTPUT_PATH} @ONLY)
diff --git a/include/boblight-functions.h b/include/boblight-functions.h
deleted file mode 100644
index 0e0731e0..00000000
--- a/include/boblight-functions.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * boblight
- * Copyright (C) Bob 2009
- *
- * boblight is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * boblight is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-//these definitions can be expanded to make normal prototypes, or functionpointers and dlsym lines
-
-BOBLIGHT_FUNCTION(void*, boblight_init, ());
-BOBLIGHT_FUNCTION(void, boblight_destroy, (void* vpboblight));
-
-BOBLIGHT_FUNCTION(int, boblight_connect, (void* vpboblight, const char* address, int port, int usectimeout));
-BOBLIGHT_FUNCTION(int, boblight_setpriority, (void* vpboblight, int priority));
-BOBLIGHT_FUNCTION(const char*, boblight_geterror, (void* vpboblight));
-BOBLIGHT_FUNCTION(int, boblight_getnrlights, (void* vpboblight));
-BOBLIGHT_FUNCTION(const char*, boblight_getlightname, (void* vpboblight, int lightnr));
-
-BOBLIGHT_FUNCTION(int, boblight_getnroptions, (void* vpboblight));
-BOBLIGHT_FUNCTION(const char*, boblight_getoptiondescript,(void* vpboblight, int option));
-BOBLIGHT_FUNCTION(int, boblight_setoption, (void* vpboblight, int lightnr, const char* option));
-BOBLIGHT_FUNCTION(int, boblight_getoption, (void* vpboblight, int lightnr, const char* option, const char** output));
-
-BOBLIGHT_FUNCTION(void, boblight_setscanrange, (void* vpboblight, int width, int height));
-
-BOBLIGHT_FUNCTION(int, boblight_addpixel, (void* vpboblight, int lightnr, int* rgb));
-BOBLIGHT_FUNCTION(void, boblight_addpixelxy, (void* vpboblight, int x, int y, int* rgb));
-
-BOBLIGHT_FUNCTION(int, boblight_sendrgb, (void* vpboblight, int sync, int* outputused));
-BOBLIGHT_FUNCTION(int, boblight_ping, (void* vpboblight, int* outputused));
diff --git a/include/boblight.h b/include/boblight.h
deleted file mode 100644
index c5963570..00000000
--- a/include/boblight.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * boblight
- * Copyright (C) Bob 2009
- *
- * boblight is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * boblight is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-//if you define BOBLIGHT_DLOPEN, all boblight functions are defined as pointers
-//you can then call boblight_loadlibrary to load libboblight with dlopen and the function pointers with dlsym
-//if you pass NULL to boblight_loadlibrary's first argument, the default filename for libboblight is used
-//if boblight_loadlibrary returns NULL, dlopen and dlsym went ok, if not it returns a char* from dlerror
-
-//if you want to use the boblight functions from multiple files, you can define BOBLIGHT_DLOPEN in one file,
-//and define BOBLIGHT_DLOPEN_EXTERN in the other file, the functionpointers are then defined as extern
-
-#ifndef LIBBOBLIGHT
-#define LIBBOBLIGHT
-
- #if !defined(BOBLIGHT_DLOPEN) && !defined(BOBLIGHT_DLOPEN_EXTERN)
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- //generate normal prototypes
- #define BOBLIGHT_FUNCTION(returnvalue, name, arguments) returnvalue name arguments
- #include "boblight-functions.h"
- #undef BOBLIGHT_FUNCTION
-
- #ifdef __cplusplus
- }
- #endif
-
- #elif defined(BOBLIGHT_DLOPEN)
-
- #include
- #include
-
- //generate function pointers
- #define BOBLIGHT_FUNCTION(returnvalue, name, arguments) returnvalue (* name ) arguments = NULL
- #include "boblight-functions.h"
- #undef BOBLIGHT_FUNCTION
-
- #ifdef __cplusplus
- #define BOBLIGHT_CAST(value) reinterpret_cast
- #else
- #define BOBLIGHT_CAST(value) (value)
- #endif
-
- //gets a functionpointer from dlsym, and returns char* from dlerror if it didn't work
- #define BOBLIGHT_FUNCTION(returnvalue, name, arguments) \
- name = BOBLIGHT_CAST(returnvalue (*) arguments)(dlsym(p_boblight, #name)); \
- { char* error = dlerror(); if (error) return error; }
-
- void* p_boblight = NULL; //where we put the lib
-
- //load function pointers
- char* boblight_loadlibrary(const char* filename)
- {
- if (filename == NULL)
- filename = "libboblight.so";
-
- if (p_boblight != NULL)
- {
- dlclose(p_boblight);
- p_boblight = NULL;
- }
-
- p_boblight = dlopen(filename, RTLD_NOW);
- if (p_boblight == NULL)
- return dlerror();
-
- //generate dlsym lines
- #include "boblight-functions.h"
-
- return NULL;
- }
- #undef BOBLIGHT_FUNCTION
- #undef BOBLIGHT_CAST
-
- //you can define BOBLIGHT_DLOPEN_EXTERN when you load the library in another file
- #elif defined(BOBLIGHT_DLOPEN_EXTERN)
-
- extern char* boblight_loadlibrary(const char* filename);
- extern void* p_boblight;
- #define BOBLIGHT_FUNCTION(returnvalue, name, arguments) extern returnvalue (* name ) arguments
- #include "boblight-functions.h"
- #undef BOBLIGHT_FUNCTION
-
- #endif //BOBLIGHT_DLOPEN_EXTERN
-#endif //LIBBOBLIGHT
-
diff --git a/include/hyperion/DispmanxWrapper.h b/include/hyperion/DispmanxWrapper.h
new file mode 100644
index 00000000..4d9b5649
--- /dev/null
+++ b/include/hyperion/DispmanxWrapper.h
@@ -0,0 +1,32 @@
+#pragma once
+
+// QT includes
+#include
+#include
+
+// Forward class declaration
+class ImageProcessor;
+class DispmanxFrameGrabber;
+
+class DispmanxWrapper: public QObject
+{
+ Q_OBJECT
+public:
+ DispmanxWrapper();
+
+ virtual ~DispmanxWrapper();
+
+public slots:
+ void start();
+
+ void action();
+
+ void stop();
+
+private:
+ QTimer _timer;
+
+ DispmanxFrameGrabber* _frameGrabber;
+ ImageProcessor* _processor;
+};
+
diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h
index 1f3113de..e278bef3 100644
--- a/include/hyperion/Hyperion.h
+++ b/include/hyperion/Hyperion.h
@@ -4,9 +4,14 @@
// hyperion-utils includes
#include
+// Hyperion includes
#include
-#include
#include
+#include
+
+// Forward class declaration
+namespace hyperion { class ColorTransform; }
+
class Hyperion
{
@@ -15,27 +20,18 @@ public:
~Hyperion();
- void setInputSize(const unsigned width, const unsigned height);
-
- RgbImage& image()
- {
- return *mImage;
- }
-
- void commit();
-
- void operator() (const RgbImage& inputImage);
-
- void setColor(const RgbColor& color);
+ void setValue(int priority, std::vector &ledColors);
private:
void applyTransform(std::vector& colors) const;
LedString mLedString;
- RgbImage* mImage;
+ PriorityMuxer mMuxer;
- ImageToLedsMap mLedsMap;
+ hyperion::ColorTransform* mRedTransform;
+ hyperion::ColorTransform* mGreenTransform;
+ hyperion::ColorTransform* mBlueTransform;
LedDevice* mDevice;
};
diff --git a/include/hyperion/ImageProcessor.h b/include/hyperion/ImageProcessor.h
new file mode 100644
index 00000000..7ee06006
--- /dev/null
+++ b/include/hyperion/ImageProcessor.h
@@ -0,0 +1,72 @@
+
+#pragma once
+
+// Utils includes
+#include
+
+#include
+#include
+
+// Forward class declaration
+namespace hyperion { class ImageToLedsMap;
+ class ColorTransform; }
+
+/**
+ * The ImageProcessor translates an RGB-image to RGB-values for the leds. The processing is
+ * performed in two steps. First the average color per led-region is computed. Second a
+ * color-tranform is applied based on a gamma-correction.
+ */
+class ImageProcessor
+{
+public:
+ ~ImageProcessor();
+
+ /**
+ * Processes the image to a list of led colors. This will update the size of the buffer-image
+ * if required and call the image-to-leds mapping to determine the mean color per led.
+ *
+ * @param[in] image The image to translate to led values
+ *
+ * @return The color value per led
+ */
+ std::vector process(const RgbImage& image);
+
+ // 'IN PLACE' processing functions
+
+ /**
+ * Specifies the width and height of 'incomming' images. This will resize the buffer-image to
+ * match the given size.
+ * NB All earlier obtained references will be invalid.
+ *
+ * @param[in] width The new width of the buffer-image
+ * @param[in] height The new height of the buffer-image
+ */
+ void setSize(const unsigned width, const unsigned height);
+
+ /**
+ * Returns a reference of the underlying image-buffer. This can be used to write data directly
+ * into the buffer, avoiding a copy inside the process method.
+ *
+ * @return The reference of the underlying image-buffer.
+ */
+ RgbImage& image();
+
+ /**
+ * Determines the led colors of the image in the buffer.
+ *
+ * @param[out] ledColors The color value per led
+ */
+ void inplace_process(std::vector& ledColors);
+
+private:
+ friend class ImageProcessorFactory;
+
+ ImageProcessor(const LedString &ledString);
+
+private:
+ const LedString mLedString;
+
+ RgbImage *mBuffer;
+ hyperion::ImageToLedsMap* mImageToLeds;
+};
+
diff --git a/include/hyperion/ImageProcessorFactory.h b/include/hyperion/ImageProcessorFactory.h
new file mode 100644
index 00000000..dc558371
--- /dev/null
+++ b/include/hyperion/ImageProcessorFactory.h
@@ -0,0 +1,26 @@
+#pragma once
+
+// STL includes
+#include
+
+// Jsoncpp includes
+#include
+
+#include
+
+// Forward class declaration
+class ImageProcessor;
+
+class ImageProcessorFactory
+{
+public:
+ static ImageProcessorFactory& getInstance();
+
+public:
+ void init(const LedString& ledString);
+
+ ImageProcessor* newImageProcessor() const;
+
+private:
+ LedString _ledString;
+};
diff --git a/include/hyperion/ImageToLedsMap.h b/include/hyperion/ImageToLedsMap.h
deleted file mode 100644
index cc00972e..00000000
--- a/include/hyperion/ImageToLedsMap.h
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#pragma once
-
-// hyperion-utils includes
-#include
-
-// hyperion includes
-#include
-
-class ImageToLedsMap
-{
-public:
-
- ImageToLedsMap();
-
- void createMapping(const RgbImage& image, const std::vector& leds);
-
- std::vector getMeanLedColor();
-
- RgbColor findMeanColor(const std::vector& colors);
-
- std::vector getMedianLedColor();
-
- RgbColor findMedianColor(std::vector& colors);
-private:
- std::vector > mColorsMap;
-};
diff --git a/include/hyperion/LedString.h b/include/hyperion/LedString.h
index cc105b38..cc4962ff 100644
--- a/include/hyperion/LedString.h
+++ b/include/hyperion/LedString.h
@@ -45,28 +45,16 @@ struct Led
class LedString
{
public:
- static LedString construct(const Json::Value& ledConfig, const Json::Value& colorConfig);
+ static LedString construct(const Json::Value& ledConfig);
LedString();
~LedString();
+ std::vector& leds();
+
const std::vector& leds() const;
private:
std::vector mLeds;
-
-public:
- /**
- * Color adjustements per color
- */
- struct
- {
- /** The color gradient */
- double gamma;
- /** The color offset */
- double adjust;
- /** The minimum required level for the led to turn on */
- double blacklevel;
- } red, green, blue;
};
diff --git a/include/hyperion/PriorityMuxer.h b/include/hyperion/PriorityMuxer.h
new file mode 100644
index 00000000..c2e05fdf
--- /dev/null
+++ b/include/hyperion/PriorityMuxer.h
@@ -0,0 +1,55 @@
+#pragma once
+
+// STL includes
+#include
+#include