00001
00034 #ifndef __CAMERA_BRIDGE__
00035 #define __CAMERA_BRIDGE__
00036
00037 #include <cv.h>
00038
00039 class CameraBridge
00040 {
00041 public:
00042 enum ImageType
00043 {
00044 BW,
00045 RGB,
00046 BGR,
00047
00048 BAYER_BG,
00049 BAYER_GB,
00050 BAYER_RG,
00051 BAYER_GR
00052 };
00053
00054 public:
00055
00056 CameraBridge();
00057
00058 CameraBridge(int w, int h,
00059 float cx, float cy, float fx, float fy);
00060
00061 CameraBridge(int w, int h,
00062 float cx, float cy, float fx, float fy,
00063 float k1, float k2, float p1, float p2);
00064
00065 void SetParameters(int w, int h,
00066 float cx, float cy, float fx, float fy);
00067
00068 void SetParameters(int w, int h,
00069 float cx, float cy, float fx, float fy,
00070 float k1, float k2, float p1, float p2);
00071
00072 CameraBridge(ImageType _imageType);
00073
00074 CameraBridge(ImageType _imageType,
00075 int w, int h,
00076 float cx, float cy, float fx, float fy);
00077
00078 CameraBridge(ImageType _imageType,
00079 int w, int h,
00080 float cx, float cy, float fx, float fy,
00081 float k1, float k2, float p1, float p2);
00082
00083
00084 void SetParameters(ImageType _imageType,
00085 int w, int h,
00086 float cx, float cy, float fx, float fy);
00087
00088 void SetParameters(ImageType _imageType,
00089 int w, int h,
00090 float cx, float cy, float fx, float fy,
00091 float k1, float k2, float p1, float p2);
00092
00093
00094 void ConvertImage(cv::Mat &image) const;
00095
00096
00097 void DistortPoint(int &x, int &y) const;
00098
00099
00100 void DistortPoint(float x, float y, float& distx, float& disty) const;
00101
00102
00103 inline bool ThereIsCalibration() const
00104 {
00105 return m_there_is_calibration;
00106 }
00107
00108
00109 inline bool ThereIsDistortion() const
00110 {
00111 return m_there_is_distortion;
00112 }
00113
00114
00115 inline const cv::Mat& GetIntrinsicParameters() const
00116 {
00117 return m_intrinsic_parameters;
00118 }
00119
00120
00121 inline const cv::Mat& GetDistortionParameters() const
00122 {
00123 return m_distortion;
00124 }
00125
00126
00127 inline bool usesBayer() const
00128 {
00129 return
00130 m_image_type == BAYER_BG ||
00131 m_image_type == BAYER_GB ||
00132 m_image_type == BAYER_RG ||
00133 m_image_type == BAYER_GR;
00134 }
00135
00136 protected:
00137
00138
00139 void createMaps();
00140
00141 protected:
00142
00143 ImageType m_image_type;
00144 bool m_there_is_calibration;
00145 cv::Mat m_intrinsic_parameters;
00146 cv::Mat m_distortion;
00147
00148
00149 bool m_there_is_distortion;
00150 cv::Mat m_remap_1, m_remap_2;
00151
00152 int m_image_width;
00153 int m_image_height;
00154
00155 };
00156
00157 #endif