10 #include "RGBDImage.h"
21 bool convert_rgb_to_intensity ) {
22 std::shared_ptr<RGBDImage> rgbd_image = std::make_shared<RGBDImage>();
25 "[CreateFromColorAndDepth] Unsupported image "
31 convert_rgb_to_intensity ? *
color.CreateFloatImage() :
color;
40 bool convert_rgb_to_intensity ) {
42 convert_rgb_to_intensity);
50 bool convert_rgb_to_intensity ) {
52 convert_rgb_to_intensity);
60 bool convert_rgb_to_intensity ) {
61 std::shared_ptr<RGBDImage> rgbd_image = std::make_shared<RGBDImage>();
64 "[CreateRGBDImageFromSUNFormat] Unsupported image format.");
66 for (
int v = 0; v < depth.
height_; v++) {
67 for (
int u = 0; u < depth.
width_; u++) {
68 uint16_t &d = *depth.
PointerAt<uint16_t>(u, v);
69 d = (d >> 3) | (d << 13);
74 convert_rgb_to_intensity);
81 bool convert_rgb_to_intensity ) {
82 std::shared_ptr<RGBDImage> rgbd_image = std::make_shared<RGBDImage>();
85 "[CreateRGBDImageFromNYUFormat] Unsupported image format.");
87 for (
int v = 0; v < depth.
height_; v++) {
88 for (
int u = 0; u < depth.
width_; u++) {
89 uint16_t *d = depth.
PointerAt<uint16_t>(u, v);
90 uint8_t *p = (uint8_t *)d;
94 double xx = 351.3 / (1092.5 - *d);
98 *d = (uint16_t)(
floor(xx * 1000 + 0.5));
104 convert_rgb_to_intensity);
The Image class stores image with customizable width, height, num of channels and bytes per channel.
int height_
Height of the image.
std::shared_ptr< Image > ConvertDepthToFloatImage(double depth_scale=1000.0, double depth_trunc=3.0) const
int width_
Width of the image.
T * PointerAt(int u, int v) const
Function to access the raw data of a single-channel Image.
static std::shared_ptr< RGBDImage > CreateFromTUMFormat(const Image &color, const Image &depth, bool convert_rgb_to_intensity=true)
Factory function to create an RGBD Image from TUM dataset.
static std::shared_ptr< RGBDImage > CreateFromRedwoodFormat(const Image &color, const Image &depth, bool convert_rgb_to_intensity=true)
Factory function to create an RGBD Image from Redwood dataset.
static std::shared_ptr< RGBDImage > CreateFromSUNFormat(const Image &color, const Image &depth, bool convert_rgb_to_intensity=true)
Factory function to create an RGBD Image from SUN3D dataset.
static std::shared_ptr< RGBDImage > CreateFromNYUFormat(const Image &color, const Image &depth, bool convert_rgb_to_intensity=true)
Factory function to create an RGBD Image from NYU dataset.
static std::shared_ptr< RGBDImage > CreateFromColorAndDepth(const Image &color, const Image &depth, double depth_scale=1000.0, double depth_trunc=3.0, bool convert_rgb_to_intensity=true)
Factory function to create an RGBD Image from color and depth Images.
MiniVec< float, N > floor(const MiniVec< float, N > &a)
Generic file read and write utility for python interface.