From b6e9ed4ec5843a5a0cbc170f18e1cf0c8abc18e0 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Tue, 16 Aug 2011 09:51:54 +0000 Subject: [PATCH] fixed bug in opencv_stitching (added handling of homography evaluation failure) --- modules/stitching/main.cpp | 1 + modules/stitching/matchers.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/modules/stitching/main.cpp b/modules/stitching/main.cpp index ea4b331..d465229 100644 --- a/modules/stitching/main.cpp +++ b/modules/stitching/main.cpp @@ -549,6 +549,7 @@ int main(int argc, char* argv[]) sz.width = cvRound(full_img_sizes[i].width * compose_scale); sz.height = cvRound(full_img_sizes[i].height * compose_scale); } + Rect roi = warper->warpRoi(sz, static_cast(cameras[i].focal), cameras[i].R); corners[i] = roi.tl(); sizes[i] = roi.size(); diff --git a/modules/stitching/matchers.cpp b/modules/stitching/matchers.cpp index b043886..6365c2b 100644 --- a/modules/stitching/matchers.cpp +++ b/modules/stitching/matchers.cpp @@ -465,6 +465,8 @@ void BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFea // Find pair-wise motion matches_info.H = findHomography(src_points, dst_points, matches_info.inliers_mask, CV_RANSAC); + if (abs(determinant(matches_info.H)) < numeric_limits::epsilon()) + return; // Find number of inliers matches_info.num_inliers = 0; -- 2.7.4