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

◆ apply_operation_internal()

template<ComputeData InputType = std::shared_ptr<Kakshya::SignalSourceContainer>, ComputeData OutputType = std::vector<Kakshya::DataVariant>>
output_type MayaFlux::Yantra::VisionExtractor< InputType, OutputType >::apply_operation_internal ( const input_type input,
const ExecutionContext context 
)
inlineoverrideprotectedvirtual

Internal execution method - ComputeMatrix can access this.

Parameters
inputInput data wrapped in IO
contextExecution context with mode, threading, etc.
Returns
Processed output

Reimplemented from MayaFlux::Yantra::ComputeOperation< InputType, OutputType >.

Definition at line 147 of file VisionExtractor.hpp.

149 {
150 if (this->m_gpu_backend && this->m_gpu_backend->ensure_gpu_ready()) {
151 const auto analysis_it = input.metadata.find("vision_analysis");
152 if (analysis_it != input.metadata.end() && analysis_it->second.has_value()) {
153 const auto& analysis = safe_any_cast_or_throw<VisionAnalysis>(
154 analysis_it->second);
155
156 auto [nx, ny, nw, nh] = compute_normalised_rect(analysis);
157 const auto crop_w = static_cast<uint32_t>(
158 std::max(1.0F, std::round(nw * static_cast<float>(analysis.w))));
159 const auto crop_h = static_cast<uint32_t>(
160 std::max(1.0F, std::round(nh * static_cast<float>(analysis.h))));
161
162 auto* ctx = dynamic_cast<TextureExecutionContext*>(
163 this->m_gpu_backend.get());
164 if (ctx) {
165 ctx->set_output_dimensions(crop_w, crop_h);
166 ctx->set_push_constants(
167 CropPC { nx, ny, nw, nh, crop_w, crop_h });
168 }
169 }
170 }
171
173 }
Core::GlobalInputConfig input
Definition Config.cpp:38
std::shared_ptr< GpuExecutionContext< InputType, OutputType > > m_gpu_backend
virtual output_type apply_operation_internal(const input_type &input, const ExecutionContext &context)
Internal execution method - ComputeMatrix can access this.
std::array< float, 4 > compute_normalised_rect(const VisionAnalysis &analysis) const
Compute the normalised crop rectangle for a given VisionAnalysis.

References MayaFlux::Yantra::ComputeOperation< InputType, OutputType >::apply_operation_internal(), MayaFlux::Yantra::VisionExtractor< InputType, OutputType >::compute_normalised_rect(), input, MayaFlux::Yantra::ComputeOperation< InputType, OutputType >::m_gpu_backend, MayaFlux::Yantra::Datum< T >::metadata, and MayaFlux::Yantra::TextureExecutionContext::set_output_dimensions().

+ Here is the call graph for this function: