00001
00002 #ifndef vpgl_camera_convert_h_
00003 #define vpgl_camera_convert_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <vcl_vector.h>
00013 #include <vgl/vgl_fwd.h>
00014 #include <vnl/vnl_fwd.h>
00015 #include <vpgl/vpgl_calibration_matrix.h>
00016 #include <vpgl/vpgl_perspective_camera.h>
00017 #include <vpgl/vpgl_proj_camera.h>
00018 #include <vpgl/vpgl_affine_camera.h>
00019 #include <vpgl/vpgl_rational_camera.h>
00020 #include <vpgl/vpgl_local_rational_camera.h>
00021 #include <vpgl/vpgl_generic_camera.h>
00022 #include <vpgl/file_formats/vpgl_geo_camera.h>
00023 #include <vgl/algo/vgl_h_matrix_3d.h>
00024
00025
00026 class vpgl_proj_camera_convert
00027 {
00028 public:
00029
00030 static bool convert(vpgl_rational_camera<double> const& rat_cam,
00031 vgl_point_3d<double> const& world_center,
00032 vpgl_proj_camera<double>& camera);
00033
00034
00035 static vgl_h_matrix_3d<double>
00036 norm_trans(vpgl_rational_camera<double> const& rat_cam);
00037
00038 private:
00039
00040 vpgl_proj_camera_convert();
00041 };
00042
00043
00044
00045 class vpgl_perspective_camera_convert
00046 {
00047 public:
00048
00049
00050
00051
00052
00053
00054
00055 static bool convert( vpgl_rational_camera<double> const& rat_cam,
00056 vgl_box_3d<double> const& approximation_volume,
00057 vpgl_perspective_camera<double>& camera,
00058 vgl_h_matrix_3d<double>& norm_trans);
00059
00060
00061 static bool convert_local( vpgl_rational_camera<double> const& rat_cam,
00062 vgl_box_3d<double> const& approximation_volume,
00063 vpgl_perspective_camera<double>& camera,
00064 vgl_h_matrix_3d<double>& norm_trans);
00065
00066 private:
00067 vpgl_perspective_camera_convert();
00068 };
00069
00070
00071 class vpgl_generic_camera_convert
00072 {
00073 public:
00074
00075
00076 static bool convert( vpgl_local_rational_camera<double> const& rat_cam,
00077 int ni, int nj,
00078 vpgl_generic_camera<double> & gen_cam, unsigned level = 0);
00079
00080
00081
00082 static bool convert( vpgl_local_rational_camera<double> const& rat_cam,
00083 int ni, int nj,
00084 vpgl_generic_camera<double> & gen_cam,
00085 double local_z_min, double local_z_max, unsigned level = 0);
00086
00087
00088 static bool convert( vpgl_proj_camera<double> const& prj_cam,
00089 int ni, int nj,
00090 vpgl_generic_camera<double> & gen_cam, unsigned level = 0);
00091
00092
00093 static bool convert( vpgl_perspective_camera<double> const& per_cam,
00094 int ni, int nj,
00095 vpgl_generic_camera<double> & gen_cam, unsigned level = 0);
00096 #if 0
00097 {
00098 vpgl_perspective_camera<double> nc_cam(per_cam);
00099 vpgl_proj_camera<double>* prj_cam_ptr =
00100 dynamic_cast<vpgl_proj_camera<double>*>(&nc_cam);
00101 if (!prj_cam_ptr) return false;
00102 return convert(*prj_cam_ptr, ni, nj, gen_cam,level);
00103 }
00104 #endif
00105
00106 static bool convert_with_margin( vpgl_perspective_camera<double> const& per_cam,
00107 int ni, int nj,
00108 vpgl_generic_camera<double> & gen_cam, int margin, unsigned level = 0);
00109
00110
00111 static bool convert( vpgl_affine_camera<double> const& aff_cam,
00112 int ni, int nj, vpgl_generic_camera<double> & gen_cam, unsigned level = 0);
00113
00114
00115 static bool convert( vpgl_camera_double_sptr const& camera, int ni, int nj,
00116 vpgl_generic_camera<double> & gen_cam, unsigned level = 0);
00117
00118
00119 static bool convert( vpgl_geo_camera& geocam, int ni, int nj, double height,
00120 vpgl_generic_camera<double> & gen_cam, unsigned level = 0);
00121
00122
00123 private:
00124
00125 static bool
00126 upsample_rays(vcl_vector<vgl_ray_3d<double> > const& ray_nbrs,
00127 vgl_ray_3d<double> const& ray,
00128 vcl_vector<vgl_ray_3d<double> >& interp_rays);
00129
00130 static vgl_ray_3d<double> interp_pair(vgl_ray_3d<double> const& r0,
00131 vgl_ray_3d<double> const& r1,
00132 double n_grid);
00133 vpgl_generic_camera_convert();
00134 };
00135
00136 #endif // vpgl_camera_convert_h_