|
MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
|
Reorders detection results in a VisionAnalysis by a scalar key or callable. More...
#include <VisionSorter.hpp>
Inheritance diagram for MayaFlux::Yantra::VisionSorter< InputType, OutputType >:
Collaboration diagram for MayaFlux::Yantra::VisionSorter< InputType, OutputType >:Public Types | |
| using | input_type = Datum< InputType > |
| using | KeyFn = std::function< float(size_t index, const VisionAnalysis &)> |
| using | output_type = Datum< OutputType > |
Public Types inherited from MayaFlux::Yantra::UniversalSorter< InputType, OutputType > | |
| using | base_type = ComputeOperation< InputType, OutputType > |
| using | input_type = Datum< InputType > |
| using | output_type = Datum< OutputType > |
Public Types inherited from MayaFlux::Yantra::ComputeOperation< InputType, OutputType > | |
| using | input_type = Datum< InputType > |
| using | output_type = Datum< OutputType > |
Public Member Functions | |
| std::vector< std::string > | get_available_methods () const |
| VisionSortKey | get_key () const |
| SortingType | get_sorting_type () const override |
| Gets the sorting type category for this sorter. | |
| bool | has_key_fn () const |
| void | set_key (VisionSortKey key) |
| void | set_key_fn (KeyFn key_fn) |
| VisionSorter (KeyFn key_fn, SortingDirection direction=SortingDirection::DESCENDING) | |
| VisionSorter (VisionSortKey key=VisionSortKey::AREA, SortingDirection direction=SortingDirection::DESCENDING) | |
Public Member Functions inherited from MayaFlux::Yantra::UniversalSorter< InputType, OutputType > | |
| std::map< std::string, std::any > | get_all_parameters () const override |
| Retrieves all parameters and their values. | |
| SortingDirection | get_direction () const |
| SortingGranularity | get_granularity () const |
| std::string | get_name () const override |
| Gets human-readable name for this sorter. | |
| OperationType | get_operation_type () const override |
| Returns the category of this operation for grammar and registry discovery. | |
| std::any | get_parameter (const std::string &name) const override |
| Retrieves a parameter's current value. | |
| template<typename T > | |
| T | get_parameter_or_default (const std::string &name, const T &default_value) const |
| Type-safe parameter access with defaults. | |
| const std::vector< SortKey > & | get_sort_keys () const |
| SortingStrategy | get_strategy () const |
| template<typename T > | |
| void | set_custom_comparator (std::function< bool(const T &, const T &)> comparator) |
| Configure custom comparator for CUSTOM direction. | |
| void | set_direction (SortingDirection direction) |
| Configure sorting direction. | |
| void | set_granularity (SortingGranularity granularity) |
| Configure output granularity. | |
| void | set_parameter (const std::string &name, std::any value) override |
| Type-safe parameter management with sorting-specific defaults. | |
| void | set_sort_keys (const std::vector< SortKey > &keys) |
| Add multi-key sorting capability. | |
| void | set_strategy (SortingStrategy strategy) |
| Configure sorting strategy. | |
| virtual | ~UniversalSorter ()=default |
Public Member Functions inherited from MayaFlux::Yantra::ComputeOperation< InputType, OutputType > | |
| void | add_dependency (std::shared_ptr< ComputeOperation > dep) |
| output_type | apply_operation (const input_type &input) |
| Public synchronous execution interface. | |
| output_type | apply_operation_with_dependencies (const input_type &input) |
| Applies the operation with dependencies resolved. | |
| OutputType | apply_to_data (const InputType &data) |
| Convenience overload that extracts just the data from result. | |
| ComputeOperation () | |
| Constructor with data type validation warnings. | |
| output_type | execute (const input_type &input) |
| OpUnit interface - operations can act as units in dependency graphs. | |
| virtual const std::shared_ptr< Kakshya::SignalSourceContainer > & | get_container_for_regions () const |
| const auto & | get_dependencies () const |
| const ExecutionContext & | get_last_execution_context () const |
| bool | has_gpu_backend () const |
| output_type | operator() (const InputType &data) |
| Convenience overload for direct data processing (backward compatibility) | |
| virtual void | set_container_for_regions (const std::shared_ptr< Kakshya::SignalSourceContainer > &container) |
| void | set_gpu_backend (std::shared_ptr< GpuExecutionContext< InputType, OutputType > > backend) |
| Attach a GPU execution backend. | |
| void | set_last_execution_context (const ExecutionContext &ctx) |
| void | set_post_execution_hook (const OperationHookCallback &hook) |
| void | set_pre_execution_hook (const OperationHookCallback &hook) |
| void | set_reconstruction_callback (const ReconstructionCallback &callback) |
| virtual bool | validate_input (const input_type &) const |
| Validates if the input data meets the operation's requirements. | |
| virtual | ~ComputeOperation ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
Protected Member Functions | |
| output_type | apply_operation_internal (const input_type &input, const ExecutionContext &context) override |
| Internal execution method - ComputeMatrix can access this. | |
| std::string | get_sorter_name () const override |
| Get sorter-specific name (derived classes override this) | |
| output_type | sort_implementation (const input_type &input) override |
| Pure virtual sorting implementation - derived classes implement this. | |
Protected Member Functions inherited from MayaFlux::Yantra::UniversalSorter< InputType, OutputType > | |
| virtual output_type | add_sorting_metadata (const output_type &raw_output) |
| Add sorting metadata to results (override for custom attribution) | |
| bool | apply_custom_comparator (const std::any &a, const std::any &b) const |
| Apply custom comparator if available. | |
| virtual output_type | apply_granularity_formatting (const output_type &raw_output) |
| Apply granularity-based output formatting. | |
| virtual output_type | create_sorting_analysis (const output_type &raw_output) |
| Create detailed sorting analysis (override for custom analysis) | |
| virtual std::map< std::string, std::any > | get_all_sorting_parameters () const |
| virtual std::any | get_sorting_parameter (const std::string &name) const |
| bool | has_custom_comparator () const |
| Helper to check if custom comparator is available. | |
| output_type | operation_function (const input_type &input) override |
| Core operation implementation - called by ComputeOperation interface. | |
| virtual output_type | organize_into_groups (const output_type &raw_output) |
| Organize results into hierarchical groups (override for custom grouping) | |
| virtual void | set_sorting_parameter (const std::string &name, std::any value) |
| Sorting-specific parameter handling (override for custom parameters) | |
| virtual bool | should_use_multi_key_sorting () const |
| Apply multi-key sorting if keys are configured. | |
| template<typename SortingResultType > | |
| void | store_current_sorting (SortingResultType &&result) const |
| virtual bool | validate_sorting_input (const input_type &) const |
| Input validation (override for custom validation logic) | |
Protected Member Functions inherited from MayaFlux::Yantra::ComputeOperation< InputType, OutputType > | |
| output_type | apply_hooks (const input_type &input, const ExecutionContext &context) |
| virtual std::future< output_type > | apply_operation_async (const input_type &input) |
| Optional async implementation - default delegates to operation_function. | |
| virtual output_type | apply_operation_chained (const input_type &input, const ExecutionContext &ctx) |
| Optional chain-aware implementation - default delegates to operation_function. | |
| virtual output_type | apply_operation_parallel (const input_type &input, const ExecutionContext &ctx) |
| Optional parallel-aware implementation - default delegates to operation_function. | |
| output_type | convert_result (std::vector< std::vector< double > > &result_data, DataStructureInfo &metadata) |
| Convert processed double data back to OutputType using metadata and optional callback. | |
Private Member Functions | |
| float | compute_key (size_t index, const VisionAnalysis &analysis) const |
| template<typename T > | |
| float | key_for (size_t index, const std::vector< T > &coll, const VisionAnalysis &analysis) const |
| float | key_for_box (const Kinesis::Vision::BoundingBox &box) const |
| float | key_for_contour (const Kinesis::Vision::Contour &contour) const |
Private Attributes | |
| VisionSortKey | m_key { VisionSortKey::AREA } |
| KeyFn | m_key_fn |
Additional Inherited Members | |
Protected Attributes inherited from MayaFlux::Yantra::UniversalSorter< InputType, OutputType > | |
| output_type | m_current_output |
| std::any | m_current_sorting |
| Current sorting operation storage for complex operations. | |
Protected Attributes inherited from MayaFlux::Yantra::ComputeOperation< InputType, OutputType > | |
| std::shared_ptr< Kakshya::SignalSourceContainer > | m_container |
| std::shared_ptr< GpuExecutionContext< InputType, OutputType > > | m_gpu_backend |
| ExecutionContext | m_last_execution_context |
Reorders detection results in a VisionAnalysis by a scalar key or callable.
Reads VisionAnalysis from input.metadata["vision_analysis"], sorts the populated detection collection (boxes or contours) by the configured key and direction, writes the reordered VisionAnalysis back to output.metadata["vision_analysis"], and passes input.data through unmodified.
CPU path: std::stable_sort via permutation index.
GPU path: attach a ShaderExecutionContext configured with KernelTemplate::BitonicSort. apply_operation_internal computes scalar keys on CPU, stages them alongside a linear index array, runs the assembled bitonic sort shader, reads back sorted indices, and applies the permutation to the analysis collections before returning.
The callable overload receives the element index and the full VisionAnalysis. When both a key and a callable are set, the callable takes precedence.
| InputType | Any ComputeData type. Defaults to shared_ptr<SignalSourceContainer>. |
| OutputType | Defaults to InputType; data passes through unmodified. |
Definition at line 71 of file VisionSorter.hpp.