Richard Burton | 11b75cc | 2022-04-07 18:00:55 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2022 Arm Limited. All rights reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | #ifndef BASE_PROCESSING_HPP |
| 18 | #define BASE_PROCESSING_HPP |
| 19 | |
| 20 | #include "Model.hpp" |
| 21 | |
| 22 | namespace arm { |
| 23 | namespace app { |
| 24 | |
| 25 | /** |
| 26 | * @brief Base class exposing pre-processing API. |
| 27 | * Use cases should provide their own PreProcessing class that inherits from this one. |
| 28 | * All steps required to take raw input data and populate tensors ready for inference |
| 29 | * should be handled. |
| 30 | */ |
| 31 | class BasePreProcess { |
| 32 | |
| 33 | public: |
| 34 | virtual ~BasePreProcess() = default; |
| 35 | |
| 36 | /** |
| 37 | * @brief Should perform pre-processing of 'raw' input data and load it into |
| 38 | * TFLite Micro input tensors ready for inference |
| 39 | * @param[in] input Pointer to the data that pre-processing will work on. |
| 40 | * @param[in] inputSize Size of the input data. |
| 41 | * @return true if successful, false otherwise. |
| 42 | **/ |
| 43 | virtual bool DoPreProcess(const void* input, size_t inputSize) = 0; |
| 44 | |
| 45 | protected: |
| 46 | Model* m_model = nullptr; |
| 47 | }; |
| 48 | |
| 49 | /** |
| 50 | * @brief Base class exposing post-processing API. |
| 51 | * Use cases should provide their own PostProcessing class that inherits from this one. |
| 52 | * All steps required to take inference output and populate results vectors should be handled. |
| 53 | */ |
| 54 | class BasePostProcess { |
| 55 | |
| 56 | public: |
| 57 | virtual ~BasePostProcess() = default; |
| 58 | |
| 59 | /** |
| 60 | * @brief Should perform post-processing of the result of inference then populate |
| 61 | * populate result data for any later use. |
| 62 | * @return true if successful, false otherwise. |
| 63 | **/ |
| 64 | virtual bool DoPostProcess() = 0; |
| 65 | |
| 66 | protected: |
| 67 | Model* m_model = nullptr; |
| 68 | }; |
| 69 | |
| 70 | } /* namespace app */ |
| 71 | } /* namespace arm */ |
| 72 | |
| 73 | #endif /* BASE_PROCESSING_HPP */ |