preprocessor.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "ultra_infer/vision/common/processors/manager.h"
  16. #include "ultra_infer/vision/common/processors/transform.h"
  17. #include "ultra_infer/vision/common/result.h"
  18. namespace ultra_infer {
  19. namespace vision {
  20. namespace perception {
  21. /*! @brief Preprocessor object for Smoke serials model.
  22. */
  23. class ULTRAINFER_DECL SmokePreprocessor : public ProcessorManager {
  24. public:
  25. SmokePreprocessor() = default;
  26. /** \brief Create a preprocessor instance for Smoke model
  27. *
  28. * \param[in] config_file Path of configuration file for deployment, e.g
  29. * smoke/infer_cfg.yml
  30. */
  31. explicit SmokePreprocessor(const std::string &config_file);
  32. /** \brief Process the input image and prepare input tensors for runtime
  33. *
  34. * \param[in] images The input image data list, all the elements are returned
  35. * by cv::imread() \param[in] outputs The output tensors which will feed in
  36. * runtime \param[in] ims_info The shape info list, record input_shape and
  37. * output_shape \return true if the preprocess succeeded, otherwise false
  38. */
  39. bool Apply(FDMatBatch *image_batch, std::vector<FDTensor> *outputs);
  40. protected:
  41. bool BuildPreprocessPipelineFromConfig();
  42. std::vector<std::shared_ptr<Processor>> processors_;
  43. bool disable_permute_ = false;
  44. bool initialized_ = false;
  45. std::string config_file_;
  46. std::vector<float> input_k_data_;
  47. std::vector<float> input_ratio_data_;
  48. };
  49. } // namespace perception
  50. } // namespace vision
  51. } // namespace ultra_infer