preprocessor.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/transform.h"
  16. #include "ultra_infer/vision/common/result.h"
  17. #include "ultra_infer/vision/detection/ppdet/preprocessor.h"
  18. namespace ultra_infer {
  19. namespace vision {
  20. namespace facedet {
  21. class ULTRAINFER_DECL BlazeFacePreprocessor
  22. : public ultra_infer::vision::detection::PaddleDetPreprocessor {
  23. public:
  24. /** \brief Create a preprocessor instance for BlazeFace serials model
  25. */
  26. BlazeFacePreprocessor() = default;
  27. /** \brief Create a preprocessor instance for Blazeface serials model
  28. *
  29. * \param[in] config_file Path of configuration file for deployment, e.g
  30. * ppyoloe/infer_cfg.yml
  31. */
  32. explicit BlazeFacePreprocessor(const std::string &config_file);
  33. /** \brief Process the input image and prepare input tensors for runtime
  34. *
  35. * \param[in] images The input image data list, all the elements are returned
  36. * by cv::imread() \param[in] outputs The output tensors which will feed in
  37. * runtime \param[in] ims_info The shape info list, record input_shape and
  38. * output_shape \ret
  39. */
  40. bool Run(std::vector<FDMat> *images, std::vector<FDTensor> *outputs,
  41. std::vector<std::map<std::string, std::array<float, 2>>> *ims_info);
  42. private:
  43. bool BuildPreprocessPipelineFromConfig();
  44. // if is_scale_up is false, the input image only can be zoom out,
  45. // the maximum resize scale cannot exceed 1.0
  46. bool is_scale_;
  47. std::vector<float> normalize_mean_;
  48. std::vector<float> normalize_std_;
  49. std::vector<std::shared_ptr<Processor>> processors_;
  50. // read config file
  51. std::string config_file_;
  52. };
  53. } // namespace facedet
  54. } // namespace vision
  55. } // namespace ultra_infer