Added parameters to constructor of blackborder processor

Added blur line removal
Moved blackborder classes to hyperion namespace
This commit is contained in:
T. van der Zwan 2013-08-23 05:08:44 +00:00
parent c43b99359a
commit 046c68574e
7 changed files with 111 additions and 80 deletions

View File

@ -2,6 +2,8 @@
// Local-Hyperion includes // Local-Hyperion includes
#include "BlackBorderDetector.h" #include "BlackBorderDetector.h"
using namespace hyperion;
BlackBorderDetector::BlackBorderDetector() BlackBorderDetector::BlackBorderDetector()
{ {
// empty // empty

View File

@ -4,11 +4,13 @@
// Utils includes // Utils includes
#include <utils/RgbImage.h> #include <utils/RgbImage.h>
/// namespace hyperion
/// Result structure of the detected blackborder.
///
struct BlackBorder
{ {
///
/// Result structure of the detected blackborder.
///
struct BlackBorder
{
/// ///
/// Enumeration of the possible types of detected borders /// Enumeration of the possible types of detected borders
/// ///
@ -25,16 +27,16 @@ struct BlackBorder
/// The size of detected border (negative if not applicable) /// The size of detected border (negative if not applicable)
int size; int size;
}; };
/// ///
/// The BlackBorderDetector performs detection of black-borders on a single image. /// The BlackBorderDetector performs detection of black-borders on a single image.
/// The detector will scan the border of the upper-left quadrant of an image. Based on detected /// The detector will scan the border of the upper-left quadrant of an image. Based on detected
/// black pixels it will give an estimate of the black-border. /// black pixels it will give an estimate of the black-border.
/// ///
class BlackBorderDetector class BlackBorderDetector
{ {
public: public:
/// ///
/// Constructs a black-border detector /// Constructs a black-border detector
/// ///
@ -49,7 +51,7 @@ public:
/// ///
BlackBorder process(const RgbImage& image); BlackBorder process(const RgbImage& image);
private: private:
/// ///
/// Checks if a given color is considered black and therefor could be part of the border. /// Checks if a given color is considered black and therefor could be part of the border.
@ -64,4 +66,5 @@ private:
return RgbColor::BLACK == color; return RgbColor::BLACK == color;
// TODO[TvdZ]: We could add a threshold to check that the color is close to black // TODO[TvdZ]: We could add a threshold to check that the color is close to black
} }
}; };
} // end namespace hyperion

View File

@ -1,8 +1,16 @@
// Local-Hyperion includes
#include "BlackBorderProcessor.h" #include "BlackBorderProcessor.h"
BlackBorderProcessor::BlackBorderProcessor() : using namespace hyperion;
_unknownSwitchCnt(600),
_borderSwitchCnt(50), BlackBorderProcessor::BlackBorderProcessor(
const unsigned unknownFrameCnt,
const unsigned borderFrameCnt,
const unsigned blurRemoveCnt) :
_unknownSwitchCnt(unknownFrameCnt),
_borderSwitchCnt(borderFrameCnt),
_blurRemoveCnt(blurRemoveCnt),
_detector(), _detector(),
_currentBorder({BlackBorder::unknown, 0}), _currentBorder({BlackBorder::unknown, 0}),
_lastDetectedBorder({BlackBorder::unknown, 0}), _lastDetectedBorder({BlackBorder::unknown, 0}),
@ -12,6 +20,11 @@ BlackBorderProcessor::BlackBorderProcessor() :
BlackBorder BlackBorderProcessor::getCurrentBorder() const BlackBorder BlackBorderProcessor::getCurrentBorder() const
{ {
if (_currentBorder.size > 0)
{
return {_currentBorder.type, _currentBorder.size+int(_blurRemoveCnt)};
}
return _currentBorder; return _currentBorder;
} }

View File

@ -4,21 +4,28 @@
// Local Hyperion includes // Local Hyperion includes
#include "BlackBorderDetector.h" #include "BlackBorderDetector.h"
class BlackBorderProcessor namespace hyperion
{ {
public: class BlackBorderProcessor
BlackBorderProcessor(); {
public:
BlackBorderProcessor(
const unsigned unknownFrameCnt,
const unsigned borderFrameCnt,
const unsigned blurRemoveCnt);
BlackBorder getCurrentBorder() const; BlackBorder getCurrentBorder() const;
bool process(const RgbImage& image); bool process(const RgbImage& image);
private: private:
const unsigned _unknownSwitchCnt; const unsigned _unknownSwitchCnt;
const unsigned _borderSwitchCnt; const unsigned _borderSwitchCnt;
unsigned _blurRemoveCnt;
BlackBorderDetector _detector; BlackBorderDetector _detector;
BlackBorder _currentBorder; BlackBorder _currentBorder;
@ -26,5 +33,5 @@ private:
BlackBorder _lastDetectedBorder; BlackBorder _lastDetectedBorder;
unsigned _consistentCnt; unsigned _consistentCnt;
}; };
} // end namespace hyperion

View File

@ -9,35 +9,35 @@ SET(Hyperion_QT_HEADERS
) )
SET(Hyperion_HEADERS SET(Hyperion_HEADERS
${CURRENT_HEADER_DIR}/LedString.h
${CURRENT_HEADER_DIR}/LedDevice.h
${CURRENT_HEADER_DIR}/ImageProcessor.h ${CURRENT_HEADER_DIR}/ImageProcessor.h
${CURRENT_HEADER_DIR}/ImageProcessorFactory.h ${CURRENT_HEADER_DIR}/ImageProcessorFactory.h
${CURRENT_HEADER_DIR}/LedDevice.h
${CURRENT_HEADER_DIR}/LedString.h
${CURRENT_HEADER_DIR}/PriorityMuxer.h ${CURRENT_HEADER_DIR}/PriorityMuxer.h
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h
${CURRENT_SOURCE_DIR}/LedDeviceTest.h
${CURRENT_SOURCE_DIR}/ImageToLedsMap.h
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.h
${CURRENT_SOURCE_DIR}/BlackBorderDetector.h ${CURRENT_SOURCE_DIR}/BlackBorderDetector.h
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.h
${CURRENT_SOURCE_DIR}/ColorTransform.h ${CURRENT_SOURCE_DIR}/ColorTransform.h
${CURRENT_SOURCE_DIR}/HsvTransform.h ${CURRENT_SOURCE_DIR}/HsvTransform.h
${CURRENT_SOURCE_DIR}/ImageToLedsMap.h
${CURRENT_SOURCE_DIR}/LedDeviceTest.h
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h
) )
SET(Hyperion_SOURCES SET(Hyperion_SOURCES
${CURRENT_SOURCE_DIR}/LedString.cpp
${CURRENT_SOURCE_DIR}/Hyperion.cpp ${CURRENT_SOURCE_DIR}/Hyperion.cpp
${CURRENT_SOURCE_DIR}/ImageProcessor.cpp ${CURRENT_SOURCE_DIR}/ImageProcessor.cpp
${CURRENT_SOURCE_DIR}/ImageProcessorFactory.cpp ${CURRENT_SOURCE_DIR}/ImageProcessorFactory.cpp
${CURRENT_SOURCE_DIR}/LedString.cpp
${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp ${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp
${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp
${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp ${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp
${CURRENT_SOURCE_DIR}/ColorTransform.cpp ${CURRENT_SOURCE_DIR}/ColorTransform.cpp
${CURRENT_SOURCE_DIR}/HsvTransform.cpp ${CURRENT_SOURCE_DIR}/HsvTransform.cpp
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp
${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp
) )
set(Hyperion_RESOURCES set(Hyperion_RESOURCES

View File

@ -5,6 +5,8 @@
// Hyperion includes // Hyperion includes
#include "hyperion/BlackBorderDetector.h" #include "hyperion/BlackBorderDetector.h"
using namespace hyperion;
RgbColor randomColor() RgbColor randomColor()
{ {
const uint8_t randomRedValue = uint8_t(rand() % (std::numeric_limits<uint8_t>::max() + 1)); const uint8_t randomRedValue = uint8_t(rand() % (std::numeric_limits<uint8_t>::max() + 1));

View File

@ -5,8 +5,11 @@
// Utils includes // Utils includes
#include <utils/RgbImage.h> #include <utils/RgbImage.h>
// Local-Hyperion includes
#include "hyperion/BlackBorderProcessor.h" #include "hyperion/BlackBorderProcessor.h"
using namespace hyperion;
RgbColor randomColor() RgbColor randomColor()
{ {
const uint8_t randomRedValue = uint8_t(rand() % (std::numeric_limits<uint8_t>::max() + 1)); const uint8_t randomRedValue = uint8_t(rand() % (std::numeric_limits<uint8_t>::max() + 1));
@ -40,8 +43,9 @@ int main()
{ {
unsigned unknownCnt = 600; unsigned unknownCnt = 600;
unsigned borderCnt = 50; unsigned borderCnt = 50;
unsigned blurCnt = 0;
BlackBorderProcessor processor; BlackBorderProcessor processor(unknownCnt, borderCnt, blurCnt);
// Start with 'no border' detection // Start with 'no border' detection
RgbImage noBorderImage = createImage(64, 64, 0, 0); RgbImage noBorderImage = createImage(64, 64, 0, 0);