This is a minimal CMake project that shows how to use Rerun in your code in conjunction with Eigen and OpenCV.
Image
, Points3D
, Pinhole
, Transform3D
This C++ example demonstrates the integration of the Rerun with Eigen and OpenCV libraries. Eigen handles 3D point calculations and camera orientations, while OpenCV assists with image processing tasks like reading and converting images.
The visualizations in this example were created with the following Rerun code:
The positions of 3D points are logged to the "world/points_from_vector" and "world/points_from_matrix" entities using the Points3D
archetype.
rec.log("world/points_from_vector", rerun::Points3D(points3d_vector));
rec.log("world/points_from_matrix", rerun::Points3D(points3d_matrix));
A pinhole camera is logged to "world/camera" using the Pinhole
archetype.
Additionally, the 3D transformation of the camera, including its position and orientation, is logged using the Transform3D
archetype.
rec.log(
"world/camera",
rerun::Pinhole::from_focal_length_and_resolution({500.0, 500.0}, {640.0, 480.0})
);
rec.log(
"world/camera",
rerun::Transform3D(
rerun::Vec3D(camera_position.data()),
rerun::Mat3x3(camera_orientation.data())
)
);
Images are logged using the Image
archetype. Two methods are demonstrated: logging images with a tensor buffer and logging images by passing a pointer to the image data.
// Log image to rerun using the tensor buffer adapter defined in `collection_adapters.hpp`.
rec.log("image0", rerun::Image(tensor_shape(img), rerun::TensorBuffer::u8(img)));
// Or by passing a pointer to the image data.
rec.log("image1", rerun::Image(tensor_shape(img), reinterpret_cast<const uint8_t*>(img.data)));
You can find the build instructions here: C++ Example with OpenCV and Eigen