00001
00040 #ifndef __D_BRIEF__
00041 #define __D_BRIEF__
00042
00043 #include <opencv/cv.h>
00044 #include <vector>
00045 #include <boost/dynamic_bitset.hpp>
00046
00047 namespace DVision {
00048
00050 class BRIEF
00051 {
00052 public:
00053
00055 typedef boost::dynamic_bitset<> bitset;
00056
00058 enum Type
00059 {
00060 RANDOM,
00061 RANDOM_CLOSE,
00062 };
00063
00064 public:
00065
00072 BRIEF(int nbits = 256, int patch_size = 48, Type type = RANDOM_CLOSE);
00073 virtual ~BRIEF();
00074
00079 inline int getDescriptorLengthInBits() const
00080 {
00081 return m_bit_length;
00082 }
00083
00087 inline Type getType() const
00088 {
00089 return m_type;
00090 }
00091
00095 inline int getPatchSize() const
00096 {
00097 return m_patch_size;
00098 }
00099
00110 inline void operator() (const cv::Mat &image,
00111 const std::vector<cv::KeyPoint> &points,
00112 std::vector<bitset> &descriptors,
00113 bool treat_image = true) const
00114 {
00115 compute(image, points, descriptors, treat_image);
00116 }
00117
00128 void compute(const cv::Mat &image,
00129 const std::vector<cv::KeyPoint> &points,
00130 std::vector<bitset> &descriptors,
00131 bool treat_image = true) const;
00132
00140 inline void exportPairs(std::vector<int> &x1, std::vector<int> &y1,
00141 std::vector<int> &x2, std::vector<int> &y2) const
00142 {
00143 x1 = m_x1;
00144 y1 = m_y1;
00145 x2 = m_x2;
00146 y2 = m_y2;
00147 }
00148
00156 inline void importPairs(const std::vector<int> &x1,
00157 const std::vector<int> &y1, const std::vector<int> &x2,
00158 const std::vector<int> &y2)
00159 {
00160 m_x1 = x1;
00161 m_y1 = y1;
00162 m_x2 = x2;
00163 m_y2 = y2;
00164 m_bit_length = x1.size();
00165 }
00166
00173 inline static int distance(const bitset &a, const bitset &b)
00174 {
00175 return (a^b).count();
00176 }
00177
00178 protected:
00179
00184 void generateTestPoints();
00185
00186 protected:
00187
00189 int m_bit_length;
00190
00192 int m_patch_size;
00193
00195 Type m_type;
00196
00198 std::vector<int> m_x1, m_x2;
00199 std::vector<int> m_y1, m_y2;
00200
00201 };
00202
00203 }
00204
00205 #endif
00206
00207