Commit b91ea687 authored by Edwin Carlinet's avatar Edwin Carlinet

Merge branch 'development/minor_fixes' into 'dev'

Development/minor fixes

See merge request !14
parents 582356c0 98ee90aa
......@@ -3,6 +3,7 @@
/doc/build
/doc/html
/doc/doxyxml
/doc/source/images/*.png
.vscode
.vs
.idea
......
......@@ -4,7 +4,7 @@ project(MILENA)
# Add FindTBB directory to CMake's module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
find_package(Boost 1.42 COMPONENTS program_options unit_test_framework REQUIRED)
find_package(Boost 1.42 COMPONENTS program_options REQUIRED)
find_package(FreeImage REQUIRED)
find_package(TBB)
find_package(Qt4)
......@@ -12,9 +12,23 @@ find_package(Qt4)
# CONFIGURATION OPTIONS
set(MLN_USE_TBB YES CACHE BOOL "Set to NO to disable use of TBB and parallelization")
# Proper project creation
set(MLN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
if(MSVC OR APPLE)
#dummy static project not linked anywere needed so that a vcxproj is generated with the sources in the solution
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
file(GLOB_RECURSE MLN_SOURCES "${MLN_INCLUDE_DIR}/*.hpp")
add_library(Mln_srcs EXCLUDE_FROM_ALL STATIC ${MLN_SOURCES})
set_target_properties(Mln_srcs PROPERTIES LINKER_LANGUAGE CXX)
# target_compile_features(Mln_srcs PUBLIC cxx_std_14)
target_include_directories(Mln_srcs PUBLIC ${MLN_INCLUDE_DIR})
source_group(TREE ${MLN_INCLUDE_DIR} FILES ${MLN_SOURCES})
endif()
add_library(Mln INTERFACE)
# target_compile_features(Mln INTERFACE cxx_std_14)
target_include_directories(Mln INTERFACE ${MLN_INCLUDE_DIR})
# add source directory to find mln path
include_directories("${PROJECT_SOURCE_DIR}")
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
include_directories(${FreeImage_INCLUDE_DIRS})
link_directories(${FreeImage_LIBRARY_DIR})
......@@ -38,7 +52,7 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall -std=c++14 -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX " )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W4 /wd4244 /wd4127 /permissive- /std:c++14" )
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif()
......
......@@ -30,6 +30,7 @@ set(src_standalone
set_source_files_properties(${src_standalone} PROPERTIES COMPILE_FLAGS ${STANDALONE_COMPILE_FLAGS})
link_libraries(benchmark::benchmark)
link_libraries(Mln)
#link_libraries(-lbenchmark)
add_executable(BMErosion BMErosion.cpp BMErosion_main.cpp)
......
......@@ -11,15 +11,14 @@ add_executable(lab2rgb lab2rgb.cpp)
set_target_properties(dilate-cli PROPERTIES OUTPUT_NAME dilate)
target_link_libraries(area_close ${FreeImage_LIBRARIES})
target_link_libraries(area_fast_close ${FreeImage_LIBRARIES})
target_link_libraries(decompose_channels ${FreeImage_LIBRARIES})
target_link_libraries(recompose_channels ${FreeImage_LIBRARIES})
target_link_libraries(grain_filter ${FreeImage_LIBRARIES})
target_link_libraries(closing_by_reconstruction ${FreeImage_LIBRARIES})
target_link_libraries(dilate-cli ${FreeImage_LIBRARIES})
target_link_libraries(grain_filter ${FreeImage_LIBRARIES})
target_link_libraries(leveling ${FreeImage_LIBRARIES})
target_link_libraries(rgb2lab ${FreeImage_LIBRARIES})
target_link_libraries(lab2rgb ${FreeImage_LIBRARIES})
target_link_libraries(area_close ${FreeImage_LIBRARIES} Mln)
target_link_libraries(area_fast_close ${FreeImage_LIBRARIES} Mln)
target_link_libraries(decompose_channels ${FreeImage_LIBRARIES} Mln)
target_link_libraries(recompose_channels ${FreeImage_LIBRARIES} Mln)
target_link_libraries(grain_filter ${FreeImage_LIBRARIES} Mln)
target_link_libraries(closing_by_reconstruction ${FreeImage_LIBRARIES} Mln)
target_link_libraries(dilate-cli ${FreeImage_LIBRARIES} Mln)
target_link_libraries(leveling ${FreeImage_LIBRARIES} Mln)
target_link_libraries(rgb2lab ${FreeImage_LIBRARIES} Mln)
target_link_libraries(lab2rgb ${FreeImage_LIBRARIES} Mln)
......@@ -35,6 +35,7 @@ add_custom_target(build-images
DEPENDS "${DOCUMENTATION_IMAGES}")
link_libraries(${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE} ${FreeImage_LIBRARY})
link_libraries(Mln)
add_executable(erosion-cli erosion-cli.cpp)
add_executable(staff_lines staff_lines.cpp)
......
......@@ -774,7 +774,7 @@ namespace mln
q.rem += static_cast<int>(m_index_strides[i]);
q.quot -= 1;
}
p[i] += q.quot;
p[i] += static_cast<short>(q.quot);
diff = q.rem;
}
......
......@@ -34,7 +34,7 @@ namespace mln
line2d_iterator(const point2d& pbegin, const point2d& pend) : m_pbegin(pbegin), m_pend(pend)
{
point2d dp = pend - pbegin;
point2d dp = m_pend - m_pbegin;
m_octhan = false;
if (std::abs(dp[1]) < std::abs(dp[0]))
{
......
......@@ -26,15 +26,20 @@ include_directories(${GTEST_INCLUDE_DIRS})
# Executable: The name of the executable (default: ${Prefix}${TestName})
# Sources: The source files to compile (default: ${Prefix}${TestName}.cpp)
macro(add_core_test Executable)
set(Sources ${ARGN})
add_executable(${Executable} ${Sources})
add_test(NAME ${Executable} COMMAND ${Executable} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
if (WIN32)
target_link_libraries(${Executable} ${GTEST_BOTH_LIBRARIES})
else (WIN32)
target_link_libraries(${Executable} ${GTEST_BOTH_LIBRARIES} pthread)
endif (WIN32)
add_dependencies(check ${Executable})
set(Sources ${ARGN})
add_executable(${Executable} ${Sources})
add_test(NAME ${Executable} COMMAND ${Executable} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
target_link_libraries(${Executable} Mln)
if (WIN32)
target_link_libraries(${Executable} ${GTEST_BOTH_LIBRARIES})
else (WIN32)
target_link_libraries(${Executable} ${GTEST_BOTH_LIBRARIES} pthread)
endif (WIN32)
add_dependencies(check ${Executable})
endmacro(add_core_test)
add_subdirectory(accu)
......
......@@ -12,15 +12,15 @@ TEST(Accu, Sum)
acc.take(12);
acc.take("blabla");
ASSERT_EQ(extractor::count(acc), 2);
ASSERT_EQ(extractor::count(acc), 2u);
acc.untake(13);
ASSERT_EQ(extractor::count(acc), 1);
ASSERT_EQ(extractor::count(acc), 1u);
acc2.take(69);
acc.take(69);
acc2.take(acc);
ASSERT_EQ(extractor::count(acc2), 3);
ASSERT_EQ(extractor::count(acc2), 3u);
}
......@@ -13,23 +13,23 @@ TEST(Accu, Mean)
acc.take(5);
acc.take(15);
ASSERT_EQ(extractor::sum(acc), 20);
ASSERT_EQ(extractor::count(acc), 2);
ASSERT_EQ(extractor::mean(acc), 10);
ASSERT_EQ(extractor::sum(acc), 20u);
ASSERT_EQ(extractor::count(acc), 2u);
ASSERT_EQ(extractor::mean(acc), 10u);
acc.untake(10);
ASSERT_EQ(extractor::sum(acc), 10);
ASSERT_EQ(extractor::count(acc), 1);
ASSERT_EQ(extractor::mean(acc), 10);
ASSERT_EQ(extractor::sum(acc), 10u);
ASSERT_EQ(extractor::count(acc), 1u);
ASSERT_EQ(extractor::mean(acc), 10u);
acc2.take(20);
acc2.take(40);
acc2.take(acc);
ASSERT_EQ(extractor::sum(acc2), 70);
ASSERT_EQ(extractor::count(acc2), 3);
ASSERT_EQ(extractor::mean(acc2), 23);
ASSERT_EQ(extractor::sum(acc2), 70u);
ASSERT_EQ(extractor::count(acc2), 3u);
ASSERT_EQ(extractor::mean(acc2), 23u);
}
TEST(Accu, Mean_vec)
......@@ -44,12 +44,12 @@ TEST(Accu, Mean_vec)
acc.take(rgb8{(uint8)255, (uint8)5, (uint8)255});
ASSERT_EQ(extractor::sum(acc), (rgb<int>{260, 10, 510}));
ASSERT_EQ(extractor::count(acc), 2);
ASSERT_EQ(extractor::count(acc), 2u);
ASSERT_EQ(extractor::mean(acc), (rgb8{(uint8)130, (uint8)5, (uint8)255}));
acc.untake(rgb8{(uint8)10, (uint8)10, (uint8)10});
ASSERT_EQ(extractor::sum(acc), (rgb<int>{250, 0, 500}));
ASSERT_EQ(extractor::count(acc), 1);
ASSERT_EQ(extractor::count(acc), 1u);
ASSERT_EQ(extractor::mean(acc), (rgb<int>{250, 0, 500}));
}
......@@ -12,14 +12,14 @@ TEST(Accu, Sum)
acc.take(12);
acc.take(13);
ASSERT_EQ(extractor::sum(acc), 25);
ASSERT_EQ(extractor::sum(acc), 25u);
acc.untake(10);
ASSERT_EQ(extractor::sum(acc), 15);
ASSERT_EQ(extractor::sum(acc), 15u);
acc2.take(69);
acc2.take(acc);
ASSERT_EQ(extractor::sum(acc2), 84);
ASSERT_EQ(extractor::sum(acc2), 84u);
}
......@@ -11,7 +11,7 @@ struct iterator_test
{
image2d<int> ima;
std::vector<int> values;
std::vector<int> indexes;
std::vector<unsigned> indexes;
void test_forward_viter()
{
......
......@@ -99,8 +99,6 @@ TEST(Core, Image2d_WhereOperator)
auto f4 = where(x > 12, (uint8)0, (uint8)1); // RValue image + Scalar + Scalar
ASSERT_TRUE(all(f1 >= 12));
// MSVC : uint8&, clang/gcc : const uint8&
ASSERT_TRUE((std::is_same<mln_reference(decltype(f1)), const uint8&>() ||
std::is_same<mln_reference(decltype(f1)), uint8&>()));
ASSERT_TRUE((std::is_same<mln_reference(decltype(f1)), const uint8&>()));
ASSERT_TRUE((std::is_same<mln_reference(decltype(f2)), uint8&>()));
}
......@@ -25,5 +25,5 @@ TEST(Core, range_filter)
ASSERT_TRUE(x.has(point2d{1, 1}));
ASSERT_TRUE(not x.has(point2d{0, 1}));
ASSERT_TRUE(not x.has(point2d{1, 0}));
ASSERT_EQ(sz, 33);
ASSERT_EQ(sz, 33u);
}
......@@ -12,7 +12,7 @@ TEST(Core, stdrange_compatibility)
std::array<int, 4> x = {{2, 5, 15, 22}};
ASSERT_EQ(rng::size(x), 4);
ASSERT_EQ(rng::size(x), 4u);
{
int i = 0;
......
......@@ -14,7 +14,7 @@ TEST(Core, ziprange)
std::array<int, 4> x{{2, 5, 15, 22}};
std::array<int, 4> y{{-2, -5, -15, -22}};
ASSERT_EQ(rng::size(x), 4);
ASSERT_EQ(rng::size(x), 4u);
auto z = rng::zip(x, y);
......
......@@ -15,7 +15,7 @@ TEST(Value, Integers)
Int<14> z = 12;
y += z;
++y;
ASSERT_EQ(y, 31);
ASSERT_EQ(y, 31u);
Int<7> zz = x + z;
ASSERT_EQ(zz, 25);
......
......@@ -52,7 +52,7 @@ TEST(Graph, graph_iteration)
box2d b({-2, -3}, {3, 4});
mln::graph::undirected_graph_image2d<char, float, c4_t> g(b, c4);
unsigned nv = 0, ne = 0;
int nv = 0, ne = 0;
mln_foreach (point2d p, g.vertices())
g.vertex(p) = 'a' + (nv++ % 26);
......
......@@ -17,7 +17,7 @@ TEST(GraphCut, graph_iteration)
typedef mln::graphcut::internal::graphcut_graph_t<char, float, c4_t> graph_t;
graph_t g(b, c4);
unsigned nv = 0, ne = 0;
int nv = 0, ne = 0;
mln_foreach (point2d p, g.vertices())
{
......
......@@ -19,7 +19,7 @@ TEST(Labeling, blobs_fast)
image2d<uint8> lbl;
unsigned nlabel;
std::tie(lbl, nlabel) = labeling::blobs(mask, c4, uint8());
ASSERT_EQ(nlabel, 13);
ASSERT_EQ(nlabel, 13u);
}
TEST(Labeling, blobs_custom)
......@@ -33,8 +33,8 @@ TEST(Labeling, blobs_custom)
unsigned nlabel;
std::tie(lbl, nlabel) = labeling::blobs(ima % 2 == 0, c4, uint8());
ASSERT_EQ(nlabel, 13);
ASSERT_EQ(nlabel, 13u);
std::tie(lbl, nlabel) = labeling::blobs(ima % 2 == 0, c8, uint8());
ASSERT_EQ(nlabel, 1);
ASSERT_EQ(nlabel, 1u);
}
......@@ -78,7 +78,7 @@ TEST(Morpho, component_tree_forward_iteration)
std::cout << y << ",";
std::cout << std::endl;
}
ASSERT_EQ(n, 7);
ASSERT_EQ(n, 7u);
}
TEST(Morpho, component_tree_backward_iteration)
......@@ -104,7 +104,7 @@ TEST(Morpho, component_tree_backward_iteration)
mln_reverse_foreach(auto y, x.pset()) std::cout << y << ",";
std::cout << std::endl;
}
ASSERT_EQ(n, 0);
ASSERT_EQ(n, 0u);
}
TEST(Morpho, component_tree_subtree)
......@@ -139,5 +139,5 @@ TEST(Morpho, component_tree_subtree)
std::cout << std::endl;
n++;
}
ASSERT_EQ(n, 3);
ASSERT_EQ(n, 3u);
}
......@@ -89,7 +89,7 @@ TEST(Morpho, property_image_nbh)
unsigned j = 0;
mln_forall (nx)
{
ASSERT_EQ(nx->val(), voisins[i][j]);
ASSERT_EQ(static_cast<unsigned>(nx->val()), voisins[i][j]);
ASSERT_EQ(nx->point().id(), voisins[i][j]);
++j;
}
......@@ -106,7 +106,7 @@ TEST(Morpho, property_image_nbh)
unsigned j = 0;
mln_forall (n)
{
ASSERT_EQ(ima(*n), voisins[i][j]);
ASSERT_EQ(static_cast<unsigned>(ima(*n)), voisins[i][j]);
ASSERT_TRUE(n->id() == voisins[i][j]);
++j;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment