iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RGBDmessage.H
Go to the documentation of this file.
1 /*! @file
2  @author Laurent Itti
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 #ifndef INCLUDE_NRT_CORE_MESSAGES_RGBDMESSAGE_H
36 #define INCLUDE_NRT_CORE_MESSAGES_RGBDMESSAGE_H
37 
40 
41 namespace nrt
42 {
43  namespace rgbd
44  {
45  //! Data fields for RGBDmeta
46  //! @{
47  NRT_DECLARE_MESSAGEFIELD(maxdepth, float, "Maximum depth supported by the depth sensor, in meters");
48  NRT_DECLARE_MESSAGEFIELD(shadow, uint64_t, "Value for shadow (occluded) depth pixels");
49  NRT_DECLARE_MESSAGEFIELD(nosample, uint64_t, "Value for pixels without valid disparity measurement");
50  NRT_DECLARE_MESSAGEFIELD(baseline, float, "Baseline of the depth sensor, in meters");
51  NRT_DECLARE_MESSAGEFIELD(depthfocallen, float, "Focal length of the depth sensor, in pixels");
52  NRT_DECLARE_MESSAGEFIELD(rgbfocallen, float, "Focal length of the image sensor, in pixels");
53  //! @}
54  }
55 
56  //! A splittable message to pass RGBD metadata, e.g., from a Kinect sensor
57  class RGBDmeta :
58  public nrt::CompositeMessage<NRT_MESSAGEFIELD(rgbd::maxdepth),
59  NRT_MESSAGEFIELD(rgbd::shadow),
60  NRT_MESSAGEFIELD(rgbd::nosample),
61  NRT_MESSAGEFIELD(rgbd::baseline),
62  NRT_MESSAGEFIELD(rgbd::depthfocallen),
63  NRT_MESSAGEFIELD(rgbd::rgbfocallen)>
64  { };
65 
66  namespace rgbd
67  {
68  //! Data fields for RGBDmessage
69  //! @{
70  NRT_DECLARE_MESSAGEFIELD(rgb, GenericImage, "RGB image data");
71  NRT_DECLARE_MESSAGEFIELD(depth, GenericImage, "Depth map data");
72  NRT_DECLARE_MESSAGEFIELD(meta, RGBDmeta, "Sensor metadata");
73  //! @}
74  }
75 
76  //! A splittable message to pass RGB + Depth data + metadata, e.g., from a Kinect sensor
77  class RGBDmessage :
78  public nrt::CompositeMessage<NRT_MESSAGEFIELD(rgbd::rgb),
79  NRT_MESSAGEFIELD(rgbd::depth),
80  NRT_MESSAGEFIELD(rgbd::meta)>
81  {
82  public:
83  //! Return the larger of the rgb or depth dims
84  Dims<int32> maxDims() const;
85 
86  //! Return an interpolated version of the rgb image, also possibly pixel-promoted
87  template <typename promo = void>
88  GenericImage interpolatedRGB(Dims<int32> const & newdims) const;
89 
90  //! Return an interpolated version of the depth image, also possibly pixel-promoted
91  template <typename promo = void>
92  GenericImage interpolatedDepth(Dims<int32> const & newdims) const;
93 
94  //! Return the depth map calibrated in meters with quiet_NaN values if shadow or nosample
95  /*! Scale converts from raw to meters, default assumes raw is in mm */
96  Image<PixGray<float> > depthInMeters(float const scale = 0.001F) const;
97 
98  //! Return the interpolated depth map calibrated in meters with quiet_NaN values if shadow or nosample
99  /*! Scale converts from raw to meters, default assumes raw is in mm */
100  Image<PixGray<float> > interpolatedDepthInMeters(Dims<int32> const & newdims, float const scale = 0.001F) const;
101  };
102 }
103 
104 // Include template implementation
106 
107 #endif // INCLUDE_NRT_CORE_MESSAGES_RGBDMESSAGE_H