From 38788a31619b742f3af86db4e0e5e9fcf8343de9 Mon Sep 17 00:00:00 2001 From: Oguzhan Guclu Date: Sat, 2 Apr 2022 01:13:14 +0300 Subject: [PATCH] Merge pull request #21803 from oguzhanguclu:matches_info_pybinding python binding for matches and inliers_mask attributes of cv2.detail_MatchesInfo class * making matches and inliers_mask attributes of cv2.detail_MatchesInfo class accessible from python interface * binding test for cv2.detail_MatchesInfo class --- .../opencv2/stitching/detail/matchers.hpp | 4 ++-- .../misc/python/test/test_stitching.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/stitching/include/opencv2/stitching/detail/matchers.hpp b/modules/stitching/include/opencv2/stitching/detail/matchers.hpp index cd9749ca8b..1b7d7d6897 100644 --- a/modules/stitching/include/opencv2/stitching/detail/matchers.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/matchers.hpp @@ -104,8 +104,8 @@ struct CV_EXPORTS_W_SIMPLE MatchesInfo CV_PROP_RW int src_img_idx; CV_PROP_RW int dst_img_idx; //!< Images indices (optional) - std::vector matches; - std::vector inliers_mask; //!< Geometrically consistent matches mask + CV_PROP_RW std::vector matches; + CV_PROP_RW std::vector inliers_mask; //!< Geometrically consistent matches mask CV_PROP_RW int num_inliers; //!< Number of geometrically consistent matches CV_PROP_RW Mat H; //!< Estimated transformation CV_PROP_RW double confidence; //!< Confidence two images are from the same panorama diff --git a/modules/stitching/misc/python/test/test_stitching.py b/modules/stitching/misc/python/test/test_stitching.py index 0d66182fb8..2e7b2b5818 100644 --- a/modules/stitching/misc/python/test/test_stitching.py +++ b/modules/stitching/misc/python/test/test_stitching.py @@ -118,5 +118,22 @@ class stitching_compose_panorama_args(NewOpenCVTests): assert result == 0 +class stitching_matches_info_test(NewOpenCVTests): + + def test_simple(self): + finder = cv.ORB.create() + img1 = self.get_sample('stitching/a1.png') + img2 = self.get_sample('stitching/a2.png') + + img_feat1 = cv.detail.computeImageFeatures2(finder, img1) + img_feat2 = cv.detail.computeImageFeatures2(finder, img2) + + matcher = cv.detail.BestOf2NearestMatcher_create() + matches_info = matcher.apply(img_feat1, img_feat2) + + self.assertIsNotNone(matches_info.matches) + self.assertIsNotNone(matches_info.inliers_mask) + + if __name__ == '__main__': NewOpenCVTests.bootstrap()