From ddea1c64bc3b0cd9d5b5f08412de9328b7c10a86 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 25 May 2018 17:37:31 -0700 Subject: [PATCH] Updated AutoTester. --- tools/auto-tester/src/ImageComparer.cpp | 10 ++++++++-- tools/auto-tester/src/Test.cpp | 2 +- tools/auto-tester/src/ui/AutoTester.cpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/auto-tester/src/ImageComparer.cpp b/tools/auto-tester/src/ImageComparer.cpp index eb892484a2..3afdeaec0a 100644 --- a/tools/auto-tester/src/ImageComparer.cpp +++ b/tools/auto-tester/src/ImageComparer.cpp @@ -15,6 +15,12 @@ // Computes SSIM - see https://en.wikipedia.org/wiki/Structural_similarity // The value is computed for the luminance component and the average value is returned double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const { + // Make sure the image is 8 bits per colour + QImage::Format format = expectedImage.format(); + if (format != QImage::Format::Format_ARGB32) { + throw -1; + } + const int L = 255; // (2^number of bits per pixel) - 1 const double K1 { 0.01 }; const double K2 { 0.03 }; @@ -54,8 +60,8 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co // Collect pixels into linear arrays int i{ 0 }; - for (int xx = 0; xx < WIN_SIZE; ++xx) { - for (int yy = 0; yy < WIN_SIZE; ++yy) { + for (int xx = 0; xx < WIN_SIZE && x + xx < expectedImage.width(); ++xx) { + for (int yy = 0; yy < WIN_SIZE && y + yy < expectedImage.height(); ++yy) { // Get pixels QRgb pixelP = expectedImage.pixel(QPoint(x + xx, y + yy)); QRgb pixelQ = resultImage.pixel(QPoint(x + xx, y + yy)); diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 5281f84d7a..5c69715d2e 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -63,7 +63,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) // Loop over both lists and compare each pair of images // Quit loop if user has aborted due to a failed test. - const double THRESHOLD { 0.99 }; + const double THRESHOLD { 0.9995 }; bool success{ true }; bool keepOn{ true }; for (int i = 0; keepOn && i < expectedImagesFullFilenames.length(); ++i) { diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 1edd7f6f28..14329e36c2 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -129,7 +129,7 @@ void AutoTester::saveImage(int index) { pixmap.loadFromData(downloaders[index]->downloadedData()); QImage image = pixmap.toImage(); - image = image.convertToFormat(QImage::Format_RGB32); + image = image.convertToFormat(QImage::Format_ARGB32); QString fullPathname = _directoryName + "/" + _filenames[index]; if (!image.save(fullPathname, 0, 100)) {