In this page we include some code snippets and software for processing the data. If you have any suggestions or would like to contribute software to this page, please contact Kevin Lai.
All depth images in the RGB-D Object Dataset are stored as PNG where each pixel stores the depth in millimeters as a 16-bit unsigned integer. The code snippet below uses OpenCV to read a depth image and convert the depth into floats - thanks to Daniel Ricao Canelhas for suggesting this.
depthImage = cv::imread(filename, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR ); // Read the file
depthImage.convertTo(depthImage, CV_32F); // convert the image data to float type
read_rgbd_pcd.cpp - Point clouds in the RGB-D Object Dataset are stored in the PCD file format. This sample code reads a point cloud in the dataset using the Point Cloud Library (PCL).
Note: If you encounter point clouds that are incorrectly colored black, see this for a fix. Thanks to Walter Lucetti for pointing this out.
readPcd.m - Point clouds in the RGB-D Object Dataset are stored in the PCD file format. This MATLAB function reads a point cloud in the dataset. Warning: While this function will read PCD files from the RGB-D Object Dataset, it may not be compatible with arbitrary PCD files created with the latest version of PCL.
unpackRGBFloat.m - The color information of each point is stored as a float. Use this function to unpack the data as follows:
data = readPcd('apple_1_1_1.pcd');
rgb = unpackRGBFloat(single(data(:,4)));
depthToCloud.m - This MATLAB function will convert the depth images in the RGB-D Object Dataset into 3D point clouds. In order to convert the depth images into 3D point clouds, you need to use one of the following set of instructions, depending on which dataset you downloaded:
1. RGB-D Object Dataset (cropped images):
loc = load('apple_1_1_1_loc.txt');
depth = imread('apple_1_1_1_depthcrop.png');
[pcloud distance] = depthToCloud(depth,loc);
2. RGB-D Object Dataset (full 640x480 images) or RGB-D Scenes:
depth = imread('apple_1_1_1_depth.png');
[pcloud distance] = depthToCloud(depth);
The "loc" parameter is necessary for the cropped images because the depthToCloud function needs to know the location in the CCD sensor of the top-left pixel in the image. With the full, uncropped images, this is just 1,1 and so the parameter is not needed.
The depthToCloud function returns the point cloud in a N*M*3 matrix, where pcloud(x,y,:) is the 3D point at image location (x,y), with NaN denoting missing depth pixels.
compSpinImages.m - This MATLAB function computes spin images for every point in a point cloud. It uses a third-party implementation of k-d trees here. In our experiments we used radius=0.04, imgW=16, minNeighbors=10.
Software and Data for the technique from the above paper is now available.