Go to the documentation of this file.00001 #ifndef __fovis_pyramid_level_hpp__
00002 #define __fovis_pyramid_level_hpp__
00003
00004 #include <vector>
00005 #include <Eigen/Core>
00006 #include <Eigen/Geometry>
00007
00008 #include "keypoint.hpp"
00009 #include "intensity_descriptor.hpp"
00010 #include "grid_filter.hpp"
00011
00012 namespace fovis
00013 {
00014
00021 class PyramidLevel
00022 {
00023 public:
00024 PyramidLevel(int width, int height, int level_num, int feature_window_size,
00025 GridKeyPointFilter& grid_filter);
00026 ~PyramidLevel();
00027
00028 const uint8_t* getGrayscaleImage() const {
00029 return _raw_gray;
00030 }
00031
00032 int getGrayscaleImageStride() const {
00033 return _raw_gray_stride;
00034 }
00035
00036 const uint8_t* getDescriptor(int i) const {
00037 return _descriptors + i * getDescriptorStride();
00038 }
00039
00040
00041 int getDescriptorStride() const {
00042 return _descriptor_extractor->getDescriptorStride();
00043 }
00044
00045 int getNumKeypoints() const {
00046 return _num_keypoints;
00047 }
00048
00049 int getDescriptorLength() const {
00050 return _descriptor_extractor->getDescriptorLength();
00051 }
00052
00053 const KeyPoint& getKeypoint(int i) const {
00054 return _keypoints[i].kp;
00055 }
00056
00057 const Eigen::Vector4d& getKeypointXYZW(int i) const {
00058 return _keypoints[i].xyzw;
00059 }
00060
00061 float getKeypointRectBaseU(int kp_index) const {
00062 return _keypoints[kp_index].rect_base_uv(0);
00063 }
00064
00065 float getKeypointRectBaseV(int kp_index) const {
00066 return _keypoints[kp_index].rect_base_uv(1);
00067 }
00068
00069 const Eigen::Vector2d& getKeypointRectBaseUV(int kp_index) const {
00070 return _keypoints[kp_index].rect_base_uv;
00071 }
00072
00073 const KeypointData* getKeypointData(int i) const {
00074 return &_keypoints[i];
00075 }
00076
00077 KeypointData* getKeypointData(int i) {
00078 return &_keypoints[i];
00079 }
00080
00081 int getLevelNum() const { return _level_num; }
00082
00083 void populateDescriptorInterp(float x, float y, uint8_t* descriptor) const;
00084
00085 void populateDescriptorAligned(int x, int y, uint8_t* descriptor) const;
00086
00087 void populateDescriptorsInterp(const KeypointData* keypoints,
00088 int num_keypoints,
00089 uint8_t* descriptors) const;
00090
00091 void populateDescriptorsAligned(const KeypointData* keypoints,
00092 int num_keypoints,
00093 uint8_t* descriptors) const;
00094
00095 int getWidth() const { return _width; }
00096 int getHeight() const { return _height; }
00097
00098 bool isLegalKeypointCoordinate(float x, float y) const {
00099 return x >= _keypoint_min_x && x <= _keypoint_max_x &&
00100 y >= _keypoint_min_y && y <= _keypoint_max_y;
00101 }
00102
00103 const int* getDescriptorIndexOffsets() const {
00104 return _descriptor_extractor->getDescriptorIndexOffsets();
00105 }
00106
00107 const std::vector<KeyPoint>& getInitialFeatures() const {
00108 return _initial_keypoints;
00109 }
00110
00111 int getNumDetectedKeypoints() const {
00112 return _num_detected_keypoints;
00113 }
00114
00115 private:
00116 friend class OdometryFrame;
00117 friend class StereoFrame;
00118
00119 void increase_capacity(int new_capacity);
00120
00121 uint8_t* _raw_gray;
00122 int _raw_gray_stride;
00123
00124 std::vector<KeyPoint> _initial_keypoints;
00125 int _num_detected_keypoints;
00126
00127 GridKeyPointFilter _grid_filter;
00128
00129 KeypointData* _keypoints;
00130 int _num_keypoints;
00131 int _keypoints_capacity;
00132
00133 uint8_t* _descriptors;
00134
00135 int _keypoint_min_x;
00136 int _keypoint_min_y;
00137 int _keypoint_max_x;
00138 int _keypoint_max_y;
00139
00140 int _width;
00141 int _height;
00142 int _level_num;
00143
00144 uint8_t* _pyrbuf;
00145
00146 IntensityDescriptorExtractor * _descriptor_extractor;
00147 };
00148
00149 }
00150 #endif