From f23e4cdf313e48a331cb7ba4998d203ee492340e Mon Sep 17 00:00:00 2001 From: Paul-Edouard Sarlin Date: Wed, 20 Dec 2023 16:52:48 +0100 Subject: [PATCH] Bind colmap::span --- pycolmap/helpers.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pycolmap/helpers.h b/pycolmap/helpers.h index 1ffbaf23..7911c786 100644 --- a/pycolmap/helpers.h +++ b/pycolmap/helpers.h @@ -3,6 +3,7 @@ #pragma once #include "colmap/util/threading.h" +#include "colmap/util/types.h" #include "pycolmap/log_exceptions.h" @@ -15,6 +16,7 @@ #include #include #include +#include #include using namespace colmap; @@ -263,7 +265,16 @@ void PyWait(Thread* thread, double gap = 2.0) { thread->Wait(); } -namespace pybind11 { +namespace PYBIND11_NAMESPACE { + +// Bind COLMAP's backport implementation of std::span. This copies the content +// into a list. We could instead create a view with an Eigen::Map but the cast +// should be explicit and cannot be automatic - likely not worth the added +// logic. +namespace detail { +template +struct type_caster> : list_caster, Type> {}; +} // namespace detail // Fix long-standing bug https://github.com/pybind/pybind11/issues/4529 // TODO(sarlinpe): remove when https://github.com/pybind/pybind11/pull/4972 @@ -429,4 +440,4 @@ class_ bind_map_fix(handle scope, return cl; } -} // namespace pybind11 +} // namespace PYBIND11_NAMESPACE