| 71 | } |
| 72 | |
| 73 | std::unique_ptr<YoloDatabase::TTestCaseData> YoloDatabase::GetTestCaseData(unsigned int testCaseId) |
| 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 | { |
| 86 | image.Resize(YoloImageWidth, YoloImageHeight, CHECK_LOCATION()); |
| 87 | } |
| 88 | imageData = GetImageDataInArmNnLayoutAsNormalizedFloats(ImageChannelLayout::Rgb, image); |
| 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 | } |