Create data variants for a specific modality.
507 {
508 std::vector<DataVariant> variants;
509
511 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
512 variants.emplace_back(std::vector<T>(total, default_value));
513 return variants;
514 }
515
516 switch (modality) {
518 variants.emplace_back(std::vector<T>(shape[0], default_value));
519 break;
520
522 uint64_t samples = shape[0];
523 uint64_t channels = shape[1];
524 variants.reserve(channels);
525 for (uint64_t ch = 0; ch < channels; ++ch) {
526 variants.emplace_back(std::vector<T>(samples, default_value));
527 }
528 break;
529 }
530
532 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
533 break;
534
536 uint64_t
height = shape[0];
537 uint64_t
width = shape[1];
538 uint64_t channels = shape[2];
540 variants.reserve(channels);
541 for (uint64_t ch = 0; ch < channels; ++ch) {
542 variants.emplace_back(std::vector<T>(
pixels, default_value));
543 }
544 break;
545 }
546
548 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
549 break;
550
552 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
553 break;
554
556 uint64_t frames = shape[0];
557 uint64_t
height = shape[1];
558 uint64_t
width = shape[2];
560 variants.reserve(frames);
561 for (uint64_t f = 0; f < frames; ++f) {
562 variants.emplace_back(std::vector<T>(frame_size, default_value));
563 }
564 break;
565 }
566
568 uint64_t frames = shape[0];
569 uint64_t
height = shape[1];
570 uint64_t
width = shape[2];
571 uint64_t channels = shape[3];
573 variants.reserve(frames * channels);
574 for (uint64_t f = 0; f < frames; ++f) {
575 for (uint64_t ch = 0; ch < channels; ++ch) {
576 variants.emplace_back(std::vector<T>(frame_size, default_value));
577 }
578 }
579 break;
580 }
581
582 default:
583 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
584 variants.emplace_back(std::vector<T>(total, default_value));
585 break;
586 }
587
588 return variants;
589 }
const std::vector< float > * pixels
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ AUDIO_1D
1D audio signal
@ 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)