37 #ifndef ESTIMATION_INTERNAL_H_ 38 #define ESTIMATION_INTERNAL_H_ 41 #include <opencv2/core/utility.hpp> 42 #include <opencv2/imgcodecs.hpp> 43 #include <opencv2/stitching/detail/matchers.hpp> 49 static inline cv::Ptr<cv::detail::FeaturesFinder>
54 return cv::makePtr<cv::detail::AKAZEFeaturesFinder>();
56 return cv::makePtr<cv::detail::OrbFeaturesFinder>();
58 return cv::makePtr<cv::detail::SurfFeaturesFinder>();
63 const std::vector<cv::Mat>& images,
64 const std::vector<cv::detail::ImageFeatures>& image_features,
65 const std::vector<cv::detail::MatchesInfo>& pairwise_matches)
67 for (
auto& match_info : pairwise_matches) {
68 if (match_info.H.empty() ||
69 match_info.src_img_idx >= match_info.dst_img_idx) {
72 std::cout << match_info.src_img_idx <<
" " << match_info.dst_img_idx
75 << image_features[size_t(match_info.src_img_idx)].keypoints.size()
77 << image_features[size_t(match_info.dst_img_idx)].keypoints.size()
79 <<
"matches: " << match_info.matches.size() << std::endl
80 <<
"inliers: " << match_info.num_inliers << std::endl
81 <<
"inliers/matches ratio: " 82 << match_info.num_inliers / double(match_info.matches.size())
84 <<
"confidence: " << match_info.confidence << std::endl
85 << match_info.H << std::endl;
88 cv::drawMatches(images[
size_t(match_info.src_img_idx)],
89 image_features[size_t(match_info.src_img_idx)].keypoints,
90 images[size_t(match_info.dst_img_idx)],
91 image_features[size_t(match_info.dst_img_idx)].keypoints,
92 match_info.matches, img);
93 cv::imwrite(std::to_string(match_info.src_img_idx) +
"_" +
94 std::to_string(match_info.dst_img_idx) +
"_matches.png",
98 images[
size_t(match_info.src_img_idx)],
99 image_features[
size_t(match_info.src_img_idx)].keypoints,
100 images[
size_t(match_info.dst_img_idx)],
101 image_features[
size_t(match_info.dst_img_idx)].keypoints,
102 match_info.matches, img, cv::Scalar::all(-1), cv::Scalar::all(-1),
103 *reinterpret_cast<
const std::vector<char>*>(&match_info.inliers_mask));
104 cv::imwrite(std::to_string(match_info.src_img_idx) +
"_" +
105 std::to_string(match_info.dst_img_idx) +
106 "_matches_inliers.png",
114 #endif // ESTIMATION_INTERNAL_H_ static void writeDebugMatchingInfo(const std::vector< cv::Mat > &images, const std::vector< cv::detail::ImageFeatures > &image_features, const std::vector< cv::detail::MatchesInfo > &pairwise_matches)
static cv::Ptr< cv::detail::FeaturesFinder > chooseFeatureFinder(FeatureType type)