detection_runner.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*************************************************************************
  2. * Copyright (C) [2020] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #ifndef EDK_SAMPLES_STREAM_APP_DETECTION_RUNNER_H_
  21. #define EDK_SAMPLES_STREAM_APP_DETECTION_RUNNER_H_
  22. #include <memory>
  23. #include <string>
  24. #include "cnosd.h"
  25. #include "cnpostproc.h"
  26. #include "device/mlu_context.h"
  27. #include "easybang/resize_and_colorcvt.h"
  28. #include "easycodec/easy_decode.h"
  29. #include "easyinfer/easy_infer.h"
  30. #include "easyinfer/mlu_memory_op.h"
  31. #include "easyinfer/model_loader.h"
  32. #include "easytrack/easy_track.h"
  33. #include "feature_extractor.h"
  34. #include "runner.h"
  35. class DetectionRunner : public StreamRunner {
  36. public:
  37. DetectionRunner(const std::string& model_path, const std::string& func_name, const std::string& label_path,
  38. const std::string& track_model_path, const std::string& track_func_name,
  39. const std::string& data_path, const std::string& net_type, bool show, bool save_video);
  40. ~DetectionRunner();
  41. void Process(edk::CnFrame frame) override;
  42. private:
  43. edk::MluMemoryOp mem_op_;
  44. edk::EasyInfer infer_;
  45. edk::MluResizeConvertOp rc_op_;
  46. CnOsd osd_;
  47. std::shared_ptr<edk::ModelLoader> model_{nullptr};
  48. std::unique_ptr<FeatureExtractor> feature_extractor_{nullptr};
  49. std::unique_ptr<edk::CnPostproc> postproc_{nullptr};
  50. std::unique_ptr<edk::FeatureMatchTrack> tracker_{nullptr};
  51. std::unique_ptr<cv::VideoWriter> video_writer_{nullptr};
  52. void **mlu_output_{nullptr}, **cpu_output_{nullptr}, **mlu_input_{nullptr};
  53. bool show_;
  54. bool save_video_;
  55. };
  56. #endif // EDK_SAMPLES_STREAM_APP_DETECTION_RUNNER_H_