mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Merge branch 'master' of https://github.com/tvdzwan/hyperion.git
Former-commit-id: e21a530324abb6af92f4b34abdfbf23313775f4a
This commit is contained in:
@@ -4,6 +4,7 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc)
|
||||
|
||||
add_subdirectory(hyperion)
|
||||
add_subdirectory(blackborder)
|
||||
add_subdirectory(jsonserver)
|
||||
add_subdirectory(protoserver)
|
||||
add_subdirectory(boblightserver)
|
||||
|
11
libsrc/blackborder/BlackBorderDetector.cpp
Normal file
11
libsrc/blackborder/BlackBorderDetector.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
// BlackBorders includes
|
||||
#include <blackborder/BlackBorderDetector.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
BlackBorderDetector::BlackBorderDetector(uint8_t blackborderThreshold) :
|
||||
_blackborderThreshold(blackborderThreshold)
|
||||
{
|
||||
// empty
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
|
||||
// Local-Hyperion includes
|
||||
#include <hyperion/BlackBorderProcessor.h>
|
||||
// Blackborder includes
|
||||
#include <blackborder/BlackBorderProcessor.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
BlackBorderProcessor::BlackBorderProcessor(
|
||||
const unsigned unknownFrameCnt,
|
||||
BlackBorderProcessor::BlackBorderProcessor(const unsigned unknownFrameCnt,
|
||||
const unsigned borderFrameCnt,
|
||||
const unsigned blurRemoveCnt) :
|
||||
const unsigned blurRemoveCnt,
|
||||
uint8_t blackborderThreshold) :
|
||||
_unknownSwitchCnt(unknownFrameCnt),
|
||||
_borderSwitchCnt(borderFrameCnt),
|
||||
_blurRemoveCnt(blurRemoveCnt),
|
||||
_detector(),
|
||||
_detector(blackborderThreshold),
|
||||
_currentBorder({true, -1, -1}),
|
||||
_previousDetectedBorder({true, -1, -1}),
|
||||
_consistentCnt(0)
|
23
libsrc/blackborder/CMakeLists.txt
Normal file
23
libsrc/blackborder/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
# Define the current source locations
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/blackborder)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/blackborder)
|
||||
|
||||
SET(Blackborder_HEADERS
|
||||
${CURRENT_HEADER_DIR}/BlackBorderDetector.h
|
||||
${CURRENT_HEADER_DIR}/BlackBorderProcessor.h
|
||||
)
|
||||
|
||||
SET(Blackborder_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp
|
||||
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp
|
||||
)
|
||||
|
||||
add_library(blackborder
|
||||
${Blackborder_HEADERS}
|
||||
${Blackborder_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(blackborder
|
||||
hyperion-utils
|
||||
)
|
@@ -1,10 +0,0 @@
|
||||
|
||||
// Local-Hyperion includes
|
||||
#include <hyperion/BlackBorderDetector.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
BlackBorderDetector::BlackBorderDetector()
|
||||
{
|
||||
// empty
|
||||
}
|
@@ -17,9 +17,6 @@ SET(Hyperion_HEADERS
|
||||
${CURRENT_HEADER_DIR}/LedString.h
|
||||
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
||||
|
||||
${CURRENT_HEADER_DIR}/BlackBorderDetector.h
|
||||
${CURRENT_HEADER_DIR}/BlackBorderProcessor.h
|
||||
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
|
||||
)
|
||||
|
||||
@@ -30,8 +27,6 @@ SET(Hyperion_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/LedString.cpp
|
||||
${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp
|
||||
|
||||
${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp
|
||||
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp
|
||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
|
||||
@@ -54,6 +49,7 @@ add_library(hyperion
|
||||
)
|
||||
|
||||
target_link_libraries(hyperion
|
||||
blackborder
|
||||
hyperion-utils
|
||||
leddevice
|
||||
effectengine
|
||||
|
@@ -270,7 +270,10 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
||||
throw std::runtime_error("Color transformation incorrectly set");
|
||||
}
|
||||
// initialize the image processor factory
|
||||
ImageProcessorFactory::getInstance().init(_ledString, jsonConfig["blackborderdetector"].get("enable", true).asBool());
|
||||
ImageProcessorFactory::getInstance().init(
|
||||
_ledString,
|
||||
jsonConfig["blackborderdetector"].get("enable", true).asBool(),
|
||||
jsonConfig["blackborderdetector"].get("threshold", 0.01).asDouble());
|
||||
|
||||
// initialize the color smoothing filter
|
||||
_device = createColorSmoothing(jsonConfig["color"]["smoothing"], _device);
|
||||
|
@@ -2,50 +2,52 @@
|
||||
// Hyperion includes
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <hyperion/ImageToLedsMap.h>
|
||||
#include <hyperion/BlackBorderProcessor.h>
|
||||
|
||||
// Blacborder includes
|
||||
#include <blackborder/BlackBorderProcessor.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector) :
|
||||
mLedString(ledString),
|
||||
ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector, uint8_t blackborderThreshold) :
|
||||
_ledString(ledString),
|
||||
_enableBlackBorderRemoval(enableBlackBorderDetector),
|
||||
_borderProcessor(new BlackBorderProcessor(600, 50, 1)),
|
||||
mImageToLeds(nullptr)
|
||||
_borderProcessor(new BlackBorderProcessor(600, 50, 1, blackborderThreshold)),
|
||||
_imageToLeds(nullptr)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
ImageProcessor::~ImageProcessor()
|
||||
{
|
||||
delete mImageToLeds;
|
||||
delete _imageToLeds;
|
||||
delete _borderProcessor;
|
||||
}
|
||||
|
||||
unsigned ImageProcessor::getLedCount() const
|
||||
{
|
||||
return mLedString.leds().size();
|
||||
return _ledString.leds().size();
|
||||
}
|
||||
|
||||
void ImageProcessor::setSize(const unsigned width, const unsigned height)
|
||||
{
|
||||
// Check if the existing buffer-image is already the correct dimensions
|
||||
if (mImageToLeds && mImageToLeds->width() == width && mImageToLeds->height() == height)
|
||||
if (_imageToLeds && _imageToLeds->width() == width && _imageToLeds->height() == height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean up the old buffer and mapping
|
||||
delete mImageToLeds;
|
||||
delete _imageToLeds;
|
||||
|
||||
// Construct a new buffer and mapping
|
||||
mImageToLeds = new ImageToLedsMap(width, height, 0, 0, mLedString.leds());
|
||||
_imageToLeds = new ImageToLedsMap(width, height, 0, 0, _ledString.leds());
|
||||
}
|
||||
|
||||
bool ImageProcessor::getScanParameters(size_t led, double &hscanBegin, double &hscanEnd, double &vscanBegin, double &vscanEnd) const
|
||||
{
|
||||
if (led < mLedString.leds().size())
|
||||
if (led < _ledString.leds().size())
|
||||
{
|
||||
const Led & l = mLedString.leds()[led];
|
||||
const Led & l = _ledString.leds()[led];
|
||||
hscanBegin = l.minX_frac;
|
||||
hscanEnd = l.maxX_frac;
|
||||
vscanBegin = l.minY_frac;
|
||||
|
@@ -10,13 +10,25 @@ ImageProcessorFactory& ImageProcessorFactory::getInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
void ImageProcessorFactory::init(const LedString& ledString, bool enableBlackBorderDetector)
|
||||
void ImageProcessorFactory::init(const LedString& ledString, bool enableBlackBorderDetector, double blackborderThreshold)
|
||||
{
|
||||
_ledString = ledString;
|
||||
_enableBlackBorderDetector = enableBlackBorderDetector;
|
||||
|
||||
int threshold = int(std::ceil(blackborderThreshold * 255));
|
||||
if (threshold < 0)
|
||||
threshold = 0;
|
||||
else if (threshold > 255)
|
||||
threshold = 255;
|
||||
_blackborderThreshold = uint8_t(threshold);
|
||||
|
||||
if (_enableBlackBorderDetector)
|
||||
{
|
||||
std::cout << "Black border threshold set to " << blackborderThreshold << " (" << int(_blackborderThreshold) << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ImageProcessor* ImageProcessorFactory::newImageProcessor() const
|
||||
{
|
||||
return new ImageProcessor(_ledString, _enableBlackBorderDetector);
|
||||
return new ImageProcessor(_ledString, _enableBlackBorderDetector, _blackborderThreshold);
|
||||
}
|
||||
|
@@ -223,6 +223,12 @@
|
||||
"enable" : {
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
},
|
||||
"threshold" : {
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0.0,
|
||||
"maximum" : 1.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
|
@@ -3,9 +3,6 @@
|
||||
set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/protoserver)
|
||||
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/protoserver)
|
||||
|
||||
# add protocol buffers
|
||||
find_package(Protobuf REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROTOBUF_INCLUDE_DIRS})
|
||||
|
Reference in New Issue
Block a user