Monado OpenXR Runtime
t_euroc_recorder.cpp File Reference

EuRoC dataset recorder utility. More...

#include "t_euroc_recorder.h"
#include "os/os_time.h"
#include "util/u_frame.h"
#include "util/u_sink.h"
#include "util/u_var.h"
#include "util/u_debug.h"
#include "xrt/xrt_defines.h"
#include "xrt/xrt_tracking.h"
#include <cassert>
#include <ctime>
#include <filesystem>
#include <fstream>
#include <mutex>
#include <string>
#include <queue>
#include <iomanip>
#include <opencv2/imgcodecs.hpp>
Include dependency graph for t_euroc_recorder.cpp:

Data Structures

struct  euroc_recorder
 

Macros

#define DEFINE_SAVE_CAM(cam_id)
 
#define DEFINE_RECEIVE_CAM(cam_id)
 

Functions

static void euroc_recorder_mkfiles (struct euroc_recorder *er)
 
static void euroc_recorder_flush (struct euroc_recorder *er)
 
void euroc_recorder_save_imu (xrt_imu_sink *sink, struct xrt_imu_sample *sample)
 
void euroc_recorder_save_gt (xrt_pose_sink *sink, struct xrt_pose_sample *sample)
 
static void euroc_recorder_save_frame (euroc_recorder *er, struct xrt_frame *frame, int cam_index)
 
void euroc_recorder_save_cam0 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_save_cam1 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_save_cam2 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_save_cam3 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_save_cam4 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_receive_imu (xrt_imu_sink *sink, struct xrt_imu_sample *sample)
 
void euroc_recorder_receive_gt (xrt_pose_sink *sink, struct xrt_pose_sample *sample)
 
static void euroc_recorder_receive_frame (euroc_recorder *er, struct xrt_frame *src_frame, int cam_index)
 
void euroc_recorder_receive_cam0 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_receive_cam1 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_receive_cam2 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_receive_cam3 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_receive_cam4 (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
void euroc_recorder_node_break_apart (struct xrt_frame_node *node)
 
void euroc_recorder_node_destroy (struct xrt_frame_node *node)
 
xrt_slam_sinkseuroc_recorder_create (struct xrt_frame_context *xfctx, const char *record_path, int cam_count, bool record_from_start)
 Create SLAM sinks to record samples in EuRoC format. More...
 
void euroc_recorder_start (struct xrt_slam_sinks *er_sinks)
 Start recording samples sent to the recorder sinks. More...
 
void euroc_recorder_stop (struct xrt_slam_sinks *er_sinks)
 Stop recording samples sent to the recorder sinks. More...
 
static void euroc_recorder_btn_cb (void *ptr)
 
void euroc_recorder_add_ui (struct xrt_slam_sinks *er_sinks, void *root, const char *prefix)
 Add EuRoC recorder UI button to start recording after creation. More...
 

Variables

static void(* euroc_recorder_save_cam [XRT_TRACKING_MAX_SLAM_CAMS])(struct xrt_frame_sink *sink, struct xrt_frame *frame)
 Be sure to define the same number of defined functions as XRT_TRACKING_MAX_SLAM_CAMS and to add them to to euroc_recorder_save_cam. More...
 
static void(* euroc_recorder_receive_cam [XRT_TRACKING_MAX_SLAM_CAMS])(struct xrt_frame_sink *, struct xrt_frame *)
 Be sure to define the same number of defined functions as XRT_TRACKING_MAX_SLAM_CAMS and to add them to to euroc_recorder_receive_cam. More...
 

Detailed Description

EuRoC dataset recorder utility.

Author
Mateo de Mayo mateo.nosp@m..dem.nosp@m.ayo@c.nosp@m.olla.nosp@m.bora..nosp@m.com

Macro Definition Documentation

◆ DEFINE_RECEIVE_CAM

#define DEFINE_RECEIVE_CAM (   cam_id)
Value:
extern "C" void euroc_recorder_receive_cam##cam_id(struct xrt_frame_sink *sink, struct xrt_frame *frame) \
{ \
euroc_recorder *er = container_of(sink, euroc_recorder, cloner_sinks[cam_id]); \
euroc_recorder_receive_frame(er, frame, cam_id); \
}
#define container_of(ptr, type, field)
Get the holder from a pointer to a field.
Definition: xrt_compiler.h:149
Definition: t_euroc_recorder.cpp:43
Definition: u_pacing_compositor.c:54
A object that is sent frames.
Definition: xrt_frame.h:58
Basic frame data structure - holds a pointer to buffer.
Definition: xrt_frame.h:25
static void(* euroc_recorder_receive_cam[XRT_TRACKING_MAX_SLAM_CAMS])(struct xrt_frame_sink *, struct xrt_frame *)
Be sure to define the same number of defined functions as XRT_TRACKING_MAX_SLAM_CAMS and to add them ...
Definition: t_euroc_recorder.cpp:301

◆ DEFINE_SAVE_CAM

#define DEFINE_SAVE_CAM (   cam_id)
Value:
extern "C" void euroc_recorder_save_cam##cam_id(struct xrt_frame_sink *sink, struct xrt_frame *frame) \
{ \
euroc_recorder *er = container_of(sink, euroc_recorder, writer_sinks[cam_id]); \
if (cam_id == 0) { \
euroc_recorder_flush(er); \
} \
euroc_recorder_save_frame(er, frame, cam_id); \
}
static void(* euroc_recorder_save_cam[XRT_TRACKING_MAX_SLAM_CAMS])(struct xrt_frame_sink *sink, struct xrt_frame *frame)
Be sure to define the same number of defined functions as XRT_TRACKING_MAX_SLAM_CAMS and to add them ...
Definition: t_euroc_recorder.cpp:219

Function Documentation

◆ euroc_recorder_add_ui()

void euroc_recorder_add_ui ( struct xrt_slam_sinks er_sinks,
void *  root,
const char *  prefix 
)

Add EuRoC recorder UI button to start recording after creation.

Parameters
er_sinksThe sinks returned by euroc_recorder_create
rootThe pointer to add UI button to
prefixPrefix in case you have multiple recorders, otherwise pass an empty string

References u_var_button::cb, container_of, and euroc_recorder::recording_btn.

◆ euroc_recorder_start()

void euroc_recorder_start ( struct xrt_slam_sinks er_sinks)

Start recording samples sent to the recorder sinks.

Parameters
er_sinksThe recorder sinks returned by euroc_recorder_create

References container_of, os_realtime_get_ns(), euroc_recorder::path, euroc_recorder::path_prefix, euroc_recorder::recording, U_1_000_000_000, and U_LOG_W.

◆ euroc_recorder_stop()

void euroc_recorder_stop ( struct xrt_slam_sinks er_sinks)

Stop recording samples sent to the recorder sinks.

You can start and stop as many times as you like.

Parameters
er_sinksThe recorder sinks returned by euroc_recorder_create

References container_of, euroc_recorder::path, euroc_recorder::recording, and U_LOG_W.

Variable Documentation

◆ euroc_recorder_receive_cam

void(* euroc_recorder_receive_cam[XRT_TRACKING_MAX_SLAM_CAMS])(struct xrt_frame_sink *, struct xrt_frame *) ( struct xrt_frame_sink ,
struct xrt_frame  
)
static
Initial value:
= {
euroc_recorder_receive_cam0,
euroc_recorder_receive_cam1,
euroc_recorder_receive_cam2,
euroc_recorder_receive_cam3,
euroc_recorder_receive_cam4,
}

Be sure to define the same number of defined functions as XRT_TRACKING_MAX_SLAM_CAMS and to add them to to euroc_recorder_receive_cam.

◆ euroc_recorder_save_cam

void(* euroc_recorder_save_cam[XRT_TRACKING_MAX_SLAM_CAMS])(struct xrt_frame_sink *sink, struct xrt_frame *frame) ( struct xrt_frame_sink sink,
struct xrt_frame frame 
)
static
Initial value:
= {
euroc_recorder_save_cam0,
euroc_recorder_save_cam1,
euroc_recorder_save_cam2,
euroc_recorder_save_cam3,
euroc_recorder_save_cam4,
}

Be sure to define the same number of defined functions as XRT_TRACKING_MAX_SLAM_CAMS and to add them to to euroc_recorder_save_cam.