Eigen and OpenCV C++ integration

This is a minimal CMake project that shows how to use Rerun in your code in conjunction with Eigen and OpenCV.

Used Rerun types

Image, Points3D, Pinhole, Transform3D

Background

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.

Logging and visualizing with Rerun

The visualizations in this example were created with the following Rerun code:

3D points

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));

Pinhole camera

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

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)));

Run the code

You can find the build instructions here: C++ Example with OpenCV and Eigen