MCPcopy Create free account
hub / github.com/AutonomousFieldRoboticsLab/SVIn / compute

Method compute

pose_graph/ThirdParty/DVision/BRIEF256.h:175–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173
174template <int Bits>
175void BRIEF_t<Bits>::compute(const cv::Mat& image,
176 const std::vector<cv::KeyPoint>& points,
177 std::vector<bitset>& descriptors,
178 bool treat_image) const {
179 const float sigma = 2.f;
180 const cv::Size ksize(9, 9);
181
182 cv::Mat im;
183 if (treat_image) {
184 cv::Mat aux;
185 if (image.depth() == 3) {
186 cv::cvtColor(image, aux, cv::COLOR_RGB2GRAY);
187 } else {
188 aux = image;
189 }
190
191 cv::GaussianBlur(aux, im, ksize, sigma, sigma);
192
193 } else {
194 im = image;
195 }
196
197 assert(im.type() == CV_8UC1);
198 assert(im.isContinuous());
199
200 // use im now
201 const int W = im.cols;
202 const int H = im.rows;
203
204 descriptors.resize(points.size());
205 typename std::vector<bitset>::iterator dit;
206
207 std::vector<cv::KeyPoint>::const_iterator kit;
208
209 int x1, y1, x2, y2;
210
211 dit = descriptors.begin();
212 for (kit = points.begin(); kit != points.end(); ++kit, ++dit) {
213 dit->reset();
214
215 for (unsigned int i = 0; i < m_x1.size(); ++i) {
216 x1 = (int)(kit->pt.x + m_x1[i]);
217 y1 = (int)(kit->pt.y + m_y1[i]);
218 x2 = (int)(kit->pt.x + m_x2[i]);
219 y2 = (int)(kit->pt.y + m_y2[i]);
220
221 if (x1 >= 0 && x1 < W && y1 >= 0 && y1 < H && x2 >= 0 && x2 < W && y2 >= 0 && y2 < H) {
222 if (im.ptr<unsigned char>(y1)[x1] < im.ptr<unsigned char>(y2)[x2]) {
223 dit->set(i);
224 }
225 } // if (x,y)_1 and (x,y)_2 are in the image
226 } // for each (x,y)
227 } // for each keypoint
228}
229
230template <int Bits>
231void BRIEF_t<Bits>::generateTestPoints() {

Callers

nothing calls this directly

Calls 5

depthMethod · 0.80
setMethod · 0.80
typeMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected