Example: rgbd_dataset2rawlog
Contents
1. Description
This small utility converts the TUM RGB+D Kinect datasets into Rawlogs, loadable by MRPT programs. Some notes about the differences between Kinect datasets in Rawlog format and in the TUM originals:
- In MRPT, a Kinect observation object (CObservation3DRangeScan) can store the three fields simultaneously: range image, RGB data and projected 3D point coordinates.
- An observation is created only when both range & RGB data are available in the dataset with a difference in timestamp below half the kinect period (1/30 sec). That means that due to ocasional losses in the original datasets, the rate of observations is less than 30Hz.
- Only one IMU entry is kept per RGB+Range pair. If you need high-rate accelerometer data, please download the TUM original data files.
2. Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Usage: rgbd_dataset2rawlog [PATH_TO_RGBD_DATASET] [OUTPUT_NAME] Where expected input files are: - PATH_TO_RGBD_DATASET/accelerometer.txt - PATH_TO_RGBD_DATASET/depth.txt - PATH_TO_RGBD_DATASET/rgb.txt - PATH_TO_RGBD_DATASET/rgb/... (Images, 3x8u) - PATH_TO_RGBD_DATASET/depth/... (Images, 1x16u) Output files: - OUTPUT_NAME.rawlog: The output rawlog file. - OUTPUT_NAME_Images/...: External RGB images. |
3. Source code
See: https://github.com/MRPT/mrpt/tree/master/samples/rgbd_dataset2rawlog/
4. Visualization of the resulting data set
(View in YouTube)
5. Extra tools
The following script can be used to batch convert several datasets from the TUM collection (or any others in the future) that start as .tgz files. For the expected format, see the comments at the beginning of the example “test.cpp”.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#!/bin/bash # ---- CUSTOMIZE AS NEEDED ----------- RGBD_DATASETS_PATH="/media/ALMACENAMIENTO/Rawlogs/rgbd-datasets" README_FILE="/media/ALMACENAMIENTO/Rawlogs/rgbd-datasets/README.txt" MRPT_RGBD_EXE_PATH="$HOME/code/mrpt-release/samples/rgbd_dataset2rawlog/" RAWLOGS_DIR="$HOME/rawlogs" # ----------------------------------- LST_DATASETS_TGZ=$(ls $RGBD_DATASETS_PATH/rgbd_dataset_freiburg*.tgz ) mkdir $RAWLOGS_DIR for FIL in $LST_DATASETS_TGZ; do DATASET_NAME=$(basename $FIL .tgz) echo "" echo "-----------------------------------------------------" echo "Processing dataset: $DATASET_NAME" OUT_DIR="$RAWLOGS_DIR/$DATASET_NAME/" OUT_RAWLOG="${OUT_DIR}$DATASET_NAME" DECOMPR_DIR="$RAWLOGS_DIR/${DATASET_NAME}_TMP/" mkdir $DECOMPR_DIR echo "Decompressing: $DATASET_NAME.tgz --> $DECOMPR_DIR" tar -C $DECOMPR_DIR -xf $FIL echo "Done." # The actual dataset will be here: SRC_DATASET_DIR="$DECOMPR_DIR/$DATASET_NAME/" # Create output dir: mkdir $OUT_DIR #if [ ! -d "$SRC_DATASET_DIR/depth" ]; then # echo "*** ERROR ***: Skipping this dataset since it has no data dir" # continue #fi # Usage: program PATH_TO_RGBD_DATASET RAWLOG_OUTPUT_FILE $MRPT_RGBD_EXE_PATH/rgbd_dataset2rawlog $SRC_DATASET_DIR $OUT_RAWLOG if [ -f $SRC_DATASET_DIR/groundtruth.txt ]; then cp $SRC_DATASET_DIR/groundtruth.txt $OUT_DIR else echo "*** WARNING: Missing groundtruth file ***" fi if [ -f $README_FILE ];then cp $README_FILE $OUT_DIR fi echo "Removing decompressed dir: $DECOMPR_DIR" rm -fr $DECOMPR_DIR echo "Done." done |