00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __OMNI_GRAPHIC_CARD_CONVERTER__
00021 #define __OMNI_GRAPHIC_CARD_CONVERTER__
00022
00023 #include "OmniConfig.hh"
00024 #include "OmniAngle.hh"
00025 #ifdef WIN32
00026 #include "wgl_window_management.h"
00027 #else
00028 #include "glx_window_management.h"
00029 #endif
00030
00031 #include <GL/gl.h>
00032 #include <GL/glu.h>
00033 #include <GL/glext.h>
00034 #include <Cg/cg.h>
00035 #include <Cg/cgGL.h>
00036
00037
00038 #include <cv.h>
00039 #include <highgui.h>
00040
00041
00047 class OmniGCardConverter {
00048 public:
00049
00071 OmniGCardConverter( double min_radius,
00072 double max_radius,
00073 double omni_center_x,
00074 double omni_center_y,
00075 unsigned int video_width,
00076 unsigned int video_height,
00077 char *program_name = "omnigcardconverter_hardware",
00078 char *vertex_program_file_name = "data/shaders/vertex_shader.cg",
00079 char *vertex_program_name = "vertex_shader_main",
00080 char *fragment_program_file_name = "data/shaders/pixel_shader.cg",
00081 char *fragment_program_name = "pixel_shader_main",
00082 bool flipped_mode = false );
00083
00084 virtual ~OmniGCardConverter();
00085
00091 void angle_type_conversion( const OmniAngle<double> &in_double_interval,
00092 OmniAngle<int> &out_int_interval );
00093
00103 IplImage* omni2pano( IplImage *omni_frame, const OmniAngle<double> &IN_interval );
00104
00113 IplImage* omni2pano( IplImage *omni_frame, const OmniAngle<int> &IN_interval );
00114
00125 void pano2omni_xy( CvPoint *pano_point,
00126 double theta_start,
00127 CvPoint *omni_point );
00128
00129 double get_min_radius();
00130 double get_max_radius();
00131 double get_omni_center_x();
00132 double get_omni_center_y();
00133
00135 bool is_initialized ();
00136
00143 static bool check_for_3d_gcard_availability ();
00144
00145 private:
00146 #ifdef WIN32
00147
00148 void setVSync(int interval = 1 );
00149 #endif
00150
00155 static int check_for_cg_error( const char *situation, char *prg_name, CGcontext cg_ctx );
00156
00163 int get_texturized_video_size( int video_width, int video_height );
00164
00169 void gl_paint ( float slide = 0.0f );
00170
00171 private:
00172 double _min_radius;
00173 double _max_radius;
00174
00176 int _pano_width;
00177
00179 int _pano_height;
00180
00181 double _omni_center_x;
00182 double _omni_center_y;
00183
00185 unsigned int _video_height;
00186 unsigned int _video_width;
00187
00189 unsigned int _hw_video_width;
00190
00192 unsigned int _hw_video_height;
00193
00195 bool _flipped_mode;
00196
00198 bool _initialized;
00199
00204 CGcontext _cg_context;
00205 CGprofile _cg_vertex_profile, _cg_fragment_profile;
00206 CGprogram _cg_vertex_program, _cg_fragment_program;
00207 CGparameter _cg_vertex_param_min_radius_on_max_radius;
00208 CGparameter _cg_fragment_param_omni_tex;
00209 CGparameter _cg_fragment_param_center_x;
00210 CGparameter _cg_fragment_param_center_y;
00211 CGparameter _cg_fragment_param_width_on_height;
00212 CGparameter _cg_fragment_param_slide;
00213
00214 char *_program_name;
00215 char *_vertex_program_file_name;
00216 char *_vertex_program_name;
00217 char *_fragment_program_file_name;
00218 char *_fragment_program_name;
00219
00220 #ifdef WIN32
00221 typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
00222 PFNWGLSWAPINTERVALFARPROC _wglSwapIntervalEXT;
00223
00224 Application _g_application;
00225 GL_Window _g_window;
00226 Keys _g_keys;
00227 #else
00228 Display *_dpy;
00229 Window _win;
00230 #endif
00231
00232 };
00233
00234
00235
00236 #endif
00237