pipeline.h 2.5 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/ultra_infer_model.h"
  16. #include "ultra_infer/vision/common/result.h"
  17. #include "ultra_infer/vision/detection/ppdet/model.h"
  18. #include "ultra_infer/vision/keypointdet/pptinypose/pptinypose.h"
  19. namespace ultra_infer {
  20. /** \brief All pipeline model APIs are defined inside this namespace
  21. *
  22. */
  23. namespace pipeline {
  24. /*! @brief PPTinyPose Pipeline object used when to load a detection model +
  25. * pptinypose model
  26. */
  27. class ULTRAINFER_DECL PPTinyPose {
  28. public:
  29. /** \brief Set initialized detection model object and pptinypose model object
  30. *
  31. * \param[in] det_model Initialized detection model object
  32. * \param[in] pptinypose_model Initialized pptinypose model object
  33. */
  34. PPTinyPose(
  35. ultra_infer::vision::detection::PicoDet *det_model,
  36. ultra_infer::vision::keypointdetection::PPTinyPose *pptinypose_model);
  37. /** \brief Predict the keypoint detection result for an input image
  38. *
  39. * \param[in] img The input image data, comes from cv::imread()
  40. * \param[in] result The output keypoint detection result will be written to
  41. * this structure \return true if the prediction succeeded, otherwise false
  42. */
  43. virtual bool Predict(cv::Mat *img,
  44. ultra_infer::vision::KeyPointDetectionResult *result);
  45. /* \brief The score threshold for detecting model to filter bbox before
  46. * inputting pptinypose model
  47. */
  48. float detection_model_score_threshold = 0;
  49. protected:
  50. ultra_infer::vision::detection::PicoDet *detector_ = nullptr;
  51. ultra_infer::vision::keypointdetection::PPTinyPose *pptinypose_model_ =
  52. nullptr;
  53. virtual bool Detect(cv::Mat *img,
  54. ultra_infer::vision::DetectionResult *result);
  55. virtual bool
  56. KeypointDetect(cv::Mat *img,
  57. ultra_infer::vision::KeyPointDetectionResult *result,
  58. ultra_infer::vision::DetectionResult &detection_result);
  59. };
  60. } // namespace pipeline
  61. } // namespace ultra_infer