Gazebo logo

StereoCamera.hh

Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: A stereo camera sensor using OpenGL
00022  * Author: Andrew Howard
00023  * Date: 7 Oct 2004
00024  * CVS: $Id: StereoCamera.hh,v 1.8 2004/11/13 22:23:23 inspectorg Exp $
00025  */
00026 
00027 #ifndef STEREOCAMERA_HH
00028 #define STEREOCAMERA_HH
00029 
00030 #include <stdint.h>
00031 
00032 #include "Error.hh"
00033 #include "Sensor.hh"
00034 #include "Vector.hh"
00035 #include "RenderOptions.hh"
00036 #include "GLContext.hh"
00037 
00038 // Forward Declarations
00039 class World;
00040 class WorldFile;
00041 class WorldFileNode;
00042 
00049 class StereoCamera : public Sensor
00050 {
00052   public: StereoCamera(World *world);
00053 
00055   public: virtual ~StereoCamera();
00056 
00066   public: int Init(int width, int height, double hfov, double baseline,
00067                    double nearClip, double farClip, const char *method);
00068 
00070   public: int Fini();
00071 
00073   public: void Update();
00074 
00076   public: void SetPose(GzPose pose);
00077 
00079   public: GzPose GetPose();
00080 
00082   public: double GetFOV() const {return this->hfov;}
00083 
00085   public: void GetSize(int *w, int *h);
00086 
00090   // Render the scene from the camera perspective
00091   public: void EnableImage(int camera, bool enable);
00092 
00096   // Render the scene from the camera perspective
00097   public: void EnableDisparity(int camera, bool enable);
00098 
00101   public: const unsigned char *GetImageData(int camera) const {return this->images[camera];}
00102 
00105   public: const float *GetDisparityData(int camera) const {return this->disparityImages[camera];}
00106 
00107   // Render image for given camera 
00108   private: void Render(int camera);
00109 
00110   // Render depth image for given camera
00111   private: void RenderDepth(int camera);
00112 
00113   // Render the models
00114   private: void RenderModels();
00115 
00116   // Post-process the disparity images to calculate occlusions, etc
00117   private: void ProcessDisparity();
00118 
00120   public: void SetSavePath(const char *pathname);
00121 
00123   public: void EnableSaveFrame(bool enable);
00124 
00125   // Save the camera frame
00126   private: void SaveFrame();
00127 
00129   private: GLContext imageContext, depthContext;
00130   
00131   // Rendering options
00132   private: RenderOptions renderOpt;
00133 
00134   // Image dimensions
00135   private: int imgWidth, imgHeight;
00136 
00137   // Perspective lens options
00138   private: double hfov;
00139 
00140   // Clipping planes
00141   private: double nearClip, farClip;
00142 
00143   // Camera baseline (parallel projection)
00144   private: double baseline;
00145 
00146   // Camera model
00147   private: GzHomo P, iP;
00148   
00149   // Relative camera poses
00150   private: GzPose cameraPoses[2];
00151 
00152   // Current central pose (global cs)
00153   private: GzPose pose;
00154 
00156   private: bool imageEnable[2];
00157   
00159   private: int imageSize;
00160   private: unsigned char *images[2];
00161 
00163   private: int depthSize;
00164   private: float *depthImages[2];
00165 
00167   private: bool disparityEnable[2];
00168 
00170   private: int disparitySize;
00171   private: float *disparityImages[2];
00172 
00173   // Info for saving images
00174   private: bool saveEnable;
00175   private: const char *savePathname;
00176   private: unsigned int saveCount;
00177 };
00178 
00179 
00180 #endif
00181 

Last updated 12 September 2005 21:38:45