mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:17:40 +02:00
Clean-up.
This commit is contained in:
parent
689957c80b
commit
80b646f48c
5 changed files with 17 additions and 17 deletions
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
ITKImageComparer::ITKImageComparer() {
|
ITKImageComparer::ITKImageComparer() {
|
||||||
// These are smart pointers that do not need to be deleted
|
// These are smart pointers that do not need to be deleted
|
||||||
actualImageReader = ReaderType::New();
|
resultImageReader = ReaderType::New();
|
||||||
expectedImageReader = ReaderType::New();
|
expectedImageReader = ReaderType::New();
|
||||||
}
|
}
|
||||||
|
|
||||||
float ITKImageComparer::compareImages(QString actualImageFilename, QString expectedImageFilename) const {
|
float ITKImageComparer::compareImages(QString resultImageFilename, QString expectedImageFilename) const {
|
||||||
actualImageReader->SetFileName(actualImageFilename.toStdString().c_str());
|
resultImageReader->SetFileName(resultImageFilename.toStdString().c_str());
|
||||||
expectedImageReader->SetFileName(expectedImageFilename.toStdString().c_str());
|
expectedImageReader->SetFileName(expectedImageFilename.toStdString().c_str());
|
||||||
|
|
||||||
// Images are converted to monochrome for comparison
|
// Images are converted to monochrome for comparison
|
||||||
|
@ -29,10 +29,10 @@ float ITKImageComparer::compareImages(QString actualImageFilename, QString expec
|
||||||
using MonochromeImageType = itk::Image<MonochromePixelType, Dimension>;
|
using MonochromeImageType = itk::Image<MonochromePixelType, Dimension>;
|
||||||
using FilterType = itk::RGBToLuminanceImageFilter<RGBImageType, MonochromeImageType>;
|
using FilterType = itk::RGBToLuminanceImageFilter<RGBImageType, MonochromeImageType>;
|
||||||
|
|
||||||
FilterType::Pointer actualImageToMonochrome = FilterType::New();
|
FilterType::Pointer resultImageToMonochrome = FilterType::New();
|
||||||
FilterType::Pointer expectedImageToMonochrome = FilterType::New();
|
FilterType::Pointer expectedImageToMonochrome = FilterType::New();
|
||||||
|
|
||||||
actualImageToMonochrome->SetInput(actualImageReader->GetOutput());
|
resultImageToMonochrome->SetInput(resultImageReader->GetOutput());
|
||||||
expectedImageToMonochrome->SetInput(expectedImageReader->GetOutput());
|
expectedImageToMonochrome->SetInput(expectedImageReader->GetOutput());
|
||||||
|
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
class ITKImageComparer : public ImageComparer {
|
class ITKImageComparer : public ImageComparer {
|
||||||
public:
|
public:
|
||||||
ITKImageComparer();
|
ITKImageComparer();
|
||||||
float compareImages(QString actualImageFilename, QString expectedImageFilename) const final;
|
float compareImages(QString resultImageFilename, QString expectedImageFilename) const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const unsigned int Dimension{ 2 };
|
static const unsigned int Dimension{ 2 };
|
||||||
|
@ -27,7 +27,7 @@ private:
|
||||||
|
|
||||||
using ReaderType = itk::ImageFileReader<RGBImageType>;
|
using ReaderType = itk::ImageFileReader<RGBImageType>;
|
||||||
|
|
||||||
ReaderType::Pointer actualImageReader;
|
ReaderType::Pointer resultImageReader;
|
||||||
ReaderType::Pointer expectedImageReader;
|
ReaderType::Pointer expectedImageReader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
class ImageComparer {
|
class ImageComparer {
|
||||||
public:
|
public:
|
||||||
virtual float compareImages(QString actualImageFilename, QString expectedImageFilename) const = 0;
|
virtual float compareImages(QString resultImageFilename, QString expectedImageFilename) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ImageComparer_h
|
#endif // hifi_ImageComparer_h
|
||||||
|
|
|
@ -46,21 +46,21 @@ void Test::evaluateTests() {
|
||||||
// Separate images into two lists. The first is the expected images, the second is the test results
|
// Separate images into two lists. The first is the expected images, the second is the test results
|
||||||
// Images that are in the wrong format are ignored.
|
// Images that are in the wrong format are ignored.
|
||||||
QStringList expectedImages;
|
QStringList expectedImages;
|
||||||
QStringList actualImages;
|
QStringList resultImages;
|
||||||
foreach(QString currentFilename, sortedImageFilenames) {
|
foreach(QString currentFilename, sortedImageFilenames) {
|
||||||
QString fullCurrentFilename = pathToImageDirectory + "/" + currentFilename;
|
QString fullCurrentFilename = pathToImageDirectory + "/" + currentFilename;
|
||||||
if (isInExpectedImageFilenameFormat(currentFilename)) {
|
if (isInExpectedImageFilenameFormat(currentFilename)) {
|
||||||
expectedImages << fullCurrentFilename;
|
expectedImages << fullCurrentFilename;
|
||||||
} else if (isInSnapshotFilenameFormat(currentFilename)) {
|
} else if (isInSnapshotFilenameFormat(currentFilename)) {
|
||||||
actualImages << fullCurrentFilename;
|
resultImages << fullCurrentFilename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The number of images in each list should be identical
|
// The number of images in each list should be identical
|
||||||
if (expectedImages.length() != actualImages.length()) {
|
if (expectedImages.length() != resultImages.length()) {
|
||||||
messageBox.critical(0,
|
messageBox.critical(0,
|
||||||
"Test failed",
|
"Test failed",
|
||||||
"Found " + QString::number(actualImages.length()) + " images in directory" +
|
"Found " + QString::number(resultImages.length()) + " images in directory" +
|
||||||
"\nExpected to find " + QString::number(expectedImages.length()) + " images");
|
"\nExpected to find " + QString::number(expectedImages.length()) + " images");
|
||||||
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -72,13 +72,13 @@ void Test::evaluateTests() {
|
||||||
bool success{ true };
|
bool success{ true };
|
||||||
bool keepOn{ true };
|
bool keepOn{ true };
|
||||||
for (int i = 0; keepOn && i < expectedImages.length(); ++i) {
|
for (int i = 0; keepOn && i < expectedImages.length(); ++i) {
|
||||||
float error = itkImageComparer.compareImages(actualImages[i], expectedImages[i]);
|
float error = itkImageComparer.compareImages(resultImages[i], expectedImages[i]);
|
||||||
if (error > THRESHOLD) {
|
if (error > THRESHOLD) {
|
||||||
mismatchWindow.setTestFailure(TestFailure{
|
mismatchWindow.setTestFailure(TestFailure{
|
||||||
error, // value of the error (float)
|
error, // value of the error (float)
|
||||||
expectedImages[i].left(expectedImages[i].lastIndexOf("/") + 1), // path to the test (including trailing /
|
expectedImages[i].left(expectedImages[i].lastIndexOf("/") + 1), // path to the test (including trailing /
|
||||||
QFileInfo(expectedImages[i].toStdString().c_str()).fileName(), // filename of expected image
|
QFileInfo(expectedImages[i].toStdString().c_str()).fileName(), // filename of expected image
|
||||||
QFileInfo(actualImages[i].toStdString().c_str()).fileName() // filename of result image
|
QFileInfo(resultImages[i].toStdString().c_str()).fileName() // filename of result image
|
||||||
});
|
});
|
||||||
|
|
||||||
mismatchWindow.exec();
|
mismatchWindow.exec();
|
||||||
|
|
|
@ -17,7 +17,7 @@ MismatchWindow::MismatchWindow(QWidget *parent)
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
expectedImage->setScaledContents(true);
|
expectedImage->setScaledContents(true);
|
||||||
actualImage->setScaledContents(true);
|
resultImage->setScaledContents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MismatchWindow::setTestFailure(TestFailure testFailure) {
|
void MismatchWindow::setTestFailure(TestFailure testFailure) {
|
||||||
|
@ -28,8 +28,8 @@ void MismatchWindow::setTestFailure(TestFailure testFailure) {
|
||||||
expectedFilename->setText(testFailure._expectedImageFilename);
|
expectedFilename->setText(testFailure._expectedImageFilename);
|
||||||
expectedImage->setPixmap(QPixmap(testFailure._pathname + testFailure._expectedImageFilename));
|
expectedImage->setPixmap(QPixmap(testFailure._pathname + testFailure._expectedImageFilename));
|
||||||
|
|
||||||
actualFilename->setText(testFailure._actualImageFilename);
|
resultFilename->setText(testFailure._actualImageFilename);
|
||||||
actualImage->setPixmap(QPixmap(testFailure._pathname + testFailure._actualImageFilename));
|
resultImage->setPixmap(QPixmap(testFailure._pathname + testFailure._actualImageFilename));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MismatchWindow::on_passTestButton_clicked()
|
void MismatchWindow::on_passTestButton_clicked()
|
||||||
|
|
Loading…
Reference in a new issue