| 277 | |
| 278 | template <typename TProcessValueCallable> |
| 279 | std::vector<float> GetImageDataInArmNnLayoutAsFloats(ImageChannelLayout channelLayout, |
| 280 | const InferenceTestImage& image, |
| 281 | TProcessValueCallable processValue) |
| 282 | { |
| 283 | const unsigned int h = image.GetHeight(); |
| 284 | const unsigned int w = image.GetWidth(); |
| 285 | |
| 286 | std::vector<float> imageData; |
| 287 | imageData.resize(h * w * 3); |
| 288 | |
| 289 | for (unsigned int j = 0; j < h; ++j) |
| 290 | { |
| 291 | for (unsigned int i = 0; i < w; ++i) |
| 292 | { |
| 293 | uint8_t r, g, b; |
| 294 | std::tie(r, g, b) = image.GetPixelAs3Channels(i, j); |
| 295 | |
| 296 | // ArmNN order: C, H, W |
| 297 | const unsigned int rDstIndex = GetImageChannelIndex(channelLayout, ImageChannel::R) * h * w + j * w + i; |
| 298 | const unsigned int gDstIndex = GetImageChannelIndex(channelLayout, ImageChannel::G) * h * w + j * w + i; |
| 299 | const unsigned int bDstIndex = GetImageChannelIndex(channelLayout, ImageChannel::B) * h * w + j * w + i; |
| 300 | |
| 301 | imageData[rDstIndex] = processValue(ImageChannel::R, float(r)); |
| 302 | imageData[gDstIndex] = processValue(ImageChannel::G, float(g)); |
| 303 | imageData[bDstIndex] = processValue(ImageChannel::B, float(b)); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | return imageData; |
| 308 | } |
| 309 | |
| 310 | std::vector<float> GetImageDataInArmNnLayoutAsNormalizedFloats(ImageChannelLayout layout, |
| 311 | const InferenceTestImage& image) |
no test coverage detected