MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Features.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Core {
6class VKImage;
7}
8
10
11/**
12 * @brief Axis-aligned bounding box in normalised image coordinates.
13 *
14 * Origin is top-left, x and y in [0, 1], +Y down. Distinct from
15 * Kinesis::AABB2D which is NDC with center origin and +Y up.
16 *
17 * Use to_ndc() to convert to AABB2D for Forma hit testing.
18 */
20 float x {};
21 float y {};
22 float w {};
23 float h {};
24 float confidence { 1.0F };
25 uint32_t label_id {};
26
27 /**
28 * @brief Convert to NDC AABB2D for use with Portal::Forma::Element.
29 *
30 * Maps [0, 1] image space to [-1, 1] NDC, flipping Y axis.
31 */
32 [[nodiscard]] Kinesis::AABB2D to_ndc() const noexcept
33 {
34 return {
35 .min = { x * 2.0F - 1.0F, 1.0F - (y + h) * 2.0F },
36 .max = { (x + w) * 2.0F - 1.0F, 1.0F - y * 2.0F },
37 };
38 }
39};
40
41/**
42 * @brief Closed contour extracted from a binary mask.
43 *
44 * Points are in normalised image coordinates [0, 1], top-left origin.
45 */
46struct Contour {
47 static constexpr uint32_t no_parent = 0xFFFFFFFFU; ///< Outer contour parent sentinel.
48
49 std::vector<glm::vec2> points;
50 float area; ///< Pixel coverage divided by total image area.
51 float perimeter; ///< Closed boundary length in pixels.
52
53 /**
54 * @brief no_parent for an outer contour. For a hole contour, the label id
55 * (1-based) of the foreground component this hole is
56 * enclosed by.
57 */
58 uint32_t parent_label { no_parent };
59
60 /**
61 * @brief 1-based label id of the component this contour traces, matching
62 * ComponentResult::boxes and BoundingBox::label_id numbering, and
63 * the value written per pixel in ConnectedComponents' device
64 * label buffer. 0 for a hole contour: a hole has no foreground
65 * pixels of its own to select by label, it is already absent
66 * from the label buffer wherever it opens through the parent's
67 * silhouette.
68 */
69 uint32_t label_id { 0 };
70};
71
72/**
73 * @brief Single interest point produced by a corner or blob detector.
74 *
75 * Position is in normalised image coordinates [0, 1], top-left origin.
76 */
77struct Keypoint {
78 glm::vec2 position;
79 float response;
80 float scale;
81 float angle;
82};
83
84/**
85 * @brief Image captured mid-pipeline by a Snapshot step.
86 *
87 * The CPU executor fills pixels, a normalised float buffer in the format
88 * active at the snapshot point. The GPU executor fills image instead: a copy
89 * of the working image that later steps do not overwrite, valid until the
90 * next run on the same executor. channels distinguishes single-channel
91 * (grayscale, Harris response) from three-channel (HSV) and four-channel
92 * (RGBA).
93 */
95 std::vector<float> pixels;
96 std::shared_ptr<Core::VKImage> image;
97 uint32_t w { 0 };
98 uint32_t h { 0 };
99 uint32_t channels { 0 };
100};
101
102} // namespace MayaFlux::Kinesis::Vision
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:63
Kinesis::AABB2D to_ndc() const noexcept
Convert to NDC AABB2D for use with Portal::Forma::Element.
Definition Features.hpp:32
Axis-aligned bounding box in normalised image coordinates.
Definition Features.hpp:19
float perimeter
Closed boundary length in pixels.
Definition Features.hpp:51
float area
Pixel coverage divided by total image area.
Definition Features.hpp:50
uint32_t parent_label
no_parent for an outer contour.
Definition Features.hpp:58
uint32_t label_id
1-based label id of the component this contour traces, matching ComponentResult::boxes and BoundingBo...
Definition Features.hpp:69
static constexpr uint32_t no_parent
Outer contour parent sentinel.
Definition Features.hpp:47
std::vector< glm::vec2 > points
Definition Features.hpp:49
Closed contour extracted from a binary mask.
Definition Features.hpp:46
Single interest point produced by a corner or blob detector.
Definition Features.hpp:77
std::shared_ptr< Core::VKImage > image
Definition Features.hpp:96
Image captured mid-pipeline by a Snapshot step.
Definition Features.hpp:94