2013-08-21 22:44:17 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Local Hyperion includes
|
|
|
|
#include "BlackBorderDetector.h"
|
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
namespace hyperion
|
2013-08-21 22:44:17 +02:00
|
|
|
{
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// The BlackBorder processor is a wrapper around the black-border detector for keeping track of
|
|
|
|
/// detected borders and count of the type and size of detected borders.
|
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
class BlackBorderProcessor
|
|
|
|
{
|
|
|
|
public:
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Constructor for the BlackBorderProcessor
|
|
|
|
/// @param unknownFrameCnt The number of frames(images) that need to contain an unknown
|
|
|
|
/// border before the current border is set to unknown
|
|
|
|
/// @param borderFrameCnt The number of frames(images) that need to contain a vertical or
|
|
|
|
/// horizontal border becomes the current border
|
|
|
|
/// @param blurRemoveCnt The size to add to a horizontal or vertical border (because the
|
2013-10-27 09:25:02 +01:00
|
|
|
/// outer pixels is blurred (black and color combined due to image scaling))
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
BlackBorderProcessor(
|
|
|
|
const unsigned unknownFrameCnt,
|
|
|
|
const unsigned borderFrameCnt,
|
|
|
|
const unsigned blurRemoveCnt);
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Return the current (detected) border
|
|
|
|
/// @return The current border
|
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
BlackBorder getCurrentBorder() const;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Processes the image. This performs detecion of black-border on the given image and
|
|
|
|
/// updates the current border accordingly. If the current border is updated the method call
|
|
|
|
/// will return true else false
|
|
|
|
///
|
|
|
|
/// @param image The image to process
|
|
|
|
///
|
|
|
|
/// @return True if a different border was detected than the current else false
|
|
|
|
///
|
2013-11-11 10:00:37 +01:00
|
|
|
template <typename Pixel_T>
|
|
|
|
bool process(const Image<Pixel_T> & image)
|
|
|
|
{
|
|
|
|
// get the border for the single image
|
|
|
|
BlackBorder imageBorder = _detector.process(image);
|
|
|
|
// add blur to the border
|
|
|
|
if (imageBorder.horizontalSize > 0)
|
|
|
|
{
|
|
|
|
imageBorder.horizontalSize += _blurRemoveCnt;
|
|
|
|
}
|
|
|
|
if (imageBorder.verticalSize > 0)
|
|
|
|
{
|
|
|
|
imageBorder.verticalSize += _blurRemoveCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool borderUpdated = updateBorder(imageBorder);
|
|
|
|
return borderUpdated;
|
|
|
|
}
|
|
|
|
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
private:
|
2013-11-11 10:00:37 +01:00
|
|
|
///
|
|
|
|
/// Updates the current border based on the newly detected border. Returns true if the
|
|
|
|
/// current border has changed.
|
|
|
|
///
|
|
|
|
/// @param newDetectedBorder The newly detected border
|
|
|
|
/// @return True if the current border changed else false
|
|
|
|
///
|
|
|
|
bool updateBorder(const BlackBorder & newDetectedBorder);
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The number of unknown-borders detected before it becomes the current border
|
2013-08-23 07:08:44 +02:00
|
|
|
const unsigned _unknownSwitchCnt;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The number of horizontal/vertical borders detected before it becomes the current border
|
2013-08-23 07:08:44 +02:00
|
|
|
const unsigned _borderSwitchCnt;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The number of pixels to increase a detected border for removing blury pixels
|
2013-08-23 07:08:44 +02:00
|
|
|
unsigned _blurRemoveCnt;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The blackborder detector
|
2013-08-23 07:08:44 +02:00
|
|
|
BlackBorderDetector _detector;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The current detected border
|
2013-08-23 07:08:44 +02:00
|
|
|
BlackBorder _currentBorder;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The border detected in the previous frame
|
2013-08-23 18:24:10 +02:00
|
|
|
BlackBorder _previousDetectedBorder;
|
2013-08-21 22:44:17 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The number of frame the previous detected border matched the incomming border
|
2013-08-23 07:08:44 +02:00
|
|
|
unsigned _consistentCnt;
|
|
|
|
};
|
|
|
|
} // end namespace hyperion
|