MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VisionQuery.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "VisionContext.hpp"
4#include "VisionIntent.hpp"
5#include "VisionOp.hpp"
6
7/**
8 * @file VisionQuery.hpp
9 * @brief Per-intent parameters and resolution into a set of VisionSequences.
10 */
11
13
14/**
15 * @brief Colour representation FindElements segments in, which decides the
16 * conversion its chain leads with.
17 *
18 * Gray leads with RgbaToGray, Hsv with RgbaToHsv (channels are then hue,
19 * saturation, value), Rgba with no conversion at all.
20 */
21enum class SegmentationSpace : uint8_t {
22 Gray,
23 Rgba,
24 Hsv,
25};
26
27/**
28 * @brief Threshold applied to the converted frame. Multichannel selection
29 * and bands live in the params themselves (ChannelMask, ChannelBand).
30 */
31using SegmentationMethod = std::variant<OtsuParams, ThresholdAdaptiveParams, ThresholdParams>;
32
33/**
34 * @brief How FindElements separates foreground from background. The default
35 * is grayscale Otsu.
36 */
41
42/**
43 * @brief Parameters for VisionIntent::FindElements.
44 */
50
51/**
52 * @brief Parameters for VisionIntent::TrackObjects.
53 *
54 * region, a normalised rectangle, restricts where new points are detected:
55 * it is written into the chain's HarrisParams and ExtractPeaksParams. The
56 * frame, pyramid and every result coordinate stay full-frame, and flow state
57 * is unaffected by changing region between calls. Points already being
58 * tracked keep being tracked wherever they move, including out of the
59 * region; only detection is confined. EstimateMotion, when also active,
60 * still covers the whole frame.
61 */
68
69/**
70 * @brief Parameters for VisionIntent::DetectFeatures.
71 *
72 * region, a normalised rectangle, restricts detection to it through the
73 * chain's HarrisParams and ExtractPeaksParams. Keypoints stay in full-frame
74 * coordinates.
75 */
79 std::optional<BoundingBox> region;
80};
81
82/**
83 * @brief Parameters for VisionIntent::DetectEdges.
84 */
88
89/**
90 * @brief Parameters for VisionIntent::EstimateMotion.
91 */
95
96/**
97 * @brief Parameters for VisionIntent::MeasureAppearance.
98 *
99 * Empty: its VisionOp (Sobel) takes no parameters. Present as a named type
100 * rather than a bare flag so VisionQuery's per-intent fields stay uniform.
101 */
103
104/**
105 * @brief Composed query: which VisionIntents are active, and each active
106 * one's parameters.
107 *
108 * A field is read by resolve() only when its VisionIntent bit is set in
109 * intents; an unset bit's field is ignored even if populated, and a set bit
110 * with no populated field resolves to nothing for that intent.
111 */
114
115 std::optional<FindElementsParams> find_elements;
116 std::optional<TrackObjectsParams> track_objects;
117 std::optional<DetectFeaturesParams> detect_features;
118 std::optional<DetectEdgesParams> detect_edges;
119 std::optional<EstimateMotionParams> estimate_motion;
120 std::optional<MeasureAppearanceParams> measure_appearance;
121};
122
123/**
124 * @brief Picks a VisionResult field to seed a later sequence's image
125 * argument with, instead of the query's own raw frame.
126 */
127using SeedAccessor = std::shared_ptr<Core::VKImage> (*)(const VisionResult&);
128
129/**
130 * @brief One VisionSequence to run, and where its image argument comes from.
131 *
132 * seed_field null means seed from the query's own raw frame. Otherwise,
133 * run sequences[seed_lane] first and pass seed_field(its result) as the
134 * image argument in place of the raw frame.
135 */
141
142/**
143 * @brief Resolve a VisionQuery into the ResolvedSequences needed to
144 * satisfy every active intent.
145 *
146 * TrackObjects and EstimateMotion, when both active, resolve into one
147 * sequence sharing a tail; neither can be split back apart afterward.
148 * Every other active intent gets its own sequence, seeded from whichever
149 * leading steps it has in common with the first sequence (matched by
150 * VisionOp and params) instead of recomputing them. Sharing happens only
151 * when neither sequence runs a step that overwrites the executor's shared
152 * output images after the shared prefix, because such a step would already
153 * have destroyed the seed. Seeded sequences are returned right after the
154 * first, unseeded ones last, and DetectEdges last of all so the edge image
155 * it hands back is not overwritten by a later sequence.
156 *
157 * @param query Active intents and their parameters.
158 * @return Ordered ResolvedSequences to run against the same frame; empty
159 * when no intent in query.intents has a populated parameter
160 * field.
161 */
162[[nodiscard]] MAYAFLUX_API std::vector<ResolvedSequence> resolve(const VisionQuery& query);
163
164} // namespace MayaFlux::Kinesis::Vision
Declarative "what to do" vocabulary, one layer above VisionOp.
Declarative description of a Kinesis::Vision processing sequence.
VisionIntent
Composable flags naming what a vision analysis should produce.
std::vector< ResolvedSequence > resolve(const VisionQuery &query)
Resolve a VisionQuery into the ResolvedSequences needed to satisfy every active intent.
std::shared_ptr< Core::VKImage >(*)(const VisionResult &) SeedAccessor
Picks a VisionResult field to seed a later sequence's image argument with, instead of the query's own...
SegmentationSpace
Colour representation FindElements segments in, which decides the conversion its chain leads with.
std::variant< OtsuParams, ThresholdAdaptiveParams, ThresholdParams > SegmentationMethod
Threshold applied to the converted frame.
Connected-component label export and color output.
Definition VisionOp.hpp:302
Parameters for VisionIntent::DetectEdges.
Parameters for VisionIntent::DetectFeatures.
Parameters for VisionIntent::EstimateMotion.
Contour filtering, trace limits, and output selection.
Definition VisionOp.hpp:326
Parameters for VisionIntent::FindElements.
Harris response parameters.
Definition VisionOp.hpp:190
Parameters for VisionIntent::MeasureAppearance.
One VisionSequence to run, and where its image argument comes from.
How FindElements separates foreground from background.
Parameters for VisionIntent::TrackObjects.
std::optional< MeasureAppearanceParams > measure_appearance
std::optional< TrackObjectsParams > track_objects
std::optional< FindElementsParams > find_elements
std::optional< EstimateMotionParams > estimate_motion
std::optional< DetectEdgesParams > detect_edges
std::optional< DetectFeaturesParams > detect_features
Composed query: which VisionIntents are active, and each active one's parameters.
Result of executing a VisionSequence on one frame.
Ordered VisionSteps and the backend chosen to execute them.
Definition VisionOp.hpp:381