Skip to content

Commit ce147a1

Browse files
committed
Add logging of posed pinhole camera
1 parent b447071 commit ce147a1

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/main.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,40 @@ int main() {
6262

6363
// Points represented by std::vector<Eigen::Vector3f>
6464
auto points3d_vector = generate_random_points_vector(1000);
65-
rec.log("points_from_vector", rerun::Points3D(points3d_vector));
65+
rec.log("world/points_from_vector", rerun::Points3D(points3d_vector));
6666

6767
// Points represented by Eigen::MatX3f (Nx3 matrix)
6868
Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random(num_points, 3);
69-
rec.log("points_from_matrix", rerun::Points3D(points3d_matrix));
69+
rec.log("world/points_from_matrix", rerun::Points3D(points3d_matrix));
70+
71+
// Posed pinhole camera
72+
float width = 640.0f;
73+
float height = 480.0f;
74+
Eigen::Matrix3f projection_matrix = Eigen::Matrix3f::Identity();
75+
projection_matrix(0, 0) = 500.0f;
76+
projection_matrix(1, 1) = 500.0f;
77+
projection_matrix(0, 2) = (width - 1) / 2.0;
78+
projection_matrix(1, 2) = (height - 1) / 2.0;
79+
rec.log(
80+
"world/camera",
81+
rerun::Pinhole(rerun::components::PinholeProjection(*(float(*)[9])projection_matrix.data()))
82+
.with_resolution(rerun::components::Resolution({width, height}))
83+
);
84+
Eigen::Vector3f camera_position{0.0, -1.0, 0.0};
85+
Eigen::Matrix3f camera_orientation;
86+
// clang-format off
87+
camera_orientation <<
88+
0.0, 1.0, 0.0,
89+
0.0, 0.0, 1.0,
90+
1.0, 0.0, 0.0;
91+
// clang-format on
92+
rec.log(
93+
"world/camera",
94+
rerun::Transform3D(
95+
rerun::datatypes::Vec3D(*(float(*)[3])camera_position.data()),
96+
rerun::datatypes::Mat3x3(*(float(*)[9])camera_orientation.data())
97+
)
98+
);
7099

71100
// Image
72101
std::string image_path = "rerun-logo.png";

0 commit comments

Comments
 (0)