mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:16:58 +02:00
Updated AutoTester.
This commit is contained in:
parent
20d2128a10
commit
ddea1c64bc
3 changed files with 10 additions and 4 deletions
|
@ -15,6 +15,12 @@
|
||||||
// Computes SSIM - see https://en.wikipedia.org/wiki/Structural_similarity
|
// Computes SSIM - see https://en.wikipedia.org/wiki/Structural_similarity
|
||||||
// The value is computed for the luminance component and the average value is returned
|
// The value is computed for the luminance component and the average value is returned
|
||||||
double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const {
|
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 int L = 255; // (2^number of bits per pixel) - 1
|
||||||
const double K1 { 0.01 };
|
const double K1 { 0.01 };
|
||||||
const double K2 { 0.03 };
|
const double K2 { 0.03 };
|
||||||
|
@ -54,8 +60,8 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) co
|
||||||
|
|
||||||
// Collect pixels into linear arrays
|
// Collect pixels into linear arrays
|
||||||
int i{ 0 };
|
int i{ 0 };
|
||||||
for (int xx = 0; xx < WIN_SIZE; ++xx) {
|
for (int xx = 0; xx < WIN_SIZE && x + xx < expectedImage.width(); ++xx) {
|
||||||
for (int yy = 0; yy < WIN_SIZE; ++yy) {
|
for (int yy = 0; yy < WIN_SIZE && y + yy < expectedImage.height(); ++yy) {
|
||||||
// Get pixels
|
// Get pixels
|
||||||
QRgb pixelP = expectedImage.pixel(QPoint(x + xx, y + yy));
|
QRgb pixelP = expectedImage.pixel(QPoint(x + xx, y + yy));
|
||||||
QRgb pixelQ = resultImage.pixel(QPoint(x + xx, y + yy));
|
QRgb pixelQ = resultImage.pixel(QPoint(x + xx, y + yy));
|
||||||
|
|
|
@ -63,7 +63,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar)
|
||||||
|
|
||||||
// Loop over both lists and compare each pair of images
|
// Loop over both lists and compare each pair of images
|
||||||
// Quit loop if user has aborted due to a failed test.
|
// 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 success{ true };
|
||||||
bool keepOn{ true };
|
bool keepOn{ true };
|
||||||
for (int i = 0; keepOn && i < expectedImagesFullFilenames.length(); ++i) {
|
for (int i = 0; keepOn && i < expectedImagesFullFilenames.length(); ++i) {
|
||||||
|
|
|
@ -129,7 +129,7 @@ void AutoTester::saveImage(int index) {
|
||||||
pixmap.loadFromData(downloaders[index]->downloadedData());
|
pixmap.loadFromData(downloaders[index]->downloadedData());
|
||||||
|
|
||||||
QImage image = pixmap.toImage();
|
QImage image = pixmap.toImage();
|
||||||
image = image.convertToFormat(QImage::Format_RGB32);
|
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
|
||||||
QString fullPathname = _directoryName + "/" + _filenames[index];
|
QString fullPathname = _directoryName + "/" + _filenames[index];
|
||||||
if (!image.save(fullPathname, 0, 100)) {
|
if (!image.save(fullPathname, 0, 100)) {
|
||||||
|
|
Loading…
Reference in a new issue