9 template <
typename Params>
12 if (Kinesis::Vision::has_flag(intents, intent) && !params)
20 Kinesis::Vision::VisionQuery completed(Kinesis::Vision::VisionQuery query)
22 const auto intents = query.intents;
23 complete(query.find_elements, intents, VisionIntent::FindElements);
24 complete(query.track_objects, intents, VisionIntent::TrackObjects);
25 complete(query.detect_features, intents, VisionIntent::DetectFeatures);
26 complete(query.detect_edges, intents, VisionIntent::DetectEdges);
27 complete(query.estimate_motion, intents, VisionIntent::EstimateMotion);
28 complete(query.measure_appearance, intents, VisionIntent::MeasureAppearance);
36 std::optional<VisionExtractMode> extract,
39 return std::make_shared<VisionMatrix>(query,
extract, context);
44 std::optional<VisionExtractMode> extract,
47 create_operation<VisionAnalyzer>(
"analyze", completed(query), context);
49 create_operation<VisionExtractor>(
"extract", *
extract);
54 const auto now = std::chrono::steady_clock::now();
56 const double seconds = std::chrono::duration<double>(now - *
m_last_call).count();
58 const double rate = 1.0 / seconds;
102 const auto analyzer_op =
analyzer();
103 const auto results = analyzer_op->get_shared_results();
105 const size_t lanes = std::min(
results->size(), resolved.size());
107 for (
size_t lane = 0; lane < lanes; ++lane) {
108 const auto& steps = resolved[lane].sequence.steps;
109 const auto has = [&steps](
VisionOp op) {
110 return std::ranges::any_of(steps, [op](
const auto& step) {
return step.op == op; });
115 case VisionIntent::FindElements:
116 serves = has(VisionOp::ConnectedComponents);
118 case VisionIntent::TrackObjects:
119 serves = has(VisionOp::TrackKeypoints);
121 case VisionIntent::DetectFeatures:
122 serves = has(VisionOp::HarrisResponse) && !has(VisionOp::TrackKeypoints);
124 case VisionIntent::DetectEdges:
125 serves = has(VisionOp::Canny);
127 case VisionIntent::EstimateMotion:
128 serves = has(VisionOp::OpticalFlowDense);
130 case VisionIntent::MeasureAppearance:
131 serves = has(VisionOp::Sobel);
138 return {
results, &(*results)[lane] };
150 const std::shared_ptr<Kakshya::SignalSourceContainer>& source,
size_t index)
Core::GlobalInputConfig input
FluentExecutor< ComputeMatrix, StartType > with(const Datum< StartType > &input)
Create a fluent executor for chaining operations.
static std::shared_ptr< ComputeMatrix > create()
Create a new ComputeMatrix instance.
std::shared_ptr< VisionExtractor > extractor()
The matrix's "extract" operation, or null when the matrix was built without a mode.
const std::vector< Kinesis::Vision::VisionResult > & results()
The VisionResult of every sequence the analyzer's last completed analysis ran, with each step's image...
void execute(const std::shared_ptr< Core::VKImage > &image)
Analyze image and keep it with its analysis until the next call.
std::optional< std::chrono::steady_clock::time_point > m_last_call
VisionMatrix(Kinesis::Vision::VisionQuery query, std::optional< VisionExtractMode > extract={}, Kinesis::Vision::VisionAnalysisContext context={})
Kinesis::Vision::VisionAnalysis analyze(const std::shared_ptr< Core::VKImage > &image)
Analyze image with the matrix's query.
Kinesis::Vision::VisionAnalysis m_analysis
std::shared_ptr< Core::VKImage > m_extraction
std::shared_ptr< const Kinesis::Vision::VisionResult > result(Kinesis::Vision::VisionIntent intent)
The VisionResult of the sequence that served intent in the last completed analysis,...
void extract(const Kinesis::Vision::VisionAnalysis &analysis, const std::shared_ptr< Core::VKImage > &image)
Extract from image with analysis and keep all three until the next call.
std::shared_ptr< VisionAnalyzer > analyzer()
The matrix's "analyze" operation.
std::shared_ptr< Core::VKImage > m_frame
const Kinesis::Vision::VisionAnalysis & analysis() const
The analysis of the last execute() or extract(), empty before the first.
std::optional< T > get_metadata_value(const std::unordered_map< std::string, std::any > &metadata, const std::string &key)
Get a value from a metadata map by key.
VisionIntent
Composable flags naming what a vision analysis should produce.
VisionOp
Named operations available in a VisionSequence.
std::vector< ResolvedSequence > resolve(const VisionQuery &query)
Resolve a VisionQuery into the ResolvedSequences needed to satisfy every active intent.
Composed context: caller-supplied data for whichever intents need it, consulted after a VisionQuery's...
Composed analysis output: one populated field per active intent that produced a result this call.
Composed query: which VisionIntents are active, and each active one's parameters.
std::unordered_map< std::string, std::any > metadata
Associated metadata.
Input/Output container for computation pipeline data flow with structure preservation.