Rewrite of black border detector to fix problems with overscan and xbmc video calibration settings

Former-commit-id: ed6dd4e6872ea69d682096a82e108a3f7e7ca4ae
This commit is contained in:
johan
2013-10-27 09:25:02 +01:00
parent 8a9c052e8d
commit a3e59f0243
7 changed files with 134 additions and 167 deletions

View File

@@ -45,7 +45,7 @@ int TC_NO_BORDER()
{
RgbImage image = createImage(64, 64, 0, 0);
BlackBorder border = detector.process(image);
if (border.type != BlackBorder::none)
if (border.unknown != false && border.horizontalSize != 0 && border.verticalSize != 0)
{
std::cerr << "Failed to correctly detect no border" << std::endl;
result = -1;
@@ -64,7 +64,7 @@ int TC_TOP_BORDER()
{
RgbImage image = createImage(64, 64, 12, 0);
BlackBorder border = detector.process(image);
if (border.type != BlackBorder::horizontal || border.size != 12)
if (border.unknown != false && border.horizontalSize != 12 && border.verticalSize != 0)
{
std::cerr << "Failed to correctly detect horizontal border with correct size" << std::endl;
result = -1;
@@ -83,7 +83,7 @@ int TC_LEFT_BORDER()
{
RgbImage image = createImage(64, 64, 0, 12);
BlackBorder border = detector.process(image);
if (border.type != BlackBorder::vertical || border.size != 12)
if (border.unknown != false && border.horizontalSize != 0 && border.verticalSize != 12)
{
std::cerr << "Failed to detected vertical border with correct size" << std::endl;
result = -1;
@@ -93,6 +93,24 @@ int TC_LEFT_BORDER()
return result;
}
int TC_DUAL_BORDER()
{
int result = 0;
BlackBorderDetector detector;
{
RgbImage image = createImage(64, 64, 12, 12);
BlackBorder border = detector.process(image);
if (border.unknown != false && border.horizontalSize != 12 && border.verticalSize != 12)
{
std::cerr << "Failed to detected two-sided border" << std::endl;
result = -1;
}
}
return result;
}
int TC_UNKNOWN_BORDER()
{
int result = 0;
@@ -100,9 +118,9 @@ int TC_UNKNOWN_BORDER()
BlackBorderDetector detector;
{
RgbImage image = createImage(64, 64, 12, 12);
RgbImage image = createImage(64, 64, 30, 30);
BlackBorder border = detector.process(image);
if (border.type != BlackBorder::unknown)
if (border.unknown != true)
{
std::cerr << "Failed to detected unknown border" << std::endl;
result = -1;
@@ -116,6 +134,7 @@ int main()
TC_NO_BORDER();
TC_TOP_BORDER();
TC_LEFT_BORDER();
TC_DUAL_BORDER();
TC_UNKNOWN_BORDER();
return 0;

View File

@@ -70,10 +70,11 @@ int main()
}
}
}
// Verify that the border is indeed
if (processor.getCurrentBorder().type != BlackBorder::none)
if (processor.getCurrentBorder().unknown != false || processor.getCurrentBorder().horizontalSize != 0 || processor.getCurrentBorder().verticalSize != 0)
{
std::cerr << "Incorrectlty identified 'no border' (" << processor.getCurrentBorder().type << " != " << BlackBorder::none << ")" << std::endl;
std::cerr << "Incorrectlty identified 'no border'" << std::endl;
exit(EXIT_FAILURE);
}
@@ -99,14 +100,16 @@ int main()
}
}
}
if (processor.getCurrentBorder().type != BlackBorder::horizontal || processor.getCurrentBorder().size != borderSize)
if (processor.getCurrentBorder().unknown != false || processor.getCurrentBorder().horizontalSize != borderSize || processor.getCurrentBorder().verticalSize != 0)
{
std::cerr << "Incorrectlty found 'horizontal border' (" << processor.getCurrentBorder().type << " != " << BlackBorder::horizontal << ")" << std::endl;
std::cerr << "Incorrectlty found 'horizontal border' (" << processor.getCurrentBorder().unknown << "," << processor.getCurrentBorder().horizontalSize << "," << processor.getCurrentBorder().verticalSize << ")" << std::endl;
exit(EXIT_FAILURE);
}
// Switch back (in one shot) to no border
if (!processor.process(noBorderImage) || (processor.getCurrentBorder().type != BlackBorder::none))
if (!processor.process(noBorderImage) || (processor.getCurrentBorder().unknown != false || processor.getCurrentBorder().horizontalSize != 0 || processor.getCurrentBorder().verticalSize != 0))
{
std::cerr << "Failed to switch back to 'no border' with one image" << std::endl;
exit(EXIT_FAILURE);
@@ -133,9 +136,10 @@ int main()
}
}
}
if (processor.getCurrentBorder().type != BlackBorder::vertical || processor.getCurrentBorder().size != borderSize)
if (processor.getCurrentBorder().unknown != false || processor.getCurrentBorder().horizontalSize != 0 || processor.getCurrentBorder().verticalSize != borderSize)
{
std::cerr << "Incorrectlty found 'vertical border' (" << processor.getCurrentBorder().type << " != " << BlackBorder::horizontal << ")" << std::endl;
std::cerr << "Incorrectlty found 'vertical border'" << std::endl;
exit(EXIT_FAILURE);
}