10 #include "internal/RGBPixel.h"
11 #include "internal/contours.h"
40 std::pair<int32_t, int32_t> xy;
41 XY(int32_t x_, int32_t y_) : x(x_), y(y_) {
42 xy = std::make_pair(x, y);
44 bool operator<(
const XY &rhs)
const {
53 RGBXY(uint8_t r, uint8_t g, uint8_t b, int32_t x, int32_t y) : color(r, g, b), position{x, y} {
58 typedef std::shared_ptr<Node> Node_ptr;
68 std::unique_ptr<std::vector<RGBXY>> m_pixels;
69 std::set<Node_ptr> m_edges{};
73 std::set<XY> m_edge_pixels{};
76 inline Node(int32_t
id, std::unique_ptr<std::vector<RGBXY>> &pixels)
77 : m_id(
id), m_pixels(std::move(pixels)) {
82 std::array<int32_t, 4> bounding_box_xywh()
const;
83 std::array<int, 4> create_binary_image(std::vector<uint8_t> &binary)
const;
90 void compute_contour();
93 inline int32_t id()
const {
96 inline size_t area()
const {
97 return m_pixels->size();
99 inline const std::set<Node_ptr> &edges()
const {
102 inline size_t num_edges()
const {
103 return m_edges.size();
105 inline const std::vector<RGBXY> &get_pixels()
const {
113 void add_pixels(
const std::vector<RGBXY> &new_pixels);
114 void add_edge_pixel(
const XY edge_pixel);
115 void clear_edge_pixels();
119 inline void add_edge(
const Node_ptr &node) {
120 m_edges.insert(node);
122 inline void remove_edge(
const Node_ptr &node) {
125 inline void remove_all_edges() {