Added first use of ITK.

This commit is contained in:
nissim.hadar 2017-11-19 13:48:37 -08:00
parent 7b2fed6db2
commit 861c33d5a9
3 changed files with 33 additions and 42 deletions

View file

@ -6,45 +6,35 @@ SET(CMAKE_AUTOUIC ON)
SET(CMAKE_AUTOMOC ON)
setup_hifi_project(Core Widgets)
link_hifi_libraries()
# Qt includes
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
set(QT_LIBRARIES Qt5::Core Qt5::Widgets)
# Find all sources files
file (GLOB_RECURSE SOURCES src/*.cpp)
file (GLOB_RECURSE MOC_HEADERS src/*.h)
file (GLOB_RECURSE UIS src/ui/*.ui)
# ITK includes
set (ITK_DIR ENV{ITK_DIR})
find_package (ITK REQUIRED)
include (${ITK_USE_FILE})
# Find all sources files
file (GLOB_RECURSE SOURCES src/*.cpp)
file (GLOB_RECURSE HEADERS src/*.h)
file (GLOB_RECURSE UIS src/ui/*.ui)
if (WIN32)
# Do not show Console
set_property(TARGET auto-tester PROPERTY WIN32_EXECUTABLE true)
add_executable(PROJECT_NAME WIN32 ${SOURCES} ${MOC_SRCS} ${UI_HEADERS})
else()
add_executable(PROJECT_NAME ${SOURCES} ${MOC_SRCS} ${RES_SOURCES} ${UI_HEADERS})
endif()
add_executable(PROJECT_NAME ${SOURCES} ${HEADERS} ${UIS})
target_link_libraries(PROJECT_NAME ${QT_LIBRARIES} ${ITK_LIBRARIES})
set(QT_LIBRARIES Qt5::Core Qt5::Widgets)
target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES} ${ITK_LIBRARIES})
# Copy required dll's.
# Note that the two ImageMagick files are copied twice. This is to allow the tester to run from VS as well as
# directly from the executable.
add_custom_command(
TARGET auto-tester
POST_BUILD
add_custom_command(TARGET auto-tester POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:auto-tester>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:auto-tester>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:auto-tester>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ImageMagick/magick.exe $<TARGET_FILE_DIR:auto-tester>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ImageMagick/magic.xml $<TARGET_FILE_DIR:auto-tester>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ImageMagick/magick.exe $<TARGET_FILE_DIR:auto-tester>/..
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/ImageMagick/magic.xml $<TARGET_FILE_DIR:auto-tester>/..
)
)

View file

@ -32,8 +32,6 @@
#include <assert.h>
#include <QtCore/QTextStream>
#include <itkImage.h>
Test::Test() {
snapshotFilenameFormat = QRegularExpression("hifi-snap-by-.+-on-\\d\\d\\d\\d-\\d\\d-\\d\\d_\\d\\d-\\d\\d-\\d\\d.jpg");
@ -74,26 +72,26 @@ void Test::evaluateTests() {
bool success{ true };
bool keepOn{ true };
for (int i = 0; keepOn && i < expectedImages.length(); ++i) {
QString diffFilename = "HIFI_AutoTest_diff.txt";
QString command = "magick.exe compare -metric MAE " + expectedImages[i] + " " + resultImages[i] + " null: 2>" + diffFilename;
if (system(command.toStdString().c_str()) == -1) {
// command has failed
messageBox.critical(0, "Aborting!", "Error executing magick.exe");
exit(-1);
}
////QString diffFilename = "HIFI_AutoTest_diff.txt";
////QString command = "magick.exe compare -metric MAE " + expectedImages[i] + " " + resultImages[i] + " null: 2>" + diffFilename;
////
////if (system(command.toStdString().c_str()) == -1) {
//// // command has failed
//// messageBox.critical(0, "Aborting!", "Error executing magick.exe");
//// exit(-1);
////}
QFile file(diffFilename);
if (!file.open(QIODevice::ReadOnly)) {
messageBox.critical(0, "Error", file.errorString());
}
// First value on line is the comparison result
QTextStream in(&file);
QString line = in.readLine();
QStringList tokens = line.split(' ');
float error = tokens[0].toFloat();
////QFile file(diffFilename);
////if (!file.open(QIODevice::ReadOnly)) {
//// messageBox.critical(0, "Error", file.errorString());
////}
////// First value on line is the comparison result
////QTextStream in(&file);
////QString line = in.readLine();
////QStringList tokens = line.split(' ');
////float error = tokens[0].toFloat();
float error = itkImageComparer.compareImages(expectedImages[i], resultImages[i]);
if (error > THRESHOLD) {
mismatchWindow.setTestFailure(TestFailure{
error, // value of the error (float)

View file

@ -16,6 +16,7 @@
#include <QtWidgets/QMessageBox>
#include <QtCore/QRegularExpression>
#include "ITKImageComparer.h"
#include "ui/MismatchWindow.h"
class Test {
@ -41,6 +42,8 @@ private:
QRegularExpression expectedImageFilenameFormat;
MismatchWindow mismatchWindow;
ITKImageComparer itkImageComparer;
};
#endif // hifi_test_h