4 #include <boost/shared_ptr.hpp>
6 #include <cuv/ndarray.hpp>
18 typedef uint8_t LabelType;
33 RGBColor(uint8_t r, uint8_t g, uint8_t b);
41 RGBColor(
const std::string& colorString);
51 o << static_cast<int>((*this)[0]) <<
",";
52 o << static_cast<int>((*this)[1]) <<
",";
53 o << static_cast<int>((*this)[2]);
66 LabelType getOrAddColorId(
const RGBColor& color,
const LabelType& label);
68 void addColorId(
const RGBColor& color,
const LabelType& label);
89 explicit Depth(
const int& value) :
96 explicit Depth(
const double& value) :
97 value(1000.0 * value) {
118 return value / 1000.0f;
133 return Depth(value - other.value);
141 return Depth(value + other.value);
149 value += other.value;
184 explicit RGBDImage(
const std::string& filename,
const std::string& depthFilename,
bool useDepthImages,
185 bool convertToCIELab =
true,
186 bool useDepthFilling =
false,
187 bool calculateIntegralImage =
true);
193 filename(
""), depthFilename(
""),
194 width(width), height(height),
195 colorImage(cuv::extents[COLOR_CHANNELS][height][width], boost::make_shared<cuv::cuda_allocator>()),
196 depthImage(cuv::extents[DEPTH_CHANNELS][height][width], boost::make_shared<cuv::cuda_allocator>()),
197 inCIELab(false), integratedColor(false), integratedDepth(false) {
198 assert(width >= 0 && height >= 0);
211 return colorImage.
size() *
sizeof(float) + depthImage.
size() *
sizeof(int);
259 void dump(std::ostream& out)
const;
278 void saveColor(
const std::string& filename)
const;
283 void saveDepth(
const std::string& filename)
const;
310 return integratedDepth;
317 return integratedColor;
341 depthImage(1, y, x) = depth.
isValid();
348 return Depth(static_cast<int>(depthImage(0, y, x)));
355 return depthImage(1, y, x);
366 void setColor(
int x,
int y,
unsigned int channel,
float color) {
377 float getColor(
int x,
int y,
unsigned int channel)
const {
389 std::string filename;
390 std::string depthFilename;
397 bool integratedColor;
398 bool integratedDepth;
400 static const unsigned int COLOR_CHANNELS = 3;
401 static const unsigned int DEPTH_CHANNELS = 2;
403 void loadDepthImage(
const std::string& depthFilename);
404 void loadDummyDepthValues();
405 void fillDepthFromRight();
406 void fillDepthFromLeft();
407 void fillDepthFromBottom();
408 void fillDepthFromTop();
431 std::string filename;
443 filename(), width(width), height(height), image(height, width) {
445 assert(width >= 0 && height >= 0);
447 if (width > 0 && height > 0) {
448 assert(image(0, 0) == static_cast<LabelType>(0));
469 if (x < 0 || x >= width)
471 if (y < 0 || y >= height)
480 void save(
const std::string& filename)
const;
491 return image.
size() *
sizeof(LabelType);
511 void setLabel(
int x,
int y,
const LabelType label) {
532 void resizeImage(
int newWidth,
int newHeight, LabelType paddingLabel);
563 const boost::shared_ptr<LabelImage>&
labelImage);
603 void resizeImage(
int newWidth,
int newHeight, LabelType paddingLabel)
const;
616 LabeledRGBDImage loadImagePair(
const std::string& filename,
bool useCIELab,
bool useDepthImages,
bool useDepthFilling,
617 bool calculateIntegralImages =
true);
623 std::vector<std::string> listImageFilenames(
const std::string& folder);
629 std::vector<LabeledRGBDImage> loadImages(
const std::string& folder,
bool useCIELab,
bool useDepthImages,
bool useDepthFilling,
const std::vector<std::string>& ignoredColors,
size_t& numLabels);