From ed7607935e61b1499b7cf14cf34ec73d97d52c6d Mon Sep 17 00:00:00 2001 From: Quentin Chateau Date: Sat, 5 Jan 2019 16:39:09 +0100 Subject: [PATCH] Do not compute gains when no images overlap --- modules/stitching/src/exposure_compensate.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/stitching/src/exposure_compensate.cpp b/modules/stitching/src/exposure_compensate.cpp index e77a6ae982..c204af220e 100644 --- a/modules/stitching/src/exposure_compensate.cpp +++ b/modules/stitching/src/exposure_compensate.cpp @@ -201,6 +201,12 @@ void GainCompensator::singleFeed(const std::vector &corners, const std::v double alpha = 0.01; double beta = 100; int num_eq = num_images - countNonZero(skip); + gains_.create(num_images, 1); + gains_.setTo(1); + + // No image process, gains are all set to one, stop here + if (num_eq == 0) + return; Mat_ A(num_eq, num_eq); A.setTo(0); Mat_ b(num_eq, 1); b.setTo(0); @@ -248,12 +254,10 @@ void GainCompensator::singleFeed(const std::vector &corners, const std::v #endif CV_CheckTypeEQ(l_gains.type(), CV_64FC1, ""); - gains_.create(num_images, 1); for (int i = 0, j = 0; i < num_images; ++i) { - if (skip(i, 0)) - gains_.at(i, 0) = 1; - else + // Only assign non-skipped gains. Other gains are already set to 1 + if (!skip(i, 0)) gains_.at(i, 0) = l_gains(j++, 0); } }