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

◆ get_value_at()

double MayaFlux::Kakshya::VideoStreamContainer::get_value_at ( const std::vector< uint64_t > &  coordinates) const
overridevirtual

Get a single value at the specified coordinates.

Parameters
coordinatesN-dimensional coordinates
Returns
Value at the specified location

Implements MayaFlux::Kakshya::NDDataContainer.

Definition at line 218 of file VideoStreamContainer.cpp.

219{
220 if (coordinates.size() < 4 || m_data.empty())
221 return 0.0;
222
223 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[0]);
224 if (!pixels)
225 return 0.0;
226
227 const uint64_t frame = coordinates[0];
228 const uint64_t y = coordinates[1];
229 const uint64_t x = coordinates[2];
230 const uint64_t c = coordinates[3];
231
232 if (frame >= m_num_frames || y >= m_height || x >= m_width || c >= m_channels)
233 return 0.0;
234
235 const size_t idx = (frame * m_height * m_width * m_channels)
236 + (y * m_width * m_channels)
237 + (x * m_channels)
238 + c;
239
240 if (idx >= pixels->size())
241 return 0.0;
242
243 return static_cast<double>((*pixels)[idx]) / 255.0;
244}

References m_channels, m_data, m_height, m_num_frames, and m_width.