7
7
#include < opencv2/imgproc.hpp>
8
8
#include < rerun.hpp>
9
9
10
+ // Adapters so we can log eigen vectors as rerun positions:
10
11
template <>
11
12
struct rerun ::ComponentBatchAdapter<rerun::components::Position3D, std::vector<Eigen::Vector3f>> {
12
13
// Sanity check that this is binary compatible.
@@ -26,6 +27,7 @@ struct rerun::ComponentBatchAdapter<rerun::components::Position3D, std::vector<E
26
27
}
27
28
};
28
29
30
+ // Adapters so we can log an eigen matrix as rerun positions:
29
31
template <>
30
32
struct rerun ::ComponentBatchAdapter<rerun::components::Position3D, Eigen::MatrixX3f> {
31
33
// Sanity check that this is binary compatible.
@@ -62,11 +64,11 @@ int main() {
62
64
const int num_points = 1000 ;
63
65
64
66
// Points represented by std::vector<Eigen::Vector3f>
65
- auto points3d_vector = generate_random_points_vector (1000 );
67
+ const auto points3d_vector = generate_random_points_vector (1000 );
66
68
rec.log (" world/points_from_vector" , rerun::Points3D (points3d_vector));
67
69
68
70
// Points represented by Eigen::MatX3f (Nx3 matrix)
69
- Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random (num_points, 3 );
71
+ const Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random (num_points, 3 );
70
72
rec.log (" world/points_from_matrix" , rerun::Points3D (points3d_matrix));
71
73
72
74
// Posed pinhole camera
@@ -84,7 +86,7 @@ int main() {
84
86
))
85
87
.with_resolution (rerun::components::Resolution ({width, height}))
86
88
);
87
- Eigen::Vector3f camera_position{0.0 , -1.0 , 0.0 };
89
+ const Eigen::Vector3f camera_position{0.0 , -1.0 , 0.0 };
88
90
Eigen::Matrix3f camera_orientation;
89
91
// clang-format off
90
92
camera_orientation <<
@@ -95,8 +97,9 @@ int main() {
95
97
rec.log (
96
98
" world/camera" ,
97
99
rerun::Transform3D (
98
- rerun::datatypes::Vec3D (*reinterpret_cast <float (*)[3 ]>(camera_position.data ())),
99
- rerun::datatypes::Mat3x3 (*reinterpret_cast <float (*)[9 ]>(camera_orientation.data ()))
100
+ rerun::datatypes::Vec3D (*reinterpret_cast <const float (*)[3 ]>(camera_position.data ())),
101
+ rerun::datatypes::Mat3x3 (*reinterpret_cast <const float (*)[9 ]>(camera_orientation.data ())
102
+ )
100
103
)
101
104
);
102
105
0 commit comments