Configurable blackborder threshold added

Former-commit-id: 95b77dee2869b41bf556e0e374bea3c5e4534e61
This commit is contained in:
johan
2014-01-20 20:46:38 +01:00
parent af08b9b5d0
commit a7110ec64c
15 changed files with 121 additions and 49 deletions

View File

@@ -48,8 +48,9 @@ namespace hyperion
public:
///
/// Constructs a black-border detector
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
///
BlackBorderDetector();
BlackBorderDetector(uint8_t blackborderThreshold);
///
/// Performs the actual black-border detection on the given image
@@ -125,7 +126,11 @@ namespace hyperion
inline bool isBlack(const Pixel_T & color)
{
// Return the simple compare of the color against black
return color.red < 3 && color.green < 3 && color.green < 3;
return color.red < _blackborderThreshold && color.green < _blackborderThreshold && color.green < _blackborderThreshold;
}
private:
/// Threshold for the blackborder detector [0 .. 255]
const uint8_t _blackborderThreshold;
};
} // end namespace hyperion

View File

@@ -21,11 +21,13 @@ namespace hyperion
/// horizontal border becomes the current border
/// @param blurRemoveCnt The size to add to a horizontal or vertical border (because the
/// outer pixels is blurred (black and color combined due to image scaling))
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
///
BlackBorderProcessor(
const unsigned unknownFrameCnt,
const unsigned borderFrameCnt,
const unsigned blurRemoveCnt);
const unsigned blurRemoveCnt,
uint8_t blackborderThreshold);
///
/// Return the current (detected) border

View File

@@ -53,7 +53,7 @@ public:
verifyBorder(image);
// Create a result vector and call the 'in place' functionl
std::vector<ColorRgb> colors = mImageToLeds->getMeanLedColor(image);
std::vector<ColorRgb> colors = _imageToLeds->getMeanLedColor(image);
// return the computed colors
return colors;
@@ -75,7 +75,7 @@ public:
verifyBorder(image);
// Determine the mean-colors of each led (using the existing mapping)
mImageToLeds->getMeanLedColor(image, ledColors);
_imageToLeds->getMeanLedColor(image, ledColors);
}
///
@@ -98,8 +98,10 @@ private:
/// given led-string specification
///
/// @param[in] ledString The led-string specification
/// @param[in] enableBlackBorderDetector Flag indicating if the blacborder detector should be enabled
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
///
ImageProcessor(const LedString &ledString, bool enableBlackBorderDetector);
ImageProcessor(const LedString &ledString, bool enableBlackBorderDetector, uint8_t blackborderThreshold);
///
/// Performs black-border detection (if enabled) on the given image
@@ -116,17 +118,17 @@ private:
const hyperion::BlackBorder border = _borderProcessor->getCurrentBorder();
// Clean up the old mapping
delete mImageToLeds;
delete _imageToLeds;
if (border.unknown)
{
// Construct a new buffer and mapping
mImageToLeds = new hyperion::ImageToLedsMap(image.width(), image.height(), 0, 0, mLedString.leds());
_imageToLeds = new hyperion::ImageToLedsMap(image.width(), image.height(), 0, 0, _ledString.leds());
}
else
{
// Construct a new buffer and mapping
mImageToLeds = new hyperion::ImageToLedsMap(image.width(), image.height(), border.horizontalSize, border.verticalSize, mLedString.leds());
_imageToLeds = new hyperion::ImageToLedsMap(image.width(), image.height(), border.horizontalSize, border.verticalSize, _ledString.leds());
}
std::cout << "CURRENT BORDER TYPE: unknown=" << border.unknown << " hor.size=" << border.horizontalSize << " vert.size=" << border.verticalSize << std::endl;
@@ -135,14 +137,14 @@ private:
private:
/// The Led-string specification
const LedString mLedString;
const LedString _ledString;
/// Flag the enables(true)/disabled(false) blackborder detector
bool _enableBlackBorderRemoval;
const bool _enableBlackBorderRemoval;
/// The processor for black border detection
hyperion::BlackBorderProcessor * _borderProcessor;
/// The mapping of image-pixels to leds
hyperion::ImageToLedsMap* mImageToLeds;
hyperion::ImageToLedsMap* _imageToLeds;
};

View File

@@ -30,8 +30,10 @@ public:
/// Initialises this factory with the given led-configuration
///
/// @param[in] ledString The led configuration
/// @param[in] enableBlackBorderDetector Flag indicating if the blacborder detector should be enabled
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
///
void init(const LedString& ledString, bool enableBlackBorderDetector);
void init(const LedString& ledString, bool enableBlackBorderDetector, double blackborderThreshold);
///
/// Creates a new ImageProcessor. The onwership of the processor is transferred to the caller.
@@ -46,4 +48,7 @@ private:
/// Flag indicating if the black border detector should be used
bool _enableBlackBorderDetector;
/// Threshold for the blackborder detector [0 .. 255]
uint8_t _blackborderThreshold;
};