show_image.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef CVVISUAL_DEBUG_SHOW_IMAGE_HPP
  2. #define CVVISUAL_DEBUG_SHOW_IMAGE_HPP
  3. #include <string>
  4. #include "opencv2/core.hpp"
  5. #include "call_meta_data.hpp"
  6. #include "debug_mode.hpp"
  7. #ifdef CV_DOXYGEN
  8. #define CVVISUAL_DEBUGMODE
  9. #endif
  10. namespace cvv
  11. {
  12. //! @addtogroup cvv
  13. //! @{
  14. namespace impl
  15. {
  16. // implementation outside API
  17. CV_EXPORTS void showImage(cv::InputArray img, const CallMetaData &data,
  18. const char *description, const char *view);
  19. } // namespace impl
  20. #ifdef CVVISUAL_DEBUGMODE
  21. /** @brief Add a single image to debug GUI (similar to imshow \<\>).
  22. @param img Image to show in debug GUI.
  23. @param metaData Properly initialized CallMetaData struct, i.e. information about file, line and
  24. function name for GUI. Use CVVISUAL_LOCATION macro.
  25. @param description Human readable description to provide context to image.
  26. @param view Preselect view that will be used to visualize this image in GUI. Other views can still
  27. be selected in GUI later on.
  28. */
  29. static inline void showImage(cv::InputArray img,
  30. impl::CallMetaData metaData = impl::CallMetaData(),
  31. const char *description = nullptr,
  32. const char *view = nullptr)
  33. {
  34. if (debugMode())
  35. {
  36. impl::showImage(img, metaData, description, view);
  37. }
  38. }
  39. /** @overload */
  40. static inline void showImage(cv::InputArray img, impl::CallMetaData metaData,
  41. const ::std::string &description,
  42. const ::std::string &view = "")
  43. {
  44. if (debugMode())
  45. {
  46. impl::showImage(img, metaData, description.c_str(),
  47. view.c_str());
  48. }
  49. }
  50. #else
  51. static inline void showImage(cv::InputArray,
  52. impl::CallMetaData = impl::CallMetaData(),
  53. const char * = nullptr, const char * = nullptr)
  54. {
  55. }
  56. static inline void showImage(cv::InputArray, impl::CallMetaData,
  57. const ::std::string &, const ::std::string &)
  58. {
  59. }
  60. #endif
  61. //! @}
  62. } // namespace cvv
  63. #endif