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

◆ create_variants()

template<typename T >
static std::vector< DataVariant > MayaFlux::Kakshya::DataDimension::create_variants ( DataModality  modality,
const std::vector< uint64_t > &  shape,
default_value,
OrganizationStrategy  org = OrganizationStrategy::PLANAR 
)
inlinestaticprivate

Create data variants for a specific modality.

Template Parameters
TData type for storage
Parameters
modalityTarget data modality
shapeDimensional sizes
default_valueInitial value for elements
orgOrganization strategy
Returns
Vector of DataVariant objects

Definition at line 546 of file NDData.hpp.

551 {
552 std::vector<DataVariant> variants;
553
555 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
556 variants.emplace_back(std::vector<T>(total, default_value));
557 return variants;
558 }
559
560 switch (modality) {
562 variants.emplace_back(std::vector<T>(shape[0], default_value));
563 break;
564
566 uint64_t samples = shape[0];
567 uint64_t channels = shape[1];
568 variants.reserve(channels);
569 for (uint64_t ch = 0; ch < channels; ++ch) {
570 variants.emplace_back(std::vector<T>(samples, default_value));
571 }
572 break;
573 }
574
576 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
577 break;
578
580 uint64_t height = shape[0];
581 uint64_t width = shape[1];
582 uint64_t channels = shape[2];
583 uint64_t pixels = height * width;
584 variants.reserve(channels);
585 for (uint64_t ch = 0; ch < channels; ++ch) {
586 variants.emplace_back(std::vector<T>(pixels, default_value));
587 }
588 break;
589 }
590
592 uint64_t pixels = shape[0] * shape[1];
593 uint64_t components = shape[2];
594 variants.reserve(components);
595 for (uint64_t c = 0; c < components; ++c) {
596 variants.emplace_back(std::vector<T>(pixels, default_value));
597 }
598 break;
599 }
600
602 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
603 break;
604
606 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
607 break;
608
610 uint64_t frames = shape[0];
611 uint64_t height = shape[1];
612 uint64_t width = shape[2];
613 uint64_t frame_size = height * width;
614 variants.reserve(frames);
615 for (uint64_t f = 0; f < frames; ++f) {
616 variants.emplace_back(std::vector<T>(frame_size, default_value));
617 }
618 break;
619 }
620
622 uint64_t frames = shape[0];
623 uint64_t height = shape[1];
624 uint64_t width = shape[2];
625 uint64_t channels = shape[3];
626 uint64_t frame_size = height * width;
627 variants.reserve(frames * channels);
628 for (uint64_t f = 0; f < frames; ++f) {
629 for (uint64_t ch = 0; ch < channels; ++ch) {
630 variants.emplace_back(std::vector<T>(frame_size, default_value));
631 }
632 }
633 break;
634 }
635
637 uint64_t frames = shape[0];
638 uint64_t pixels = shape[1] * shape[2];
639 uint64_t components = shape[3];
640 variants.reserve(components);
641 for (uint64_t c = 0; c < components; ++c) {
642 variants.emplace_back(std::vector<T>(frames * pixels, default_value));
643 }
644 break;
645 }
646
647 default:
648 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
649 variants.emplace_back(std::vector<T>(total, default_value));
650 break;
651 }
652
653 return variants;
654 }
const std::vector< float > * pixels
Definition Decoder.cpp:65
uint32_t width
uint32_t height
@ DEPTH_MAP
[height, width, components] - range/disparity image
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ VIDEO_DEPTH
[frames, height, width, components] - streaming range data
@ VOLUMETRIC_3D
3D volumetric data
@ VIDEO_GRAYSCALE
3D video (time + 2D grayscale)
@ VIDEO_COLOR
4D video (time + 2D + color)
@ IMAGE_COLOR
2D RGB/RGBA image
@ IMAGE_2D
2D image (grayscale or single channel)
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)

References height, pixels, and width.