#include <InferenceTestImage.hpp>
|
| InferenceTestImage (const char *filePath) |
|
| InferenceTestImage (InferenceTestImage &&)=delete |
|
| InferenceTestImage (const InferenceTestImage &)=delete |
|
InferenceTestImage & | operator= (const InferenceTestImage &)=delete |
|
InferenceTestImage & | operator= (InferenceTestImage &&)=delete |
|
unsigned int | GetWidth () const |
|
unsigned int | GetHeight () const |
|
unsigned int | GetNumChannels () const |
|
unsigned int | GetNumElements () const |
|
unsigned int | GetSizeInBytes () const |
|
std::tuple< uint8_t, uint8_t, uint8_t > | GetPixelAs3Channels (unsigned int x, unsigned int y) const |
|
void | StbResize (InferenceTestImage &im, const unsigned int newWidth, const unsigned int newHeight) |
|
std::vector< float > | Resize (unsigned int newWidth, unsigned int newHeight, const armnn::CheckLocation &location, const ResizingMethods meth=ResizingMethods::STB, const std::array< float, 3 > &mean={{0.0, 0.0, 0.0}}, const std::array< float, 3 > &stddev={{1.0, 1.0, 1.0}}, const float scale=255.0f) |
|
void | Write (WriteFormat format, const char *filePath) const |
|
Definition at line 51 of file InferenceTestImage.hpp.
◆ ResizingMethods
◆ WriteFormat
◆ InferenceTestImage() [1/3]
Definition at line 127 of file InferenceTestImage.cpp.
References GetSizeInBytes().
136 using StbImageDataPtr = std::unique_ptr<unsigned char, decltype(&stbi_image_free)>;
137 StbImageDataPtr stbData(stbi_load(filePath, &width, &height, &channels, 0), &stbi_image_free);
139 if (stbData ==
nullptr)
144 if (width == 0 || height == 0)
149 m_Width = boost::numeric_cast<
unsigned int>(width);
150 m_Height = boost::numeric_cast<
unsigned int>(height);
151 m_NumChannels = boost::numeric_cast<
unsigned int>(channels);
154 m_Data.resize(sizeInBytes);
155 memcpy(m_Data.data(), stbData.get(), sizeInBytes);
unsigned int GetSizeInBytes() const
◆ InferenceTestImage() [2/3]
◆ InferenceTestImage() [3/3]
◆ GetHeight()
unsigned int GetHeight |
( |
| ) |
const |
|
inline |
◆ GetNumChannels()
unsigned int GetNumChannels |
( |
| ) |
const |
|
inline |
◆ GetNumElements()
unsigned int GetNumElements |
( |
| ) |
const |
|
inline |
Definition at line 78 of file InferenceTestImage.hpp.
unsigned int GetWidth() const
unsigned int GetNumChannels() const
unsigned int GetHeight() const
◆ GetPixelAs3Channels()
std::tuple< uint8_t, uint8_t, uint8_t > GetPixelAs3Channels |
( |
unsigned int |
x, |
|
|
unsigned int |
y |
|
) |
| const |
Definition at line 158 of file InferenceTestImage.cpp.
References GetNumChannels(), GetSizeInBytes(), and GetWidth().
Referenced by GetImageDataAsNormalizedFloats(), and GetImageDataInArmNnLayoutAsFloats().
160 if (x >= m_Width || y >= m_Height)
163 "Requested (%1%, %2%). Maximum valid coordinates (%3%, %4%).") % x % y % (m_Width - 1) % (m_Height - 1)));
167 const uint8_t*
const pixelData = m_Data.data() + pixelOffset;
170 std::array<uint8_t, 3> outPixelData;
171 outPixelData.fill(0);
173 const unsigned int maxChannelsInPixel = std::min(
GetNumChannels(), static_cast<unsigned int>(outPixelData.size()));
174 for (
unsigned int c = 0; c < maxChannelsInPixel; ++c)
176 outPixelData[c] = pixelData[c];
179 return std::make_tuple(outPixelData[0], outPixelData[1], outPixelData[2]);
unsigned int GetWidth() const
unsigned int GetNumChannels() const
unsigned int GetSizeInBytes() const
◆ GetSizeInBytes()
unsigned int GetSizeInBytes |
( |
| ) |
const |
|
inline |
◆ GetWidth()
unsigned int GetWidth |
( |
| ) |
const |
|
inline |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ Resize()
std::vector< float > Resize |
( |
unsigned int |
newWidth, |
|
|
unsigned int |
newHeight, |
|
|
const armnn::CheckLocation & |
location, |
|
|
const ResizingMethods |
meth = ResizingMethods::STB , |
|
|
const std::array< float, 3 > & |
mean = {{0.0, 0.0, 0.0}} , |
|
|
const std::array< float, 3 > & |
stddev = {{1.0, 1.0, 1.0}} , |
|
|
const float |
scale = 255.0f |
|
) |
| |
Definition at line 209 of file InferenceTestImage.cpp.
References CheckLocation::AsString(), BilinearAndNormalized, STB, and StbResize().
Referenced by CaffePreprocessor::GetTestCaseData(), and YoloDatabase::GetTestCaseData().
217 std::vector<float> out;
218 if (newWidth == 0 || newHeight == 0)
221 "operation can be zero. Requested width: %1%. Requested height: %2%.") % newWidth % newHeight));
232 out = ResizeBilinearAndNormalize(*
this, newWidth, newHeight, scale, mean, stddev);
237 boost::format(
"Unknown resizing method asked ArmNN only supports {STB, BilinearAndNormalized} %1%")
void StbResize(InferenceTestImage &im, const unsigned int newWidth, const unsigned int newHeight)
std::string AsString() const
◆ StbResize()
void StbResize |
( |
InferenceTestImage & |
im, |
|
|
const unsigned int |
newWidth, |
|
|
const unsigned int |
newHeight |
|
) |
| |
Definition at line 183 of file InferenceTestImage.cpp.
References GetHeight(), GetNumChannels(), and GetWidth().
Referenced by Resize().
185 std::vector<uint8_t> newData;
186 newData.resize(newWidth * newHeight * im.
GetNumChannels() * im.GetSingleElementSizeInBytes());
191 const int nW = boost::numeric_cast<
int>(newWidth);
192 const int nH = boost::numeric_cast<
int>(newHeight);
194 const int w =
static_cast<int>(im.
GetWidth());
195 const int h =
static_cast<int>(im.
GetHeight());
198 const int res = stbir_resize_uint8(im.m_Data.data(), w, h, 0, newData.data(), nW, nH, 0, numChannels);
204 im.m_Data.swap(newData);
205 im.m_Width = newWidth;
206 im.m_Height = newHeight;
unsigned int GetWidth() const
unsigned int GetNumChannels() const
unsigned int GetHeight() const
◆ Write()
void Write |
( |
WriteFormat |
format, |
|
|
const char * |
filePath |
|
) |
| const |
Definition at line 243 of file InferenceTestImage.cpp.
References Bmp, GetHeight(), GetNumChannels(), GetWidth(), Png, and Tga.
245 const int w =
static_cast<int>(
GetWidth());
246 const int h =
static_cast<int>(
GetHeight());
254 res = stbi_write_png(filePath, w, h, numChannels, m_Data.data(), 0);
259 res = stbi_write_bmp(filePath, w, h, numChannels, m_Data.data());
264 res = stbi_write_tga(filePath, w, h, numChannels, m_Data.data());
269 % static_cast<int>(format)));
unsigned int GetWidth() const
unsigned int GetNumChannels() const
unsigned int GetHeight() const
The documentation for this class was generated from the following files: