CameraBridge.h
Go to the documentation of this file.
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,  // used for those cases where the conversion is done by ros
00045                         RGB, // DEPRECATED
00046                         BGR, // DEPRECATED
00047                         // used when we have to remove the bayer pattern
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   // Changes the camera parameters
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         // Converts a raw image into a rectified image
00094         void ConvertImage(cv::Mat &image) const;
00095 
00096         // Applies distortion to an undistorted point
00097         void DistortPoint(int &x, int &y) const;
00098 
00099         // The same as above
00100         void DistortPoint(float x, float y, float& distx, float& disty) const;
00101 
00102         // Returns whether there is calibration
00103         inline bool ThereIsCalibration() const 
00104         {
00105                 return m_there_is_calibration;
00106         }
00107         
00108         // Returns whether there is distortion
00109         inline bool ThereIsDistortion() const
00110         {
00111           return m_there_is_distortion;
00112         }
00113 
00114         // Returns a read-only version of the intrinsic parameters
00115         inline const cv::Mat& GetIntrinsicParameters() const
00116         {
00117                 return m_intrinsic_parameters;
00118         }
00119         
00120         // Returns a read-only version of the distortion parameters
00121         inline const cv::Mat& GetDistortionParameters() const
00122         {
00123                 return m_distortion;
00124         }
00125         
00126         // Returns trye if the camera uses a bayer pattern
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         // Creates un/distortion maps
00139         void createMaps();
00140                         
00141 protected:
00142 
00143         ImageType m_image_type; // DEPRECATED. It is ignored
00144         bool m_there_is_calibration;
00145         cv::Mat m_intrinsic_parameters; // 3x3 matrix
00146         cv::Mat m_distortion; // 4x1 vector
00147 
00148         // maps to un/distort points
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


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:48