/* // Copyright (C) 2021-2024 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. */ #pragma once #include #include #include #include "models/model_base.h" #include "utils/image_utils.h" namespace ov { class InferRequest; } // namespace ov struct InputData; struct InternalModelData; class ImageModel : public ModelBase { public: /// Constructor /// @param modelFileName name of model to load /// @param useAutoResize - if true, image is resized by openvino /// @param layout - model input layout ImageModel(); ImageModel(const std::string& modelFileName, bool useAutoResize, const std::string& layout = ""); std::shared_ptr preprocess(const InputData& inputData, ov::InferRequest& request) override; void updateImageSize(const cv::Size& inputImgSize) override { netInputHeight = inputImgSize.height; netInputWidth = inputImgSize.width; } void Initalise(const std::string& _modelFileName, bool _useAutoResize, const std::string& _layout = "") { useAutoResize = _useAutoResize; ModelBase::Initilise(modelFileName, _layout); } protected: bool useAutoResize; size_t netInputHeight = 0; size_t netInputWidth = 0; cv::InterpolationFlags interpolationMode = cv::INTER_LINEAR; RESIZE_MODE resizeMode = RESIZE_FILL; };