00001 00020 #ifndef NTK_CAMERA_RGBD_IMAGE_H 00021 #define NTK_CAMERA_RGBD_IMAGE_H 00022 00023 #include <ntk/camera/calibration.h> 00024 00025 namespace ntk 00026 { 00027 00028 class RGBDProcessor; 00029 class RGBDCalibration; 00030 00040 class CV_EXPORTS RGBDImage 00041 { 00042 public: 00043 RGBDImage() : m_calibration(0) {} 00044 00046 RGBDImage(const std::string& dir, 00047 const RGBDCalibration* calib = 0, 00048 RGBDProcessor* processor = 0) 00049 { loadFromDir(dir, calib, processor); } 00050 00052 const std::string& directory() const { return m_directory; } 00053 00055 bool hasDirectory() const { return !m_directory.empty(); } 00056 00058 void loadFromDir(const std::string& dir, 00059 const RGBDCalibration* calib = 0, 00060 RGBDProcessor* processor = 0); 00061 00063 void loadFromFile(const std::string& dir, 00064 const RGBDCalibration* calib = 0); 00065 00067 const RGBDCalibration* calibration() const { return m_calibration; } 00068 00070 void setCalibration(const RGBDCalibration* calibration) { m_calibration = calibration; } 00071 00073 void setDirectory(const std::string& dir) { m_directory = dir; } 00074 00076 void copyTo(RGBDImage& other) const; 00077 00079 int rgbWidth() const { return m_rgb.cols; } 00080 int rgbHeight() const { return m_rgb.rows; } 00081 00083 int depthWidth() const { return m_depth.cols; } 00084 int depthHeight() const { return m_depth.rows; } 00085 00087 cv::Mat3b& rgbRef() { return m_rgb; } 00088 const cv::Mat3b& rgb() const { return m_rgb; } 00089 00091 cv::Mat1f& depthRef() { return m_depth; } 00092 const cv::Mat1f& depth() const { return m_depth; } 00093 00095 cv::Mat3b& rawRgbRef() { return m_raw_rgb; } 00096 const cv::Mat3b& rawRgb() const { return m_raw_rgb; } 00097 00099 cv::Mat1f& rawDepthRef() { return m_raw_depth; } 00100 const cv::Mat1f& rawDepth() const { return m_raw_depth; } 00101 00103 cv::Mat1f& rawIntensityRef() { return m_raw_intensity; } 00104 const cv::Mat1f& rawIntensity() const { return m_raw_intensity; } 00105 00107 cv::Mat1f& rawAmplitudeRef() { return m_raw_amplitude; } 00108 const cv::Mat1f& rawAmplitude() const { return m_raw_amplitude; } 00109 00114 cv::Mat1b& depthMaskRef() { return m_depth_mask; } 00115 const cv::Mat1b& depthMask() const { return m_depth_mask; } 00116 00118 cv::Mat1b& rgbAsGrayRef() { return m_rgb_as_gray; } 00119 const cv::Mat1b& rgbAsGray() const { return m_rgb_as_gray; } 00120 00125 cv::Mat3b& mappedRgbRef() { return m_mapped_rgb; } 00126 const cv::Mat3b& mappedRgb() const { return m_mapped_rgb; } 00127 00132 cv::Mat1f& mappedDepthRef() { return m_mapped_depth; } 00133 const cv::Mat1f& mappedDepth() const { return m_mapped_depth; } 00134 00136 cv::Mat3f& normalRef() { return m_normal; } 00137 const cv::Mat3f& normal() const { return m_normal; } 00138 00140 cv::Mat1f& amplitudeRef() { return m_amplitude; } 00141 const cv::Mat1f& amplitude() const { return m_amplitude; } 00142 00144 cv::Mat1f& intensityRef() { return m_intensity; } 00145 const cv::Mat1f& intensity() const { return m_intensity; } 00146 00148 bool rgbPixelHasDepth(int r, int c) const 00149 { 00150 return m_mapped_depth.data 00151 && r < m_mapped_depth.rows && c < m_mapped_depth.cols && r >= 0 && c >= 0 00152 && m_mapped_depth(r,c) > 1e-5; 00153 } 00154 00155 private: 00156 RGBDImage(const RGBDImage& rhs); 00157 00158 private: 00159 cv::Mat3b m_rgb; 00160 cv::Mat1b m_rgb_as_gray; 00161 cv::Mat3b m_mapped_rgb; 00162 cv::Mat1f m_depth; 00163 cv::Mat1f m_mapped_depth; 00164 cv::Mat1b m_depth_mask; 00165 cv::Mat3f m_normal; 00166 cv::Mat1f m_amplitude; 00167 cv::Mat1f m_intensity; 00168 cv::Mat3b m_raw_rgb; 00169 cv::Mat1f m_raw_intensity; 00170 cv::Mat1f m_raw_amplitude; 00171 cv::Mat1f m_raw_depth; 00172 const RGBDCalibration* m_calibration; 00173 std::string m_directory; 00174 }; 00175 00176 } // ntk 00177 00178 #endif // NTK_CAMERA_RGBD_IMAGE_H