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

◆ extract_structured_native()

template<OperationReadyData T>
static std::tuple< std::vector< Kakshya::DataSpanVariant >, DataStructureInfo > MayaFlux::Yantra::OperationHelper::extract_structured_native ( T &  compute_data)
inlinestatic

Extract native-typed channel spans and structure metadata from a Datum or direct ComputeData, without double coercion.

Mirrors extract_structured_double in structure: same DataStructureInfo population, same Datum unwrapping, same container handling for RegionLike types. The only difference is that channel data is returned as DataSpanVariant (type-erased native span) rather than span<double>.

Use this as the entry point for Kinesis::Vision operations and any other pipeline that must preserve the source's native element type (uint8_t pixel data, uint16_t depth, float HDR, etc.).

For RegionLike data types the region variants are returned as DataSpanVariant via extract_native_data(DataVariant), consistent with the non-region overloads.

Callers branch on DataSpanVariant::element_type() or use FrameView::as<E>() / DataSpanVariant::get_if<span<const E>>() when the native type is statically known.

Template Parameters
TOperationReadyData type.
Parameters
compute_dataDatum or direct ComputeData to extract from.
Returns
Tuple of [native channel spans, DataStructureInfo].
Exceptions
std::runtime_errorif a container is required but absent.

Definition at line 401 of file OperationHelper.hpp.

402 {
403 if constexpr (is_IO<T>::value) {
404 DataStructureInfo info {};
405 info.original_type = std::type_index(typeid(std::decay_t<decltype(compute_data.data)>));
406 info.dimensions = compute_data.dimensions;
407 info.modality = compute_data.modality;
408
409 if constexpr (RequiresContainer<std::decay_t<decltype(compute_data.data)>>) {
410 if (!compute_data.has_container()) {
411 error<std::runtime_error>(
414 std::source_location::current(),
415 "Container is required for region-like data extraction but not provided");
416 }
417
418 const auto region_variants = [&]() -> std::vector<Kakshya::DataVariant> {
419 if constexpr (std::is_same_v<std::decay_t<decltype(compute_data.data)>, Kakshya::Region>) {
420 return compute_data.container.value()->get_region_data(compute_data.data);
421 } else if constexpr (std::is_same_v<std::decay_t<decltype(compute_data.data)>, Kakshya::RegionGroup>) {
422 return compute_data.container.value()->get_region_group_data(compute_data.data);
423 } else {
424 return compute_data.container.value()->get_segments_data(compute_data.data);
425 }
426 }();
427 return { extract_native_data(region_variants), info };
428 } else {
429 auto spans = extract_native_data(compute_data.data);
430 return { std::move(spans), info };
431 }
432 } else {
433 DataStructureInfo info {};
434 info.original_type = std::type_index(typeid(T));
435 auto spans = extract_native_data(compute_data);
436 auto [dimensions, modality] = infer_structure(compute_data);
437 info.dimensions = dimensions;
438 info.modality = modality;
439 return { std::move(spans), info };
440 }
441 }
static Kakshya::DataSpanVariant extract_native_data(const Kakshya::DataVariant &variant)
Extract a single DataVariant as a type-erased span without conversion.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
static std::pair< std::vector< Kakshya::DataDimension >, Kakshya::DataModality > infer_structure(const T &data, const std::shared_ptr< Kakshya::SignalSourceContainer > &container=nullptr)
Infer dimensions and modality from any ComputeData type.

References MayaFlux::Yantra::DataStructureInfo::original_type.

Referenced by MayaFlux::Yantra::VisionAnalyzer< InputType, OutputType >::analyze_implementation().

+ Here is the caller graph for this function: