preprocessor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Caddn serials model.
  22. */
  23. class ULTRAINFER_DECL CaddnPreprocessor : public ProcessorManager {
  24. public:
  25. CaddnPreprocessor() = default;
  26. /** \brief Create a preprocessor instance for Caddn model
  27. *
  28. * \param[in] config_file Path of configuration file for deployment, e.g
  29. * Caddn/infer_cfg.yml
  30. */
  31. explicit CaddnPreprocessor(const std::string &config_file);
  32. bool Run(std::vector<FDMat> *images, std::vector<float> &input_cam_data,
  33. std::vector<float> &input_lidar_data,
  34. std::vector<FDTensor> *outputs);
  35. /** \brief Process the input image and prepare input tensors for runtime
  36. *
  37. * \param[in] images The input image data list, all the elements are returned
  38. * by cv::imread() \param[in] outputs The output tensors which will feed in
  39. * runtime \param[in] ims_info The shape info list, record input_shape and
  40. * output_shape \return true if the preprocess succeeded, otherwise false
  41. */
  42. bool Apply(FDMatBatch *image_batch, std::vector<FDTensor> *outputs) {
  43. FDERROR << "CaddnPreprocessor should input cam and lidar datas"
  44. << std::endl;
  45. return 0;
  46. };
  47. bool Apply(FDMatBatch *image_batch, std::vector<float> &input_cam_data,
  48. std::vector<float> &input_lidar_data,
  49. std::vector<FDTensor> *outputs);
  50. protected:
  51. bool BuildPreprocessPipeline();
  52. std::vector<std::shared_ptr<Processor>> processors_;
  53. bool disable_permute_ = false;
  54. bool initialized_ = false;
  55. std::string config_file_;
  56. };
  57. } // namespace perception
  58. } // namespace vision
  59. } // namespace ultra_infer