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

Method compute

pose_graph/ThirdParty/DVision/BRIEF.cpp:34–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32// ---------------------------------------------------------------------------
33
34void BRIEF::compute(const cv::Mat& image,
35 const std::vector<cv::KeyPoint>& points,
36 std::vector<bitset>& descriptors,
37 bool treat_image) const {
38 const float sigma = 2.f;
39 const cv::Size ksize(9, 9);
40
41 cv::Mat im;
42 if (treat_image) {
43 cv::Mat aux;
44 if (image.depth() == 3) {
45 cv::cvtColor(image, aux, cv::COLOR_RGB2GRAY);
46 } else {
47 aux = image;
48 }
49
50 cv::GaussianBlur(aux, im, ksize, sigma, sigma);
51
52 } else {
53 im = image;
54 }
55
56 assert(im.type() == CV_8UC1);
57 assert(im.isContinuous());
58
59 // use im now
60 const int W = im.cols;
61 const int H = im.rows;
62
63 descriptors.resize(points.size());
64 std::vector<bitset>::iterator dit;
65
66 std::vector<cv::KeyPoint>::const_iterator kit;
67
68 int x1, y1, x2, y2;
69
70 dit = descriptors.begin();
71 for (kit = points.begin(); kit != points.end(); ++kit, ++dit) {
72 dit->resize(m_bit_length);
73 dit->reset();
74
75 for (unsigned int i = 0; i < m_x1.size(); ++i) {
76 x1 = (int)(kit->pt.x + m_x1[i]);
77 y1 = (int)(kit->pt.y + m_y1[i]);
78 x2 = (int)(kit->pt.x + m_x2[i]);
79 y2 = (int)(kit->pt.y + m_y2[i]);
80
81 if (x1 >= 0 && x1 < W && y1 >= 0 && y1 < H && x2 >= 0 && x2 < W && y2 >= 0 && y2 < H) {
82 if (im.ptr<unsigned char>(y1)[x1] < im.ptr<unsigned char>(y2)[x2]) {
83 dit->set(i);
84 }
85 } // if (x,y)_1 and (x,y)_2 are in the image
86
87 } // for each (x,y)
88 } // for each keypoint
89}
90
91// ---------------------------------------------------------------------------

Callers 4

describeMethod · 0.45
describeAsMethod · 0.45
computeBRISKPointMethod · 0.45
operator()Method · 0.45

Calls 5

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

Tested by

no test coverage detected