00001 #ifndef IMAGE_H 00002 #define IMAGE_H 00003 00004 #include "opencv2/core/core.hpp" 00005 #include "opencv2/features2d/features2d.hpp" 00006 #include <image_geometry/stereo_camera_model.h> 00007 #include "utils.h" 00008 00009 using namespace std; 00010 using namespace cv; 00011 00012 namespace haloc 00013 { 00014 00015 class Image 00016 { 00017 00018 public: 00019 00020 // Class constructor 00021 Image(); 00022 00023 struct Params 00024 { 00025 //Default constructor sets all values to defaults. 00026 Params(); 00027 00028 // Class parameters 00029 string desc_type; 00030 string desc_matching_type; 00031 double desc_thresh_ratio; 00032 int min_matches; 00033 int epipolar_thresh; 00034 int b_width; 00035 int b_height; 00036 int b_max_features; 00037 00038 // Default values 00039 static const double DEFAULT_DESC_THRESH_RATIO = 0.8; 00040 static const int DEFAULT_MIN_MATCHES = 20; 00041 static const int DEFAULT_EPIPOLAR_THRESH = 1; 00042 static const int DEFAULT_B_WIDTH = 40; 00043 static const int DEFAULT_B_HEIGHT = 40; 00044 static const int DEFAULT_B_MAX_FEATURES = 3; 00045 }; 00046 00047 // Set the parameter struct 00048 void setParams(const Params& params); 00049 00050 // Return current parameters 00051 inline Params params() const { return params_; } 00052 00053 // Compute the keypoints and descriptors for one image (mono) 00054 bool setMono(int id, const Mat& img); 00055 00056 // Compute the keypoints, descriptors and 3d points for two images (stereo) 00057 bool setStereo(int id, const Mat& img_l, const Mat& img_r); 00058 00059 // Save the camera model 00060 void setCameraModel(image_geometry::StereoCameraModel stereo_camera_model); 00061 00062 // Get/set the id 00063 int getId(); 00064 void setId(int id); 00065 00066 // Get/set the keypoints of the image (left for stereo) 00067 vector<KeyPoint> getKp(); 00068 void setKp(vector<KeyPoint> kp); 00069 00070 // Get/set the descriptors of the image (left for stereo) 00071 Mat getDesc(); 00072 void setDesc(Mat desc); 00073 00074 // Get/set the 3D points 00075 vector<Point3f> get3D(); 00076 void set3D(vector<Point3f> p3d); 00077 00078 // Bucket features 00079 vector<DMatch> bucketFeatures(vector<DMatch> matches, 00080 vector<KeyPoint> kp); 00081 00082 private: 00083 00084 Params params_; 00085 image_geometry::StereoCameraModel 00086 stereo_camera_model_; 00087 int id_; 00088 vector<KeyPoint> kp_; 00089 Mat desc_; 00090 vector<Point3f> points_3d_; 00091 }; 00092 00093 } // namespace 00094 00095 #endif // IMAGE_H