SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
CVRaulMurExtNode.cpp
Go to the documentation of this file.
1 /**
2  * \file CVRaulMurExtNode.h
3  * \brief Declares the Raul Mur ORB feature detector and descriptor
4  * \details This File is based on the ORB Implementation of ORB_SLAM
5  * https://github.com/raulmur/ORB_SLAM2
6  * \date Spring 2017
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9  * \authors Marcus Hudritsch, Michael Goettlicher, Pascal Zingg, Timon Tschanz
10  * \copyright http://opensource.org/licenses/GPL-3.0
11 */
12 
13 #include <CVTypedefs.h>
14 #include <CVRaulMurExtNode.h>
15 #include <algorithm> // std::max
16 
17 //-----------------------------------------------------------------------------
18 //! Divides the current ExtractorNode into four ExtractorNodes.
19 //! The Keypoints are also divided between the four ExtractorNodes by space.
21  CVRaulMurExtNode& n2,
22  CVRaulMurExtNode& n3,
23  CVRaulMurExtNode& n4)
24 {
25  const int halfX = (int)(ceil(static_cast<float>(UR.x - UL.x) / 2));
26  const int halfY = (int)(ceil(static_cast<float>(BR.y - UL.y) / 2));
27 
28  // Define boundaries of childs
29  n1.UL = UL;
30  n1.UR = CVPoint2i(UL.x + halfX, UL.y);
31  n1.BL = CVPoint2i(UL.x, UL.y + halfY);
32  n1.BR = CVPoint2i(UL.x + halfX, UL.y + halfY);
33  n1.vKeys.reserve(vKeys.size());
34 
35  n2.UL = n1.UR;
36  n2.UR = UR;
37  n2.BL = n1.BR;
38  n2.BR = CVPoint2i(UR.x, UL.y + halfY);
39  n2.vKeys.reserve(vKeys.size());
40 
41  n3.UL = n1.BL;
42  n3.UR = n1.BR;
43  n3.BL = BL;
44  n3.BR = CVPoint2i(n1.BR.x, BL.y);
45  n3.vKeys.reserve(vKeys.size());
46 
47  n4.UL = n3.UR;
48  n4.UR = n2.BR;
49  n4.BL = n3.BR;
50  n4.BR = BR;
51  n4.vKeys.reserve(vKeys.size());
52 
53  // Associate points to childs
54  for (size_t i = 0; i < vKeys.size(); i++)
55  {
56  const CVKeyPoint& kp = vKeys[i];
57  if (kp.pt.x < n1.UR.x)
58  {
59  if (kp.pt.y < n1.BR.y)
60  n1.vKeys.push_back(kp);
61  else
62  n3.vKeys.push_back(kp);
63  }
64  else if (kp.pt.y < n1.BR.y)
65  n2.vKeys.push_back(kp);
66  else
67  n4.vKeys.push_back(kp);
68  }
69 
70  if (n1.vKeys.size() == 1)
71  n1.bNoMore = true;
72  if (n2.vKeys.size() == 1)
73  n2.bNoMore = true;
74  if (n3.vKeys.size() == 1)
75  n3.bNoMore = true;
76  if (n4.vKeys.size() == 1)
77  n4.bNoMore = true;
78 }
79 //-----------------------------------------------------------------------------
Declares the Raul Mur ORB feature detector and descriptor.
cv::Point2i CVPoint2i
Definition: CVTypedefs.h:42
cv::KeyPoint CVKeyPoint
Definition: CVTypedefs.h:60
Data structure used to subdivide the Image with key points into segments.
void DivideNode(CVRaulMurExtNode &n1, CVRaulMurExtNode &n2, CVRaulMurExtNode &n3, CVRaulMurExtNode &n4)
T ceil(T a)
Definition: Utils.h:247