MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Yantra::Vision::VisionMatrix Class Reference

Compute matrix holding one VisionAnalyzer for a query and, when an extraction mode is given, one VisionExtractor. More...

#include <VisionMatrix.hpp>

+ Inheritance diagram for MayaFlux::Yantra::Vision::VisionMatrix:
+ Collaboration diagram for MayaFlux::Yantra::Vision::VisionMatrix:

Public Member Functions

const Kinesis::Vision::VisionAnalysis & analysis () const
 The analysis of the last execute() or extract(), empty before the first.
 
double analysis_rate () const
 Analyses per second arriving through execute() and extract(), smoothed over recent calls.
 
Kinesis::Vision::VisionAnalysis analyze (const std::shared_ptr< Core::VKImage > &image)
 Analyze image with the matrix's query.
 
Kinesis::Vision::VisionAnalysis analyze (const std::shared_ptr< Kakshya::SignalSourceContainer > &source, size_t index=0)
 Analyze frame index of source with the matrix's query.
 
std::shared_ptr< VisionAnalyzer > analyzer ()
 The matrix's "analyze" operation.
 
void execute (const std::shared_ptr< Core::VKImage > &image)
 Analyze image and keep it with its analysis until the next call.
 
void execute (const std::shared_ptr< Kakshya::SignalSourceContainer > &source, size_t index)
 execute() on frame index of source: a texture container's layer, or a video stream's or window's current frame.
 
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.
 
const std::shared_ptr< Core::VKImage > & extraction () const
 The image the last extract() produced.
 
std::shared_ptr< VisionExtractor > extractor ()
 The matrix's "extract" operation, or null when the matrix was built without a mode.
 
const std::shared_ptr< Core::VKImage > & frame () const
 The image the last execute() analyzed or extract() extracted from, null before the first.
 
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, or null when the query has no such sequence or nothing has completed yet.
 
const std::vector< Kinesis::Vision::VisionResult > & results ()
 The VisionResult of every sequence the analyzer's last completed analysis ran, with each step's image named by its op.
 
 VisionMatrix (Kinesis::Vision::VisionQuery query, std::optional< VisionExtractMode > extract={}, Kinesis::Vision::VisionAnalysisContext context={})
 
- Public Member Functions inherited from MayaFlux::Yantra::GrammarAwareComputeMatrix
void add_grammar_rule (ComputationGrammar::Rule rule)
 Add a grammar rule directly to the matrix.
 
ComputationGrammar::RuleBuilder create_grammar_rule (const std::string &name)
 Create a rule builder for this matrix's grammar.
 
template<ComputeData InputType>
Datum< InputType > execute_with_grammar (const Datum< InputType > &input, const ExecutionContext &context={})
 Execute operations with grammar rule pre-processing.
 
template<ComputeData InputType>
Datum< InputType > execute_with_grammar (const std::string &rule_name, const Datum< InputType > &input, const ExecutionContext &context={})
 Execute a named grammar rule explicitly by name.
 
std::shared_ptr< ComputationGrammar > get_grammar () const
 Get the grammar instance.
 
 GrammarAwareComputeMatrix (std::shared_ptr< ComputationGrammar > grammar=nullptr)
 Constructor with optional grammar.
 
void set_grammar (std::shared_ptr< ComputationGrammar > grammar)
 Set grammar instance.
 
- Public Member Functions inherited from MayaFlux::Yantra::ComputeMatrix
template<typename OpClass >
bool add_operation (const std::string &name, std::shared_ptr< OpClass > operation)
 Add a pre-configured operation instance to this matrix.
 
void clear_operations ()
 Clear all operations from this matrix.
 
 ComputeMatrix ()
 
template<typename OpClass , typename... Args>
std::shared_ptr< OpClass > create_operation (const std::string &name, Args &&... args)
 Create and add an operation to this matrix.
 
void drain_async ()
 Block until all in-flight async chains complete.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType, typename... Args>
std::optional< Datum< OutputType > > execute (const Datum< InputType > &input, Args &&... args)
 Execute an operation by creating a new instance.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType, typename... Args>
std::future< std::optional< Datum< OutputType > > > execute_async (const Datum< InputType > &input, Args &&... args)
 Execute operation asynchronously.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType, typename... Args>
std::vector< std::optional< Datum< OutputType > > > execute_batch (const std::vector< Datum< InputType > > &inputs, Args &&... args)
 Execute operation on multiple inputs.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType, typename... Args>
std::vector< std::optional< Datum< OutputType > > > execute_batch_parallel (const std::vector< Datum< InputType > > &inputs, Args &&... args)
 Execute operation on multiple inputs in parallel.
 
template<typename FirstOp , typename SecondOp , ComputeData InputType, ComputeData IntermediateType, ComputeData OutputType>
std::optional< Datum< OutputType > > execute_chain (const Datum< InputType > &input)
 Execute operations in sequence (type-safe chain)
 
template<typename FirstOp , typename SecondOp , ComputeData InputType, ComputeData IntermediateType, ComputeData OutputType>
std::optional< Datum< OutputType > > execute_chain_named (const std::string &first_name, const std::string &second_name, const Datum< InputType > &input)
 Execute named operations in sequence.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType>
std::optional< Datum< OutputType > > execute_named (const std::string &name, const Datum< InputType > &input)
 Execute a named operation from the pool.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType>
std::future< std::optional< Datum< OutputType > > > execute_named_async (const std::string &name, const Datum< InputType > &input)
 Execute named operation asynchronously.
 
template<ComputeData InputType, typename... OpClasses>
auto execute_parallel (const Datum< InputType > &input)
 Execute multiple operations in parallel.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType>
std::vector< std::optional< Datum< OutputType > > > execute_parallel_named (const std::vector< std::string > &names, const Datum< InputType > &input)
 Execute multiple named operations in parallel.
 
template<typename OpClass , ComputeData InputType, ComputeData OutputType = InputType>
std::optional< Datum< OutputType > > execute_with (std::shared_ptr< OpClass > operation, const Datum< InputType > &input)
 Execute with provided operation instance.
 
ExecutionPolicy get_execution_policy () const
 Get current execution policy.
 
std::string get_last_error () const
 Get last error message.
 
template<typename OpClass >
std::shared_ptr< OpClass > get_operation (const std::string &name)
 Get a named operation from this matrix.
 
std::unordered_map< std::string, std::any > get_statistics () const
 Get execution statistics.
 
std::vector< std::string > list_operations () const
 List all operation names in this matrix.
 
bool remove_operation (const std::string &name)
 Remove a named operation from this matrix.
 
void set_context_configurator (std::function< void(ExecutionContext &, const std::type_index &)> configurator)
 Set custom context configurator.
 
void set_default_timeout (std::chrono::milliseconds timeout)
 Set default execution timeout.
 
void set_error_callback (std::function< void(const std::exception &, const std::type_index &)> callback)
 Set error callback.
 
void set_execution_policy (ExecutionPolicy policy)
 Set execution policy for this matrix.
 
void set_profiling (bool enabled)
 Enable/disable execution profiling.
 
template<ComputeData StartType>
FluentExecutor< ComputeMatrix, StartType > with (const Datum< StartType > &input)
 Create a fluent executor for chaining operations.
 
template<ComputeData StartType>
FluentExecutor< ComputeMatrix, StartType > with (const StartType &input)
 
template<ComputeData StartType>
FluentExecutor< ComputeMatrix, StartType > with (Datum< StartType > &&input)
 Create a fluent executor with move semantics.
 
template<ComputeData StartType>
FluentExecutor< ComputeMatrix, StartType > with (StartType &&input)
 
template<ComputeData StartType, typename ChainFunc , typename CompleteFn >
void with_async (Datum< StartType > input, ChainFunc &&chain, CompleteFn &&on_complete)
 Execute an operation chain asynchronously.
 
template<ComputeData StartType, typename ChainFunc , typename CompleteFn >
void with_async (StartType input, ChainFunc &&chain, CompleteFn &&on_complete)
 
 ~ComputeMatrix ()
 

Static Public Member Functions

static std::shared_ptr< VisionMatrix > create (Kinesis::Vision::VisionQuery query, std::optional< VisionExtractMode > extract={}, Kinesis::Vision::VisionAnalysisContext context={})
 
- Static Public Member Functions inherited from MayaFlux::Yantra::ComputeMatrix
static std::shared_ptr< ComputeMatrix > create ()
 Create a new ComputeMatrix instance.
 

Private Member Functions

void count_call ()
 

Private Attributes

Kinesis::Vision::VisionAnalysis m_analysis
 
std::shared_ptr< Core::VKImage > m_extraction
 
std::shared_ptr< Core::VKImage > m_frame
 
std::optional< std::chrono::steady_clock::time_point > m_last_call
 
double m_rate {}
 

Detailed Description

Compute matrix holding one VisionAnalyzer for a query and, when an extraction mode is given, one VisionExtractor.

An intent set in the query without its parameters runs with the defaults. Keep the matrix for as long as frames arrive: its analyzer reuses its GPU images on every call, and tracking and motion compare each frame with the previous one. Configure the extraction through extractor(). Build it with create(): the matrix must be held by a shared_ptr to run.

An analysis can be extracted from any frame, not only the one it was taken on. Boxes, contours, tracks, keypoints and appearance statistics are normalized values held on the CPU: they stay valid after later calls and apply at any size. The edge and flow images, and the labels mask() reads, belong to the analyzer and are valid only until its next call.

Definition at line 27 of file VisionMatrix.hpp.


The documentation for this class was generated from the following files: