| 331 | } |
| 332 | |
| 333 | std::vector<float> GetImageDataAsNormalizedFloats(ImageChannelLayout layout, |
| 334 | const InferenceTestImage& image) |
| 335 | { |
| 336 | std::vector<float> imageData; |
| 337 | const unsigned int h = image.GetHeight(); |
| 338 | const unsigned int w = image.GetWidth(); |
| 339 | |
| 340 | const unsigned int rDstIndex = GetImageChannelIndex(layout, ImageChannel::R); |
| 341 | const unsigned int gDstIndex = GetImageChannelIndex(layout, ImageChannel::G); |
| 342 | const unsigned int bDstIndex = GetImageChannelIndex(layout, ImageChannel::B); |
| 343 | |
| 344 | imageData.resize(h * w * 3); |
| 345 | unsigned int offset = 0; |
| 346 | |
| 347 | for (unsigned int j = 0; j < h; ++j) |
| 348 | { |
| 349 | for (unsigned int i = 0; i < w; ++i) |
| 350 | { |
| 351 | uint8_t r, g, b; |
| 352 | std::tie(r, g, b) = image.GetPixelAs3Channels(i, j); |
| 353 | |
| 354 | imageData[offset+rDstIndex] = float(r) / 255.0f; |
| 355 | imageData[offset+gDstIndex] = float(g) / 255.0f; |
| 356 | imageData[offset+bDstIndex] = float(b) / 255.0f; |
| 357 | offset += 3; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | return imageData; |
| 362 | } |
no test coverage detected