00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
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
00091 public: void EnableImage(int camera, bool enable);
00092
00096
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
00108 private: void Render(int camera);
00109
00110
00111 private: void RenderDepth(int camera);
00112
00113
00114 private: void RenderModels();
00115
00116
00117 private: void ProcessDisparity();
00118
00120 public: void SetSavePath(const char *pathname);
00121
00123 public: void EnableSaveFrame(bool enable);
00124
00125
00126 private: void SaveFrame();
00127
00129 private: GLContext imageContext, depthContext;
00130
00131
00132 private: RenderOptions renderOpt;
00133
00134
00135 private: int imgWidth, imgHeight;
00136
00137
00138 private: double hfov;
00139
00140
00141 private: double nearClip, farClip;
00142
00143
00144 private: double baseline;
00145
00146
00147 private: GzHomo P, iP;
00148
00149
00150 private: GzPose cameraPoses[2];
00151
00152
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
00174 private: bool saveEnable;
00175 private: const char *savePathname;
00176 private: unsigned int saveCount;
00177 };
00178
00179
00180 #endif
00181