Debian Codegraph @

src/pycolmap/scene/types.h

raw
1 #pragma once
2
3 #include "colmap/scene/camera.h"
4 #include "colmap/scene/frame.h"
5 #include "colmap/scene/image.h"
6 #include "colmap/scene/point2d.h"
7 #include "colmap/scene/point3d.h"
8 #include "colmap/scene/pose_graph.h"
9 #include "colmap/util/hash_containers.h"
10 #include "colmap/util/types.h"
11
12 #include <pybind11/eigen.h>
13 #include <pybind11/pybind11.h>
14 #include <pybind11/stl.h>
15
16 namespace py = pybind11;
17
18 // The scene element stores use colmap::NodeHashMap, whose concrete type depends
19 // on the selected hash map backend (see colmap/util/hash_containers.h). Alias
20 // the opaque bound map types to match so the Reconstruction/DatabaseCache
21 // accessors bind correctly under any backend.
22 using RigMap = colmap::NodeHashMap<colmap::rig_t, colmap::Rig>;
23 PYBIND11_MAKE_OPAQUE(RigMap);
24
25 using CameraMap = colmap::NodeHashMap<colmap::camera_t, colmap::Camera>;
26 PYBIND11_MAKE_OPAQUE(CameraMap);
27
28 using FrameMap = colmap::NodeHashMap<colmap::frame_t, colmap::Frame>;
29 PYBIND11_MAKE_OPAQUE(FrameMap);
30
31 using ImageMap = colmap::NodeHashMap<colmap::image_t, colmap::Image>;
32 PYBIND11_MAKE_OPAQUE(ImageMap);
33
34 using Point2DVector = std::vector<struct colmap::Point2D>;
35 PYBIND11_MAKE_OPAQUE(Point2DVector);
36
37 using Point3DMap = colmap::NodeHashMap<colmap::point3D_t, colmap::Point3D>;
38 PYBIND11_MAKE_OPAQUE(Point3DMap);
39
40 using PoseGraphEdgeMap =
41 colmap::NodeHashMap<colmap::image_pair_t, colmap::PoseGraph::Edge>;
42 PYBIND11_MAKE_OPAQUE(PoseGraphEdgeMap);
43
44 // Generic caster for non-opaque NodeHashMap returns (e.g.
45 // CorrespondenceGraph::NumMatchesBetweenAllImages). Only needed for the BOOST
46 // backend; for STD the alias is std::unordered_map, handled by pybind11. Kept
47 // here next to the PYBIND11_MAKE_OPAQUE element-store aliases above so that the
48 // opaque full specializations always take precedence over this partial one (the
49 // flat casters, which never collide with opaque types, live in
50 // pycolmap/pybind11_extension.h). Requires <pybind11/stl.h> for map_caster.
51 #if defined(COLMAP_HASH_BOOST)
52 namespace pybind11 {
53 namespace detail {
54
55 template <typename Key, typename Value, typename Hash, typename Equal>
56 struct type_caster<colmap::NodeHashMap<Key, Value, Hash, Equal>>
57 : map_caster<colmap::NodeHashMap<Key, Value, Hash, Equal>, Key, Value> {};
58
59 } // namespace detail
60 } // namespace pybind11
61 #endif