Richard Burton | ef90497 | 2022-04-27 17:24:36 +0100 | [diff] [blame] | 1 | /* |
Richard Burton | f32a86a | 2022-11-15 11:46:11 +0000 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Richard Burton | ef90497 | 2022-04-27 17:24:36 +0100 | [diff] [blame] | 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 DETECTOR_PRE_PROCESSING_HPP |
| 18 | #define DETECTOR_PRE_PROCESSING_HPP |
| 19 | |
| 20 | #include "BaseProcessing.hpp" |
| 21 | #include "Classifier.hpp" |
| 22 | |
| 23 | namespace arm { |
| 24 | namespace app { |
| 25 | |
| 26 | /** |
| 27 | * @brief Pre-processing class for Object detection use case. |
| 28 | * Implements methods declared by BasePreProcess and anything else needed |
| 29 | * to populate input tensors ready for inference. |
| 30 | */ |
| 31 | class DetectorPreProcess : public BasePreProcess { |
| 32 | |
| 33 | public: |
| 34 | /** |
| 35 | * @brief Constructor |
| 36 | * @param[in] inputTensor Pointer to the TFLite Micro input Tensor. |
| 37 | * @param[in] rgb2Gray Convert image from 3 channel RGB to 1 channel grayscale. |
| 38 | * @param[in] convertToInt8 Convert the image from uint8 to int8 range. |
| 39 | **/ |
| 40 | explicit DetectorPreProcess(TfLiteTensor* inputTensor, bool rgb2Gray, bool convertToInt8); |
| 41 | |
| 42 | /** |
| 43 | * @brief Should perform pre-processing of 'raw' input image data and load it into |
| 44 | * TFLite Micro input tensor ready for inference |
| 45 | * @param[in] input Pointer to the data that pre-processing will work on. |
| 46 | * @param[in] inputSize Size of the input data. |
| 47 | * @return true if successful, false otherwise. |
| 48 | **/ |
| 49 | bool DoPreProcess(const void* input, size_t inputSize) override; |
| 50 | |
| 51 | private: |
| 52 | TfLiteTensor* m_inputTensor; |
| 53 | bool m_rgb2Gray; |
| 54 | bool m_convertToInt8; |
| 55 | }; |
| 56 | |
| 57 | } /* namespace app */ |
| 58 | } /* namespace arm */ |
| 59 | |
| 60 | #endif /* DETECTOR_PRE_PROCESSING_HPP */ |