MCPcopy Create free account
hub / github.com/ARM-software/armnn / GetPixelAs3Channels

Method GetPixelAs3Channels

tests/InferenceTestImage.cpp:158–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158std::tuple<uint8_t, uint8_t, uint8_t> InferenceTestImage::GetPixelAs3Channels(unsigned int x, unsigned int y) const
159{
160 if (x >= m_Width || y >= m_Height)
161 {
162 throw InferenceTestImageOutOfBoundsAccess(fmt::format("Attempted out of bounds image access. "
163 "Requested ({0}, {1}). Maximum valid coordinates ({2}, {3}).", x, y, (m_Width - 1), (m_Height - 1)));
164 }
165
166 const unsigned int pixelOffset = x * GetNumChannels() + y * GetWidth() * GetNumChannels();
167 const uint8_t* const pixelData = m_Data.data() + pixelOffset;
168 ARMNN_ASSERT(pixelData <= (m_Data.data() + GetSizeInBytes()));
169
170 std::array<uint8_t, 3> outPixelData;
171 outPixelData.fill(0);
172
173 const unsigned int maxChannelsInPixel = std::min(GetNumChannels(), static_cast<unsigned int>(outPixelData.size()));
174 for (unsigned int c = 0; c < maxChannelsInPixel; ++c)
175 {
176 outPixelData[c] = pixelData[c];
177 }
178
179 return std::make_tuple(outPixelData[0], outPixelData[1], outPixelData[2]);
180}
181
182
183void InferenceTestImage::StbResize(InferenceTestImage& im, const unsigned int newWidth, const unsigned int newHeight)

Calls 4

formatEnum · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected