All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DepthCamera.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: A persepective OGRE Camera with Depth Sensor
18  * Author: Nate Koenig
19  * Date: 15 July 2003
20  */
21 
22 #ifndef _RENDERING_DEPTHCAMERA_HH_
23 #define _RENDERING_DEPTHCAMERA_HH_
24 #include <string>
25 
26 #include "common/Event.hh"
27 #include "common/Time.hh"
28 
29 #include "math/Angle.hh"
30 #include "math/Pose.hh"
31 #include "math/Vector2i.hh"
32 
33 #include "sdf/sdf.hh"
34 
35 #include "rendering/Camera.hh"
36 
37 namespace Ogre
38 {
39  class Material;
40  class RenderTarget;
41  class Texture;
42  class Viewport;
43 }
44 
45 namespace gazebo
46 {
47  namespace rendering
48  {
49  class Scene;
50 
53 
56  class DepthCamera : public Camera
57  {
62  public: DepthCamera(const std::string &_namePrefix,
63  Scene *_scene, bool _autoRender = true);
64 
66  public: virtual ~DepthCamera();
67 
70  public: void Load(sdf::ElementPtr &_sdf);
71 
73  public: void Load();
74 
76  public: void Init();
77 
79  public: void Fini();
80 
83  public: void CreateDepthTexture(const std::string &_textureName);
84 
86  public: virtual void PostRender();
87 
90  public: virtual const float *GetDepthData();
91 
94  public: virtual void SetDepthTarget(Ogre::RenderTarget *_target);
95 
99  public: template<typename T>
101  { return newDepthFrame.Connect(_subscriber); }
102 
106  { newDepthFrame.Disconnect(_c); }
107 
111  public: template<typename T>
113  { return newRGBPointCloud.Connect(_subscriber); }
114 
118  { newRGBPointCloud.Disconnect(c); }
119 
120 
122  private: virtual void RenderImpl();
123 
128  private: void UpdateRenderTarget(Ogre::RenderTarget *_target,
129  Ogre::Material *_material,
130  const std::string &_matName);
131 
133  protected: Ogre::Texture *depthTexture;
134 
136  protected: Ogre::RenderTarget *depthTarget;
137 
139  protected: Ogre::Viewport *depthViewport;
140 
142  private: float *depthBuffer;
143 
145  private: Ogre::Material *depthMaterial;
146 
148  private: bool outputPoints;
149 
151  private: float *pcdBuffer;
152 
154  private: Ogre::Viewport *pcdViewport;
155 
157  private: Ogre::Material *pcdMaterial;
158 
160  private: Ogre::Texture *pcdTexture;
161 
163  private: Ogre::RenderTarget *pcdTarget;
164 
166  private: event::EventT<void(const float *, unsigned int, unsigned int,
167  unsigned int, const std::string &)> newRGBPointCloud;
168 
170  private: event::EventT<void(const float *, unsigned int, unsigned int,
171  unsigned int, const std::string &)> newDepthFrame;
172  };
174  }
175 }
176 #endif