Create dimension descriptors for a data modality.
131{
132 std::vector<DataDimension> dims;
134
135 switch (modality) {
137 if (shape.size() != 1) {
138 error<std::invalid_argument>(
141 std::source_location::current(),
142 "AUDIO_1D requires 1D shape");
143 }
145 break;
146
148 if (shape.size() != 2) {
149 error<std::invalid_argument>(
152 std::source_location::current(),
153 "AUDIO_MULTICHANNEL requires 2D shape [samples, channels]");
154 }
157 break;
158
160 if (shape.size() != 2) {
161 error<std::invalid_argument>(
164 std::source_location::current(),
165 "IMAGE_2D requires 2D shape [height, width]");
166 }
169 break;
170
172 if (shape.size() != 3) {
173 error<std::invalid_argument>(
176 std::source_location::current(),
177 "IMAGE_COLOR requires 3D shape [height, width, channels]");
178 }
182 break;
183
185 if (shape.size() != 4) {
186 error<std::invalid_argument>(
189 std::source_location::current(),
190 "IMAGE_COLOR_ARRAY requires 4D shape [frames, height, width, channels]");
191 }
196 break;
197
199 if (shape.size() != 3) {
200 error<std::invalid_argument>(
203 std::source_location::current(),
204 "DEPTH_MAP requires 3D shape [height, width, components]");
205 }
209 break;
210
212 if (shape.size() != 2) {
213 error<std::invalid_argument>(
216 std::source_location::current(),
217 "SPECTRAL_2D requires 2D shape [time_windows, frequency_bins]");
218 }
221 dims[1].stride = strides[1];
222 break;
223
225 if (shape.size() != 3) {
226 error<std::invalid_argument>(
229 std::source_location::current(),
230 "VOLUMETRIC_3D requires 3D shape [x, y, z]");
231 }
235 break;
236
238 if (shape.size() != 3) {
239 error<std::invalid_argument>(
242 std::source_location::current(),
243 "VIDEO_GRAYSCALE requires 3D shape [frames, height, width]");
244 }
248 break;
249
251 if (shape.size() != 4) {
252 error<std::invalid_argument>(
255 std::source_location::current(),
256 "VIDEO_COLOR requires 4D shape [frames, height, width, channels]");
257 }
262 break;
263
265 if (shape.size() != 4) {
266 error<std::invalid_argument>(
269 std::source_location::current(),
270 "VIDEO_DEPTH requires 4D shape [frames, height, width, components]");
271 }
276 break;
277
278 default:
279 error<std::invalid_argument>(
282 std::source_location::current(),
284 }
285
286 return dims;
287}
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
@ DEPTH_MAP
[height, width, components] - range/disparity image
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ AUDIO_1D
1D audio signal
@ VIDEO_DEPTH
[frames, height, width, components] - streaming range data
@ IMAGE_COLOR_ARRAY
4D (idx + 2D + color)
@ 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)
std::string_view modality_to_string(DataModality modality)
Convert DataModality enum to string representation.
static DataDimension spatial(uint64_t size, char axis, uint64_t stride=1, std::string name="spatial")
Convenience constructor for a spatial dimension.
static DataDimension frequency(uint64_t bins, std::string name="frequency")
Convenience constructor for a frequency dimension.
static DataDimension time(uint64_t samples, std::string name="time")
Convenience constructor for a temporal (time) dimension.
static std::vector< uint64_t > calculate_strides(const std::vector< uint64_t > &shape, MemoryLayout layout)
Calculate memory strides based on shape and layout.
static DataDimension depth(uint64_t count=1, uint64_t stride=1)
Convenience constructor for a depth dimension.
static DataDimension channel(uint64_t count, uint64_t stride=1)
Convenience constructor for a channel dimension.