MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / divide_node

Method divide_node

src/PLPSLAM/feature/orb_extractor_node.cc:31–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 {
30
31 std::array<orb_extractor_node, 4> orb_extractor_node::divide_node()
32 {
33 // Half width/height of the allocated patch area
34 const unsigned int half_x = cvCeil((pt_end_.x - pt_begin_.x) / 2.0);
35 const unsigned int half_y = cvCeil((pt_end_.y - pt_begin_.y) / 2.0);
36
37 // Four new child nodes
38 std::array<orb_extractor_node, 4> child_nodes;
39
40 // A position of center top, left center, center, right center, and center bottom
41 // These positions are used to determine new split areas
42 const auto pt_top = cv::Point2i(pt_begin_.x + half_x, pt_begin_.y);
43 const auto pt_left = cv::Point2i(pt_begin_.x, pt_begin_.y + half_y);
44 const auto pt_center = cv::Point2i(pt_begin_.x + half_x, pt_begin_.y + half_y);
45 const auto pt_right = cv::Point2i(pt_end_.x, pt_begin_.y + half_y);
46 const auto pt_bottom = cv::Point2i(pt_begin_.x + half_x, pt_end_.y);
47
48 // Assign new patch border for each child nodes
49 child_nodes.at(0).pt_begin_ = pt_begin_;
50 child_nodes.at(0).pt_end_ = pt_center;
51 child_nodes.at(1).pt_begin_ = pt_top;
52 child_nodes.at(1).pt_end_ = pt_right;
53 child_nodes.at(2).pt_begin_ = pt_left;
54 child_nodes.at(2).pt_end_ = pt_bottom;
55 child_nodes.at(3).pt_begin_ = pt_center;
56 child_nodes.at(3).pt_end_ = pt_end_;
57
58 // Memory reservation for child nodes
59 for (auto &node : child_nodes)
60 {
61 node.keypts_.reserve(keypts_.size());
62 }
63
64 // Distribute keypoints to child nodes
65 for (const auto &keypt : keypts_)
66 {
67 unsigned int idx = 0;
68 if (pt_begin_.x + half_x <= keypt.pt.x)
69 {
70 idx += 1;
71 }
72 if (pt_begin_.y + half_y <= keypt.pt.y)
73 {
74 idx += 2;
75 }
76 child_nodes.at(idx).keypts_.push_back(keypt);
77 }
78
79 return child_nodes;
80 }
81
82 } // namespace feature
83} // namespace PLPSLAM

Callers 1

Calls 3

reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected