displayer.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*************************************************************************
  2. * Copyright (C) [2019] 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 MODULES_DISPLAYER_HPP_
  21. #define MODULES_DISPLAYER_HPP_
  22. /**
  23. * \file displayer.hpp
  24. *
  25. * This file contains a declaration of class Displayer
  26. */
  27. #include <memory>
  28. #include <string>
  29. #include "opencv2/highgui/highgui.hpp"
  30. #include "opencv2/imgproc/imgproc.hpp"
  31. #if (CV_MAJOR_VERSION >= 3)
  32. #include "opencv2/imgcodecs/imgcodecs.hpp"
  33. #endif
  34. #include "cnstream_frame.hpp"
  35. #include "cnstream_module.hpp"
  36. namespace cnstream {
  37. class SDLVideoPlayer;
  38. /**
  39. * @brief Displayer is a module for displaying the video.
  40. */
  41. class Displayer : public Module, public ModuleCreator<Displayer> {
  42. public:
  43. /**
  44. * @brief Generate Displayer
  45. *
  46. * @param Name : module name
  47. *
  48. * @return None
  49. */
  50. explicit Displayer(const std::string& name);
  51. /**
  52. * @brief Release Displayer
  53. *
  54. * @param None
  55. *
  56. * @return None
  57. */
  58. ~Displayer();
  59. /**
  60. * @brief Called by pipeline when pipeline start.
  61. *
  62. * @param paramSet :
  63. * @verbatim
  64. * window-width: display window width
  65. * window-height: display window height
  66. * cols: display image columns
  67. * rows: display image rows
  68. * refresh-rate: display refresh rate
  69. * @endverbatim
  70. *
  71. * @return if module open succeed
  72. */
  73. bool Open(ModuleParamSet paramSet) override;
  74. /**
  75. * @brief Called by pipeline when pipeline stop
  76. *
  77. * @param None
  78. *
  79. * @return None
  80. */
  81. void Close() override;
  82. /**
  83. * @brief display each frame
  84. *
  85. * @param data : data to be processed
  86. *
  87. * @return whether process succeed
  88. * @retval 0: succeed and do no intercept data
  89. * @retval <0: failed
  90. */
  91. int Process(CNFrameInfoPtr data) override;
  92. /**
  93. * @brief GUI event loop
  94. */
  95. void GUILoop(const std::function<void()>& quit_callback);
  96. /**
  97. *@brief return whether show
  98. */
  99. inline bool Show() { return show_; }
  100. /**
  101. * @brief Check ParamSet for a module.
  102. *
  103. * @param paramSet Parameters for this module.
  104. *
  105. * @return Returns true if this API run successfully. Otherwise, returns false.
  106. */
  107. bool CheckParamSet(const ModuleParamSet& paramSet) const override;
  108. private:
  109. SDLVideoPlayer* player_;
  110. bool show_ = false;
  111. }; // class Displayer
  112. } // namespace cnstream
  113. #endif // MODULES_DISPLAYER_HPP_