Commit 9e5fb8e7 authored by Michaël Roynard's avatar Michaël Roynard

Corrections for compilation gcc10

parent 8199d2c3
Pipeline #25801 failed with stages
in 3 minutes and 9 seconds
/venv
/build*
/cmake-build-*
/doc/source/images/*.png
......
......@@ -66,7 +66,7 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL
add_compile_options(
"-Wextra"
"-Wall"
"-Werror"
# "-Werror"
)
endif()
......
find_package(fmt 7.0 REQUIRED)
add_executable(gen_figs gen_figs.cpp)
target_link_libraries(gen_figs PRIVATE Fixtures::ImagePath Fixtures::ImageCompare Pylene::Pylene ${FreeImage_LIBRARIES})
target_link_libraries(gen_figs PRIVATE fmt::fmt Fixtures::ImagePath Fixtures::ImageCompare Pylene::Pylene ${FreeImage_LIBRARIES})
target_compile_features(gen_figs PRIVATE cxx_std_20)
add_executable(blur blur.cpp)
target_link_libraries(blur PRIVATE Pylene::Pylene)
target_compile_features(blur PRIVATE cxx_std_20)
add_sanitizers(gen_figs)
......
#include <mln/core/colors.hpp>
#include <mln/core/image/ndimage.hpp>
#include <mln/core/image/view/cast.hpp>
#include <mln/core/image/view/rgb.hpp>
#include <mln/core/image/view/transform.hpp>
#include <mln/io/imread.hpp>
#include <mln/io/imsave.hpp>
#include <mln/morpho/gaussian2d.hpp>
#include <mln/core/image/view/cast.hpp>
#include <mln/core/image/view/rgb.hpp>
#include <mln/core/colors.hpp>
template <class I>
auto to_gray(I&& input)
{
auto grayscale = [](auto v) -> uint8_t { return 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2]; };
return mln::view::transform(input, grayscale);
}
int main(int, char** argv)
{
auto input = mln::io::imread(argv[1]);
auto input = mln::io::imread(argv[1]);
float sigma = std::atof(argv[2]);
mln::image2d<float> out;
if (auto* in = input.cast_to<mln::rgb8, 2>())
out = mln::morpho::gaussian2d(mln::view::red(*in), sigma, sigma);
out = mln::morpho::gaussian2d(to_gray(*in), sigma, sigma);
else if (auto* in = input.cast_to<uint8_t, 2>())
out = mln::morpho::gaussian2d(*in, sigma, sigma);
......
This diff is collapsed.
......@@ -17,6 +17,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <iostream>
#include <malloc.h>
#include <stdio.h>
......@@ -69,19 +70,16 @@ namespace details
} // namespace details
std::vector<std::pair<std::string, std::string>> filenames = {
{"a.jpg", "a_bg.jpg"}, //
{"b.jpg", "b_bg.jpg"}, //
{"c.jpg", "c_bg.jpg"}, //
{"d.jpg", "d_bg.jpg"}, //
{"e.jpg", "e_bg.jpg"}, //
{"f.jpg", "f_bg.jpg"}, //
{"g.jpg", "g_bg.jpg"}, //
{"h.jpg", "h_bg.jpg"}, //
{"i.jpg", "i_bg.jpg"}, //
{"j.jpg", "j_bg.jpg"}, //
{"k.jpg", "k_bg.jpg"}, //
{"l.jpg", "l_bg.jpg"}, //
{"m.jpg", "m_bg.jpg"} //
{"castle_fg_1.tif", "castle_bg.tif"}, //
{"garden_fg_1.tif", "garden_bg.tif"}, //
{"garden_fg_2.tif", "garden_bg.tif"}, //
{"garden_fg_3.tif", "garden_bg.tif"}, //
{"garden_fg_4.tif", "garden_bg.tif"}, //
{"garden_fg_5.tif", "garden_bg.tif"}, //
{"pathway_fg_1.tif", "pathway_bg.tif"}, //
{"pathway_fg_2.tif", "pathway_bg.tif"}, //
{"pathway_fg_3.tif", "pathway_bg.tif"}, //
{"pathway_fg_4.tif", "pathway_bg.tif"}
};
......@@ -98,7 +96,7 @@ public:
using callback_cv = std::function<void(const image_cv_t& input_img_cv, const image_cv_t& input_bg_cv, image_cv_t& output_cv)>;
const std::string filepath =
std::string{fixtures::ImagePath::get_image_path()} + "../apps/tip.2019-2020/images/bg_sub_mosaic";
std::string{fixtures::ImagePath::get_image_path()} + "../apps/tip.2019-2020/images/clean_samples/6048x4024";
BMPlnVsOpenCV_BgSubPipeline()
{
......@@ -115,15 +113,17 @@ public:
for (std::size_t i = 0; i < n; ++i)
{
mln::io::imread(fmt::format("{}/mosaic_{}_{}", filepath, "6x6", filenames[i].first), g_input_imgs[i]);
mln::io::imread(fmt::format("{}/mosaic_{}_{}", filepath, "6x6", filenames[i].second), g_input_bgs[i]);
std::cout << "reading " << fmt::format("{}/{}", filepath, filenames[i].first) << std::endl;
mln::io::imread(fmt::format("{}/{}", filepath, filenames[i].first), g_input_imgs[i]);
mln::io::imread(fmt::format("{}/{}", filepath, filenames[i].second), g_input_bgs[i]);
mln::resize(g_outputs[i], g_input_imgs[i]);
int w = g_input_imgs[i].width();
int h = g_input_imgs[i].height();
g_input_imgs_cv[i] = cv::imread(fmt::format("{}/mosaic_{}_{}", filepath, "6x6", filenames[i].first), cv::IMREAD_COLOR);
g_input_bgs_cv[i] = cv::imread(fmt::format("{}/mosaic_{}_{}", filepath, "6x6", filenames[i].second), cv::IMREAD_COLOR);
g_input_imgs_cv[i] = cv::imread(fmt::format("{}/{}", filepath, filenames[i].first), cv::IMREAD_COLOR);
g_input_bgs_cv[i] = cv::imread(fmt::format("{}/{}", filepath, filenames[i].second), cv::IMREAD_COLOR);
g_outputs_cv[i].create(w, h, CV_8UC1);
g_size += w * h;
......
File added
from conans import CMake, ConanFile, tools
import os
class Pylene(ConanFile):
name = "pylene"
version = "head"
......@@ -19,22 +20,21 @@ class Pylene(ConanFile):
"boost:shared": True
}
generators = [ "cmake", "cmake_paths", "cmake_find_package" ]
generators = ["cmake", "cmake_paths", "cmake_find_package"]
exports_sources = ["pylene/*", "cmake/*", "CMakeLists.txt", "LICENSE"]
build_requires = [
"gtest/[>=1.10]",
"benchmark/[>=1.5.0]",
"benchmark/[>=1.5.1]",
]
requires = [
"range-v3/0.10.0",
"fmt/6.0.0",
"boost/1.73.0",
"pybind11/2.3.0@conan/stable"
"fmt/7.0.3",
"boost/1.74.0",
"pybind11/2.5.0"
]
def configure(self):
self.settings.compiler.cppstd = "20"
tools.check_min_cppstd(self, "20")
......@@ -54,10 +54,9 @@ class Pylene(ConanFile):
self.cpp_info.system_libs.append("freeimage")
self.cpp_info.names["cmake_find_package"] = "Pylene"
self.cpp_info.names["cmake_find_package_multi"] = "Pylene"
self.cpp_info.libs = [ "Pylene" ]
self.cpp_info.libs = ["Pylene"]
self.cpp_info.cxxflags.append(tools.cppstd_flag(self.settings))
v = tools.Version(self.settings.compiler.version)
if self.settings.compiler == "gcc" and v.major == "9":
self.cpp_info.cxxflags.append("-fconcepts")
......
find_package(GTest MODULE REQUIRED)
find_package(fmt 6.0 REQUIRED)
find_package(fmt 7.0 REQUIRED)
add_library(ImageCompare)
target_include_directories(ImageCompare PUBLIC include)
target_link_libraries(ImageCompare PUBLIC Pylene::Pylene GTest::GTest fmt::fmt)
target_compile_features(ImageCompare PUBLIC cxx_std_20)
target_sources(ImageCompare PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/fixtures/ImageCompare/image_compare.hpp
......
#pragma once
#include <mln/core/image/ndimage_fwd.hpp>
#include <mln/core/image/ndbuffer_image.hpp>
#include <mln/core/image/image.hpp>
#include <mln/core/image/ndbuffer_image.hpp>
#include <mln/core/image/ndimage_fwd.hpp>
#include <mln/core/range/rows.hpp>
#include <mln/core/range/view/zip.hpp>
#include <mln/io/imprint.hpp>
#include <range/v3/range/access.hpp>
#include <string>
#include <functional>
#include <algorithm>
#include <functional>
#include <string>
#include <type_traits>
#include <gtest/gtest.h>
......@@ -60,8 +62,7 @@ namespace fixtures::ImageCompare
std::function<void(mln::ndbuffer_image)> print_fn;
std::function<int(const void* a, const void* b, std::size_t n)> linecmp_fn;
if constexpr (fmt::internal::has_formatter<TA, fmt::format_context>() &&
fmt::internal::has_formatter<TB, fmt::format_context>())
if constexpr (fmt::has_formatter<TA, fmt::format_context>() && fmt::has_formatter<TB, fmt::format_context>())
{
print_fn = [](const mln::ndbuffer_image& ima) {
if (const auto* a = ima.cast_to<TA, adim>())
......@@ -147,4 +148,3 @@ namespace fixtures::ImageCompare
#define ASSERT_IMAGES_EQ_EXP2(f, g, flags) ASSERT_TRUE(::fixtures::ImageCompare::compare(f, g, flags))
#define ASSERT_IMAGES_NE_EXP2(f, g, flags) ASSERT_FALSE(::fixtures::ImageCompare::compare(f, g, flags))
......@@ -6,7 +6,7 @@ add_library(ImagePath STATIC
include/fixtures/ImagePath/image_path.hpp
${CMAKE_CURRENT_BINARY_DIR}/src/image_path.cpp)
target_compile_features(ImagePath PUBLIC cxx_std_17)
target_compile_features(ImagePath PUBLIC cxx_std_20)
target_include_directories(ImagePath PUBLIC include)
target_sources(ImagePath PUBLIC
......
project(Pybind CXX)
find_package(pybind11 CONFIG REQUIRED)
find_package(pybind11 REQUIRED)
pybind11_add_module(Pylena MODULE
src/pylena.cpp
......
......@@ -12,47 +12,63 @@ sns.set_context("paper")
bench_result = json.load(open("BMPlnVsOpenCV_BgSubPipeline-GNU-9.3.0.json"))
benchmarks = {'Pln_PipeViews': [],
'Pln_PipeAlgos': [], 'CV_PipeAlgo': []}
size_se_p = re.compile(".*/([0-9]+)")
indexes = []
for bench in bench_result['benchmarks']:
def draw_fig(img_id):
global bench_result
benchmarks = {'Pln_PipeViewsRect': [], 'Pln_PipeAlgosRect': [],
'CV_PipeAlgoRect': [], 'Pln_PipeViewsDisc': [],
'Pln_PipeAlgosDisc': [], 'CV_PipeAlgoDisc': []}
pattern = ".*/[0-9]+/([0-9]+)"
size_se_p = re.compile(pattern)
indexes = []
for bench in bench_result['benchmarks']:
for k in benchmarks.keys():
if k in bench['name']:
if 'aggregate_name' in bench:
continue
size_se = size_se_p.search(bench['name'])
assert(size_se is not None)
benchmarks[k].append({
'size_se': int(size_se.group(1)),
'iterations': bench['iterations'],
'time': bench['real_time'],
'unit': bench['time_unit'],
'throughput_bps': bench['bytes_per_second']
})
data = {'Pln_PipeViewsRect': [], 'Pln_PipeAlgosRect': [],
'CV_PipeAlgoRect': [], 'Pln_PipeViewsDisc': [],
'Pln_PipeAlgosDisc': [], 'CV_PipeAlgoDisc': []}
indexes = []
for k in benchmarks.keys():
if k in bench['name']:
if 'aggregate_name' in bench:
continue
size_se = size_se_p.search(bench['name'])
assert(size_se is not None)
benchmarks[k].append({
'size_se': int(size_se.group(1)),
'iterations': bench['iterations'],
'time': bench['real_time'],
'unit': bench['time_unit'],
'throughput_bps': bench['bytes_per_second']
})
for ret in benchmarks[k]:
data[k].append(ret['time'])
data = {'Pln_PipeViews': [],
'Pln_PipeAlgos': [], 'CV_PipeAlgo': []}
indexes = []
_k = list(benchmarks.keys())[0]
for ret in benchmarks[_k]:
indexes.append(ret['size_se'])
for k in benchmarks.keys():
for ret in benchmarks[k]:
data[k].append(ret['time'])
df = pd.DataFrame(data=data, index=indexes, columns=[
'Pln_PipeViewsRect', 'Pln_PipeAlgosRect',
'CV_PipeAlgoRect', 'Pln_PipeViewsDisc',
'Pln_PipeAlgosDisc', 'CV_PipeAlgoDisc'])
_k = list(benchmarks.keys())[0]
for ret in benchmarks[_k]:
indexes.append(ret['size_se'])
df.index.name = "SE size (half edge size for square, radius for disc)"
print(df.describe())
df = pd.DataFrame(data=data, index=indexes, columns=[
'Pln_PipeViews', 'Pln_PipeAlgos', 'CV_PipeAlgo'])
fig = sns.lineplot(data=df, hue="SE size", legend="full")
fig.set(yscale="log", ylabel="Time (ms)")
df.index.name = "SE size (half edge size for square, radius for disc)"
fig_name = "PlnVsOpenCV_bg_sub_{}.pdf".format(img_id)
fig.get_figure().savefig(fig_name)
print(df.describe())
fig.clear()
fig = sns.lineplot(data=df, hue="SE size", legend="full")
fig.set(yscale="log", ylabel="Time (ms)")
fig.get_figure().savefig("PlnVsOpenCV_bg_sub.pdf")
if __name__ == '__main__':
for i in range(0, 12):
draw_fig(i)
......@@ -12,46 +12,60 @@ sns.set_context("paper")
bench_result = json.load(open("BMPlnVsOpenCV_BgSubPipeline-GNU-9.3.0.json"))
benchmarks = {'Pln_PipeViews': [],
'Pln_PipeAlgos': []}
size_se_p = re.compile(".*/([0-9]+)")
indexes = []
for bench in bench_result['benchmarks']:
def draw_fig(img_id):
global bench_result
benchmarks = {'Pln_PipeViewsRect': [], 'Pln_PipeAlgosRect': [],
'Pln_PipeViewsDisc': [], 'Pln_PipeAlgosDisc': []}
pattern = ".*/[0-9]+/([0-9]+)"
size_se_p = re.compile(pattern)
indexes = []
for bench in bench_result['benchmarks']:
for k in benchmarks.keys():
if k in bench['name']:
if 'aggregate_name' in bench:
continue
size_se = size_se_p.search(bench['name'])
assert(size_se is not None)
benchmarks[k].append({
'size_se': int(size_se.group(1)),
'iterations': bench['iterations'],
'time': bench['real_time'],
'unit': bench['time_unit'],
'throughput_bps': bench['bytes_per_second']
})
data = {'Pln_PipeViewsRect': [], 'Pln_PipeAlgosRect': [],
'Pln_PipeViewsDisc': [], 'Pln_PipeAlgosDisc': []}
indexes = []
for k in benchmarks.keys():
if k in bench['name']:
if 'aggregate_name' in bench:
continue
size_se = size_se_p.search(bench['name'])
assert(size_se is not None)
benchmarks[k].append({
'size_se': int(size_se.group(1)),
'iterations': bench['iterations'],
'time': bench['real_time'],
'unit': bench['time_unit'],
'throughput_bps': bench['bytes_per_second']
})
for ret in benchmarks[k]:
data[k].append(ret['time'])
data = {'Pln_PipeViews': [],
'Pln_PipeAlgos': []}
indexes = []
_k = list(benchmarks.keys())[0]
for ret in benchmarks[_k]:
indexes.append(ret['size_se'])
for k in benchmarks.keys():
for ret in benchmarks[k]:
data[k].append(ret['time'])
df = pd.DataFrame(data=data, index=indexes, columns=[
'Pln_PipeViewsRect', 'Pln_PipeAlgosRect',
'Pln_PipeViewsDisc', 'Pln_PipeAlgosDisc'])
_k = list(benchmarks.keys())[0]
for ret in benchmarks[_k]:
indexes.append(ret['size_se'])
df.index.name = "SE size (half edge size for square, radius for disc)"
print(df.describe())
df = pd.DataFrame(data=data, index=indexes, columns=[
'Pln_PipeViews', 'Pln_PipeAlgos'])
fig = sns.lineplot(data=df, hue="SE size", legend="full")
fig.set(yscale="log", ylabel="Time (ms)")
df.index.name = "SE size (half edge size for square, radius for disc)"
fig_name = "PlnVsOpenCV_bg_sub_pln_{}.pdf".format(img_id)
fig.get_figure().savefig(fig_name)
print(df.describe())
fig.clear()
fig = sns.lineplot(data=df, hue="SE size", legend="full")
fig.set(yscale="log", ylabel="Time (ms)")
fig.get_figure().savefig("PlnVsOpenCV_bg_sub_pln.pdf")
if __name__ == '__main__':
for i in range(0, 12):
draw_fig(i)
......@@ -5,7 +5,7 @@ find_package(FreeImage REQUIRED)
find_package(TBB)
find_package(range-v3 0.10.0 REQUIRED)
find_package(fmt 6.0 REQUIRED)
find_package(fmt 7.0 REQUIRED)
set(PYLENE_USE_TBB YES CACHE BOOL "Set to NO to disable use of TBB and parallelization")
......
......@@ -4,6 +4,7 @@
#include <mln/core/concepts/archetype/domain.hpp>
#include <mln/core/concepts/archetype/pixel.hpp>
#include <mln/core/concepts/image.hpp>
#include <mln/core/concepts/extension.hpp>
#include <mln/core/private/traits/image.hpp>
#include <mln/core/private/traits/pixel.hpp>
......@@ -299,8 +300,16 @@ namespace mln::archetypes
struct WithExtensionImage : Image
{
struct Extension
struct Extension : ::mln::Extension<Extension>
{
using support_fill = std::false_type;
using support_mirror = std::false_type;
using support_periodize = std::false_type;
using support_clamp = std::false_type;
using support_extend_with = std::false_type;
using value_type = image_value_t<Image>;
bool fit(mln::archetypes::StructuringElement<image_point_t<Image>, mln::archetypes::Pixel> se) const;
int extent() const;
};
using extension_type = Extension;
......
......@@ -12,7 +12,6 @@ namespace mln::archetypes
template <class P, class Pix>
// clang-format off
requires mln::concepts::Point<P>&& mln::concepts::Pixel<Pix>
#endif
struct Neighborhood : StructuringElement<P, Pix>
// clang-format on
{
......
......@@ -3,7 +3,7 @@
#include <mln/core/concepts/archetype/pixel.hpp>
#include <mln/core/concepts/archetype/point.hpp>
#include <mln/core/concepts/neighborhood.hpp>
#include <mln/core/neighborhood/neighborhood_traits.hpp>
#include <mln/core/neighborhood/neighborhood.hpp>
#include <range/v3/view/subrange.hpp>
......@@ -22,7 +22,6 @@ namespace mln::archetypes
template <class P, class Pix>
// clang-format off
requires mln::concepts::Point<P>&& mln::concepts::Pixel<Pix>
#endif
struct StructuringElement
// clang-format on
{
......@@ -39,9 +38,7 @@ namespace mln::archetypes
template <class SE>
struct AsSE : SE, mln::details::Neighborhood
helper <AsSE<SE>>
struct AsSE : SE, mln::details::Neighborhood<AsSE<SE>>
{
};
} // namespace details
......
......@@ -11,7 +11,7 @@
#include <type_traits>
namespace mln::
namespace mln
{
template <class E>
struct Extension
......@@ -39,56 +39,56 @@ namespace mln::concepts
requires (const Ext cext,
mln::archetypes::StructuringElement<
Pnt,
mln::archetypes::Pixel> se, const Pnt pnt) {
{ cext.fit(se) } -> bool;
{ cext.extent() } -> int;
mln::archetypes::Pixel> se) {