dmatch.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef CVVISUAL_DEBUG_DMATCH_HPP
  2. #define CVVISUAL_DEBUG_DMATCH_HPP
  3. #include <string>
  4. #include "opencv2/core.hpp"
  5. #include "opencv2/features2d.hpp"
  6. #include "call_meta_data.hpp"
  7. #include "debug_mode.hpp"
  8. #ifdef CV_DOXYGEN
  9. #define CVVISUAL_DEBUGMODE
  10. #endif
  11. namespace cvv
  12. {
  13. //! @addtogroup cvv
  14. //! @{
  15. namespace impl
  16. {
  17. CV_EXPORTS void debugDMatch(cv::InputArray img1, std::vector<cv::KeyPoint> keypoints1,
  18. cv::InputArray img2, std::vector<cv::KeyPoint> keypoints2,
  19. std::vector<cv::DMatch> matches, const CallMetaData &data,
  20. const char *description, const char *view,
  21. bool useTrainDescriptor);
  22. } // namespace impl
  23. #ifdef CVVISUAL_DEBUGMODE
  24. /** @brief Add a filled in DMatch \<dmatch\> to debug GUI.
  25. The matches can are visualized for interactive inspection in different GUI views (one similar to an
  26. interactive :draw_matches:drawMatches\<\>).
  27. @param img1 First image used in DMatch \<dmatch\>.
  28. @param keypoints1 Keypoints of first image.
  29. @param img2 Second image used in DMatch.
  30. @param keypoints2 Keypoints of second image.
  31. @param matches
  32. @param data See showImage
  33. @param description See showImage
  34. @param view See showImage
  35. @param useTrainDescriptor Use DMatch \<dmatch\>'s train descriptor index instead of query
  36. descriptor index.
  37. */
  38. static inline void
  39. debugDMatch(cv::InputArray img1, std::vector<cv::KeyPoint> keypoints1,
  40. cv::InputArray img2, std::vector<cv::KeyPoint> keypoints2,
  41. std::vector<cv::DMatch> matches, const impl::CallMetaData &data,
  42. const char *description = nullptr, const char *view = nullptr,
  43. bool useTrainDescriptor = true)
  44. {
  45. if (debugMode())
  46. {
  47. impl::debugDMatch(img1, std::move(keypoints1), img2,
  48. std::move(keypoints2), std::move(matches),
  49. data, description, view, useTrainDescriptor);
  50. }
  51. }
  52. /** @overload */
  53. static inline void
  54. debugDMatch(cv::InputArray img1, std::vector<cv::KeyPoint> keypoints1,
  55. cv::InputArray img2, std::vector<cv::KeyPoint> keypoints2,
  56. std::vector<cv::DMatch> matches, const impl::CallMetaData &data,
  57. const std::string &description, const std::string &view,
  58. bool useTrainDescriptor = true)
  59. {
  60. if (debugMode())
  61. {
  62. impl::debugDMatch(img1, std::move(keypoints1), img2,
  63. std::move(keypoints2), std::move(matches),
  64. data, description.c_str(), view.c_str(),
  65. useTrainDescriptor);
  66. }
  67. }
  68. #else
  69. static inline void debugDMatch(cv::InputArray, std::vector<cv::KeyPoint>,
  70. cv::InputArray, std::vector<cv::KeyPoint>,
  71. std::vector<cv::DMatch>,
  72. const impl::CallMetaData &,
  73. const char * = nullptr, const char * = nullptr,
  74. bool = true)
  75. {
  76. }
  77. static inline void debugDMatch(cv::InputArray, std::vector<cv::KeyPoint>,
  78. cv::InputArray, std::vector<cv::KeyPoint>,
  79. std::vector<cv::DMatch>,
  80. const impl::CallMetaData &, const std::string &,
  81. const std::string &, bool = true)
  82. {
  83. }
  84. #endif
  85. //! @}
  86. } // namespace cvv
  87. #endif