#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 128 of file InferenceTestImage.cpp.
References GetSizeInBytes(), and armnn::numeric_cast().
137 using StbImageDataPtr = std::unique_ptr<unsigned char, decltype(&stbi_image_free)>;
138 StbImageDataPtr stbData(stbi_load(filePath, &width, &height, &channels, 0), &stbi_image_free);
140 if (stbData ==
nullptr)
145 if (width == 0 || height == 0)
155 m_Data.resize(sizeInBytes);
156 memcpy(m_Data.data(), stbData.get(), sizeInBytes);
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
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 GetNumChannels() const
unsigned int GetWidth() 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 159 of file InferenceTestImage.cpp.
References ARMNN_ASSERT, GetNumChannels(), GetSizeInBytes(), and GetWidth().
Referenced by GetImageDataAsNormalizedFloats(), and GetImageDataInArmNnLayoutAsFloats().
161 if (x >= m_Width || y >= m_Height)
164 "Requested (%1%, %2%). Maximum valid coordinates (%3%, %4%).") % x % y % (m_Width - 1) % (m_Height - 1)));
168 const uint8_t*
const pixelData = m_Data.data() + pixelOffset;
171 std::array<uint8_t, 3> outPixelData;
172 outPixelData.fill(0);
174 const unsigned int maxChannelsInPixel = std::min(
GetNumChannels(), static_cast<unsigned int>(outPixelData.size()));
175 for (
unsigned int c = 0; c < maxChannelsInPixel; ++c)
177 outPixelData[c] = pixelData[c];
180 return std::make_tuple(outPixelData[0], outPixelData[1], outPixelData[2]);
unsigned int GetNumChannels() const
unsigned int GetWidth() const
#define ARMNN_ASSERT(COND)
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 210 of file InferenceTestImage.cpp.
References CheckLocation::AsString(), BilinearAndNormalized, STB, and StbResize().
Referenced by CaffePreprocessor::GetTestCaseData(), and YoloDatabase::GetTestCaseData().
218 std::vector<float> out;
219 if (newWidth == 0 || newHeight == 0)
222 "operation can be zero. Requested width: %1%. Requested height: %2%.") % newWidth % newHeight));
233 out = ResizeBilinearAndNormalize(*
this, newWidth, newHeight, scale, mean, stddev);
238 boost::format(
"Unknown resizing method asked ArmNN only supports {STB, BilinearAndNormalized} %1%")
std::string AsString() const
void StbResize(InferenceTestImage &im, const unsigned int newWidth, const unsigned int newHeight)
◆ StbResize()
void StbResize |
( |
InferenceTestImage & |
im, |
|
|
const unsigned int |
newWidth, |
|
|
const unsigned int |
newHeight |
|
) |
| |
Definition at line 184 of file InferenceTestImage.cpp.
References GetHeight(), GetNumChannels(), GetWidth(), and armnn::numeric_cast().
Referenced by Resize().
186 std::vector<uint8_t> newData;
187 newData.resize(newWidth * newHeight * im.
GetNumChannels() * im.GetSingleElementSizeInBytes());
195 const int w =
static_cast<int>(im.
GetWidth());
196 const int h =
static_cast<int>(im.
GetHeight());
199 const int res = stbir_resize_uint8(im.m_Data.data(), w, h, 0, newData.data(), nW, nH, 0, numChannels);
205 im.m_Data.swap(newData);
206 im.m_Width = newWidth;
207 im.m_Height = newHeight;
unsigned int GetNumChannels() const
unsigned int GetWidth() const
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
unsigned int GetHeight() const
◆ Write()
void Write |
( |
WriteFormat |
format, |
|
|
const char * |
filePath |
|
) |
| const |
Definition at line 244 of file InferenceTestImage.cpp.
References Bmp, GetHeight(), GetNumChannels(), GetWidth(), Png, and Tga.
246 const int w =
static_cast<int>(
GetWidth());
247 const int h =
static_cast<int>(
GetHeight());
255 res = stbi_write_png(filePath, w, h, numChannels, m_Data.data(), 0);
260 res = stbi_write_bmp(filePath, w, h, numChannels, m_Data.data());
265 res = stbi_write_tga(filePath, w, h, numChannels, m_Data.data());
270 % static_cast<int>(format)));
unsigned int GetNumChannels() const
unsigned int GetWidth() const
unsigned int GetHeight() const
The documentation for this class was generated from the following files: