Go to the documentation of this file.00001
00020 #ifndef NTK_CAMERA_RGBD_PROCESSOR_H
00021 #define NTK_CAMERA_RGBD_PROCESSOR_H
00022
00023 #include <ntk/core.h>
00024 #include <opencv/cv.h>
00025 #include <ntk/camera/rgbd_image.h>
00026
00027 namespace ntk
00028 {
00029
00035 class RGBDProcessor
00036 {
00037 public:
00038 enum ProcessorFlag {
00039 NoProcessing = 0x0,
00040 FixGeometry = 0x1,
00041 UndistortImages = 0x2,
00042 FixBias = 0x4,
00043 FilterAmplitude = 0x8,
00044 FilterNormals = 0x10,
00045 FilterUnstable = 0x20,
00046 FilterEdges = 0x40,
00047 FilterThresholdDepth = 0x80,
00048 FilterMedian = 0x100,
00049 ComputeMapping = 0x200,
00050 ComputeNormals = 0x400,
00051 ComputeKinectDepthTanh = 0x800,
00052 ComputeKinectDepthLinear = 0x1000,
00053 ComputeKinectDepthBaseline = 0x2000,
00054 NoAmplitudeIntensityUndistort = 0x4000,
00055 Pause = 0x8000,
00056 RemoveSmallStructures = 0x10000,
00057 FillSmallHoles = 0x20000,
00058 FlipColorImage = 0x40000,
00059 NiteProcessed = 0x80000,
00060 SmoothDepth = 0x100000,
00061 };
00062
00063 public:
00064 RGBDProcessor();
00065
00066 public:
00068 bool hasFilterFlag(ProcessorFlag flag) const { return m_flags&flag; }
00069 void setFilterFlags(int flags) { m_flags = flags; }
00070 void setFilterFlag(ProcessorFlag flag, bool enabled)
00071 { if (enabled) m_flags |= flag; else m_flags &= ~flag; }
00072
00074 void setMinDepth(float meters) { m_min_depth = meters; }
00075 float minDepth() const { return m_min_depth; }
00076 void setMaxDepth(float meters) { m_max_depth = meters; }
00077 float maxDepth() const { return m_max_depth; }
00078
00083 void setMaxNormalAngle(float angle_in_deg) { m_max_normal_angle = angle_in_deg; }
00084
00086 void setMaxTimeDelta(float v) { m_max_time_depth_delta = v; }
00087
00089 void setMaxSpacialDelta(float v) { m_max_spatial_depth_delta = v; }
00090
00095 void setMappingResolution(float r) { m_mapping_resolution = r; }
00096
00097 public:
00099 virtual void processImage(RGBDImage& image);
00100
00101 virtual void undistortImages();
00102 virtual void fixDepthGeometry();
00103 virtual void removeLowAmplitudeOutliers();
00104 virtual void removeNormalOutliers();
00105 virtual void removeUnstableOutliers();
00106 virtual void removeEdgeOutliers();
00107 virtual void applyDepthThreshold();
00108 virtual void computeNormals();
00109 virtual void computeMappings();
00110 virtual void medianFilter();
00111 virtual void computeKinectDepthLinear();
00112 virtual void computeKinectDepthTanh();
00113 virtual void computeKinectDepthBaseline();
00114 virtual void removeSmallStructures();
00115 virtual void fillSmallHoles();
00116
00117 protected:
00118 RGBDImage* m_image;
00119 int m_flags;
00120 cv::Mat1f m_last_depth_image;
00121 float m_min_depth;
00122 float m_max_depth;
00123 float m_max_normal_angle;
00124 float m_max_time_depth_delta;
00125 float m_max_spatial_depth_delta;
00126 float m_mapping_resolution;
00127 };
00128
00130 class KinectProcessor : public RGBDProcessor
00131 {
00132 public:
00133 KinectProcessor()
00134 : RGBDProcessor()
00135 {
00136 setFilterFlag(RGBDProcessor::ComputeKinectDepthBaseline, true);
00137 setFilterFlag(RGBDProcessor::NoAmplitudeIntensityUndistort, true);
00138 }
00139 };
00140
00142 class NiteProcessor : public RGBDProcessor
00143 {
00144 public:
00145 NiteProcessor()
00146 : RGBDProcessor()
00147 {
00148
00149 setFilterFlags(RGBDProcessor::NiteProcessed | RGBDProcessor::ComputeMapping);
00150 }
00151
00152 protected:
00153 virtual void computeMappings();
00154 };
00155
00160 void compute_color_encoded_depth(const cv::Mat1f& depth, cv::Mat3b& color_dept,
00161 double* min_val = 0, double* max_val = 0);
00162
00163 }
00164
00165 #endif // NTK_CAMERA_RGBD_PROCESSOR_H