blob: a57382e6189980941e1dc0f2020206baea940838 [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa014fcda012018-03-09 14:13:49 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#pragma once
6
7#include "ClassifierTestCaseData.hpp"
8
9#include <array>
10#include <string>
11#include <vector>
12#include <memory>
13
telsoa01c577f2c2018-08-31 09:22:23 +010014/// Caffe requires BGR images, not normalized, mean adjusted and resized using smooth resize of STB library
15
telsoa014fcda012018-03-09 14:13:49 +000016using ImageSet = std::pair<const std::string, unsigned int>;
17
telsoa01c577f2c2018-08-31 09:22:23 +010018class CaffePreprocessor
telsoa014fcda012018-03-09 14:13:49 +000019{
20public:
telsoa01c577f2c2018-08-31 09:22:23 +010021 using DataType = float;
22 using TTestCaseData = ClassifierTestCaseData<DataType>;
telsoa014fcda012018-03-09 14:13:49 +000023
telsoa01c577f2c2018-08-31 09:22:23 +010024 explicit CaffePreprocessor(const std::string& binaryFileDirectory,
telsoa014fcda012018-03-09 14:13:49 +000025 unsigned int width = 227,
26 unsigned int height = 227,
27 const std::vector<ImageSet>& imageSet = std::vector<ImageSet>());
28 std::unique_ptr<TTestCaseData> GetTestCaseData(unsigned int testCaseId);
29
30private:
31 unsigned int GetNumImageElements() const { return 3 * m_Width * m_Height; }
32 unsigned int GetNumImageBytes() const { return 4 * GetNumImageElements(); }
33
34 std::string m_BinaryDirectory;
35 unsigned int m_Height;
36 unsigned int m_Width;
telsoa01c577f2c2018-08-31 09:22:23 +010037 // Mean value of the database [B, G, R].
telsoa014fcda012018-03-09 14:13:49 +000038 const std::array<float, 3> m_MeanBgr = {{104.007965f, 116.669472f, 122.675102f}};
39 const std::vector<ImageSet> m_ImageSet;
telsoa01c577f2c2018-08-31 09:22:23 +010040};