Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind colmap::span #217

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pycolmap/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include "colmap/util/threading.h"
#include "colmap/util/types.h"

#include "pycolmap/log_exceptions.h"

Expand All @@ -15,6 +16,7 @@
#include <pybind11/eval.h>
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>

using namespace colmap;
Expand Down Expand Up @@ -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 <typename Type>
struct type_caster<span<Type>> : list_caster<span<Type>, 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
Expand Down Expand Up @@ -429,4 +440,4 @@ class_<Map, holder_type> bind_map_fix(handle scope,

return cl;
}
} // namespace pybind11
} // namespace PYBIND11_NAMESPACE