preprocessor.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. namespace ultra_infer {
  18. namespace vision {
  19. namespace facedet {
  20. class ULTRAINFER_DECL CenterFacePreprocessor {
  21. public:
  22. /** \brief Create a preprocessor instance for CenterFace serials model
  23. */
  24. CenterFacePreprocessor();
  25. /** \brief Process the input image and prepare input tensors for runtime
  26. *
  27. * \param[in] images The input image data list, all the elements are returned
  28. * by cv::imread() \param[in] outputs The output tensors which will feed in
  29. * runtime \param[in] ims_info The shape info list, record input_shape and
  30. * output_shape \ret
  31. */
  32. bool Run(std::vector<FDMat> *images, std::vector<FDTensor> *outputs,
  33. std::vector<std::map<std::string, std::array<float, 2>>> *ims_info);
  34. /// Set target size, tuple of (width, height), default size = {640, 640}
  35. void SetSize(const std::vector<int> &size) { size_ = size; }
  36. /// Get target size, tuple of (width, height), default size = {640, 640}
  37. std::vector<int> GetSize() const { return size_; }
  38. protected:
  39. bool Preprocess(FDMat *mat, FDTensor *output,
  40. std::map<std::string, std::array<float, 2>> *im_info);
  41. // target size, tuple of (width, height), default size = {640, 640}
  42. std::vector<int> size_;
  43. };
  44. } // namespace facedet
  45. } // namespace vision
  46. } // namespace ultra_infer