MayaFlux 1.0.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,
T  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 514 of file NDData.hpp.

519 {
520 std::vector<DataVariant> variants;
521
523 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
524 variants.emplace_back(std::vector<T>(total, default_value));
525 return variants;
526 }
527
528 switch (modality) {
530 variants.emplace_back(std::vector<T>(shape[0], default_value));
531 break;
532
534 uint64_t samples = shape[0];
535 uint64_t channels = shape[1];
536 variants.reserve(channels);
537 for (uint64_t ch = 0; ch < channels; ++ch) {
538 variants.emplace_back(std::vector<T>(samples, default_value));
539 }
540 break;
541 }
542
544 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
545 break;
546
548 uint64_t height = shape[0];
549 uint64_t width = shape[1];
550 uint64_t channels = shape[2];
551 uint64_t pixels = height * width;
552 variants.reserve(channels);
553 for (uint64_t ch = 0; ch < channels; ++ch) {
554 variants.emplace_back(std::vector<T>(pixels, default_value));
555 }
556 break;
557 }
558
560 uint64_t pixels = shape[0] * shape[1];
561 uint64_t components = shape[2];
562 variants.reserve(components);
563 for (uint64_t c = 0; c < components; ++c) {
564 variants.emplace_back(std::vector<T>(pixels, default_value));
565 }
566 break;
567 }
568
570 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
571 break;
572
574 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
575 break;
576
578 uint64_t frames = shape[0];
579 uint64_t height = shape[1];
580 uint64_t width = shape[2];
581 uint64_t frame_size = height * width;
582 variants.reserve(frames);
583 for (uint64_t f = 0; f < frames; ++f) {
584 variants.emplace_back(std::vector<T>(frame_size, default_value));
585 }
586 break;
587 }
588
590 uint64_t frames = shape[0];
591 uint64_t height = shape[1];
592 uint64_t width = shape[2];
593 uint64_t channels = shape[3];
594 uint64_t frame_size = height * width;
595 variants.reserve(frames * channels);
596 for (uint64_t f = 0; f < frames; ++f) {
597 for (uint64_t ch = 0; ch < channels; ++ch) {
598 variants.emplace_back(std::vector<T>(frame_size, default_value));
599 }
600 }
601 break;
602 }
603
605 uint64_t frames = shape[0];
606 uint64_t pixels = shape[1] * shape[2];
607 uint64_t components = shape[3];
608 variants.reserve(components);
609 for (uint64_t c = 0; c < components; ++c) {
610 variants.emplace_back(std::vector<T>(frames * pixels, default_value));
611 }
612 break;
613 }
614
615 default:
616 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
617 variants.emplace_back(std::vector<T>(total, default_value));
618 break;
619 }
620
621 return variants;
622 }
const std::vector< float > * pixels
Definition Decoder.cpp:48
uint32_t total
uint32_t channels
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 channels, height, pixels, total, and width.