ArmNN
 21.05
YoloDatabase Class Reference

#include <YoloDatabase.hpp>

Public Types

using TTestCaseData = YoloTestCaseData
 

Public Member Functions

 YoloDatabase (const std::string &imageDir)
 
std::unique_ptr< TTestCaseDataGetTestCaseData (unsigned int testCaseId)
 

Detailed Description

Definition at line 53 of file YoloDatabase.hpp.

Member Typedef Documentation

◆ TTestCaseData

Definition at line 56 of file YoloDatabase.hpp.

Constructor & Destructor Documentation

◆ YoloDatabase()

YoloDatabase ( const std::string &  imageDir)
explicit

Definition at line 68 of file YoloDatabase.cpp.

69  : m_ImageDir(imageDir)
70 {
71 }

Member Function Documentation

◆ GetTestCaseData()

std::unique_ptr< YoloDatabase::TTestCaseData > GetTestCaseData ( unsigned int  testCaseId)

Definition at line 73 of file YoloDatabase.cpp.

References ARMNN_LOG, CHECK_LOCATION, GetImageDataInArmNnLayoutAsNormalizedFloats(), armnn::numeric_cast(), InferenceTestImage::Resize(), Rgb, Exception::what(), YoloImageHeight, and YoloImageWidth.

74 {
75  testCaseId = testCaseId % armnn::numeric_cast<unsigned int>(g_PerTestCaseInputOutput.size());
76  const auto& testCaseInputOutput = g_PerTestCaseInputOutput[testCaseId];
77  const std::string imagePath = m_ImageDir + testCaseInputOutput.first;
78 
79  // Loads test case input image.
80  std::vector<float> imageData;
81  try
82  {
83  InferenceTestImage image(imagePath.c_str());
84  if (YoloImageWidth != image.GetWidth() || YoloImageHeight != image.GetHeight())
85  {
87  }
89  }
90  catch (const InferenceTestImageException& e)
91  {
92  ARMNN_LOG(fatal) << "Failed to load test case " << testCaseId << " with error: " << e.what();
93  return nullptr;
94  }
95 
96  // Prepares test case output.
97  std::vector<YoloDetectedObject> topObjectDetections;
98  topObjectDetections.reserve(1);
99  topObjectDetections.push_back(testCaseInputOutput.second);
100 
101  return std::make_unique<YoloTestCaseData>(std::move(imageData), std::move(topObjectDetections));
102 }
constexpr unsigned int YoloImageHeight
virtual const char * what() const noexcept override
Definition: Exceptions.cpp:32
#define ARMNN_LOG(severity)
Definition: Logging.hpp:202
std::vector< float > GetImageDataInArmNnLayoutAsNormalizedFloats(ImageChannelLayout layout, const InferenceTestImage &image)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
constexpr unsigned int YoloImageWidth
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
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)

The documentation for this class was generated from the following files: