MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ resolve()

MAYAFLUX_API std::vector< ResolvedSequence > MayaFlux::Kinesis::Vision::resolve ( const VisionQuery &  query)

Resolve a VisionQuery into the ResolvedSequences needed to satisfy every active intent.

TrackObjects and EstimateMotion, when both active, resolve into one sequence sharing a tail; neither can be split back apart afterward. Every other active intent gets its own sequence, seeded from whichever leading steps it has in common with the first sequence (matched by VisionOp and params) instead of recomputing them. Sharing happens only when neither sequence runs a step that overwrites the executor's shared output images after the shared prefix, because such a step would already have destroyed the seed. Seeded sequences are returned right after the first, unseeded ones last, and DetectEdges last of all so the edge image it hands back is not overwritten by a later sequence.

Parameters
queryActive intents and their parameters.
Returns
Ordered ResolvedSequences to run against the same frame; empty when no intent in query.intents has a populated parameter field.

Definition at line 170 of file VisionQuery.cpp.

171{
172 std::vector<VisionStep> flow_lane;
173 std::vector<std::vector<VisionStep>> other_chains;
174
175 auto append_to_flow_lane = [&](VisionSequence chain) {
176 auto steps = std::move(chain.steps);
177 if (!flow_lane.empty() && !steps.empty() && steps.front().op == VisionOp::RgbaToGray)
178 steps.erase(steps.begin());
179 flow_lane.insert(flow_lane.end(),
180 std::make_move_iterator(steps.begin()),
181 std::make_move_iterator(steps.end()));
182 };
183
184 if (has_flag(query.intents, VisionIntent::TrackObjects) && query.track_objects)
185 append_to_flow_lane(track_objects_chain(*query.track_objects));
186
187 if (has_flag(query.intents, VisionIntent::EstimateMotion) && query.estimate_motion)
188 append_to_flow_lane(estimate_motion_chain(*query.estimate_motion));
189
190 if (has_flag(query.intents, VisionIntent::FindElements) && query.find_elements)
191 other_chains.push_back(find_elements_chain(*query.find_elements).steps);
192
193 if (has_flag(query.intents, VisionIntent::DetectFeatures) && query.detect_features)
194 other_chains.push_back(detect_features_chain(*query.detect_features).steps);
195
196 if (has_flag(query.intents, VisionIntent::MeasureAppearance) && query.measure_appearance)
197 other_chains.push_back(measure_appearance_chain(*query.measure_appearance).steps);
198
199 if (has_flag(query.intents, VisionIntent::DetectEdges) && query.detect_edges)
200 other_chains.push_back(detect_edges_chain(*query.detect_edges).steps);
201
202 std::vector<ResolvedSequence> sequences;
203 sequences.reserve(1 + other_chains.size());
204 std::optional<size_t> reference_index;
205
206 if (!flow_lane.empty()) {
207 sequences.push_back({ .sequence = VisionSequence { .steps = std::move(flow_lane) } });
208 reference_index = 0;
209 }
210
211 std::vector<ResolvedSequence> seeded;
212 std::vector<ResolvedSequence> unseeded;
213
214 for (auto& steps : other_chains) {
215 if (!reference_index) {
216 sequences.push_back({ .sequence = VisionSequence { .steps = std::move(steps) } });
217 reference_index = 0;
218 continue;
219 }
220
221 const auto& reference = sequences[*reference_index].sequence.steps;
222 ResolvedSequence resolved;
223 const size_t shared = shared_prefix_length(reference, steps);
224 if (shared > 0) {
225 resolved.seed_lane = *reference_index;
226 resolved.seed_field = seed_accessor_for(reference[shared - 1].op);
227 steps.erase(steps.begin(), steps.begin() + static_cast<std::ptrdiff_t>(shared));
228 }
229 resolved.sequence = VisionSequence { .steps = std::move(steps) };
230 (resolved.seed_field ? seeded : unseeded).push_back(std::move(resolved));
231 }
232
233 sequences.insert(sequences.end(), std::make_move_iterator(seeded.begin()), std::make_move_iterator(seeded.end()));
234 sequences.insert(sequences.end(), std::make_move_iterator(unseeded.begin()), std::make_move_iterator(unseeded.end()));
235
236 return sequences;
237}
BufferProcessingChain * chain
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
Ordered VisionSteps and the backend chosen to execute them.
Definition VisionOp.hpp:381

References chain, MayaFlux::Kinesis::Vision::VisionQuery::detect_edges, MayaFlux::Kinesis::Vision::VisionQuery::detect_features, DetectEdges, DetectFeatures, MayaFlux::Kinesis::Vision::VisionQuery::estimate_motion, EstimateMotion, MayaFlux::Kinesis::Vision::VisionQuery::find_elements, FindElements, MayaFlux::Kinesis::Vision::VisionQuery::intents, MayaFlux::Kinesis::Vision::VisionQuery::measure_appearance, MeasureAppearance, RgbaToGray, MayaFlux::Kinesis::Vision::ResolvedSequence::seed_field, MayaFlux::Kinesis::Vision::ResolvedSequence::seed_lane, MayaFlux::Kinesis::Vision::ResolvedSequence::sequence, MayaFlux::Kinesis::Vision::VisionSequence::steps, MayaFlux::Kinesis::Vision::VisionQuery::track_objects, and TrackObjects.

Referenced by MayaFlux::Yantra::VisionAnalyzer::advance(), MayaFlux::Yantra::VisionAnalyzer::analyze_resolved(), and MayaFlux::Yantra::Vision::VisionMatrix::result().

+ Here is the caller graph for this function: