You are here

Example: rgbd_dataset2rawlog

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

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: http://mrpt.googlecode.com/svn/trunk/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".

 

#!/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

 

Tags: 
Subscribe to Comments for "Example: rgbd_dataset2rawlog"