From de4c3f01788dbe72bd5a51714d85bfc753b700a5 Mon Sep 17 00:00:00 2001 From: Ivan Korolev Date: Thu, 13 Jun 2013 13:41:43 +0400 Subject: [PATCH] Fixed a bug related to video stabilization crashes with a blank video (Bug #3023) --- modules/videostab/src/global_motion.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index 484b598dc1..de93d5c5ac 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -205,6 +205,9 @@ Mat estimateGlobalMotionRobust( estimateGlobMotionLeastSquaresAffine }; const int npoints = static_cast(points0.size()); + if (npoints < params.size) + return Mat::eye(3, 3, CV_32F); + const int niters = static_cast(ceil(log(1 - params.prob) / log(1 - pow(1 - params.eps, params.size)))); @@ -300,6 +303,8 @@ PyrLkRobustMotionEstimator::PyrLkRobustMotionEstimator() Mat PyrLkRobustMotionEstimator::estimate(const Mat &frame0, const Mat &frame1) { detector_->detect(frame0, keypointsPrev_); + if (keypointsPrev_.empty()) + return Mat::eye(3, 3, CV_32F); pointsPrev_.resize(keypointsPrev_.size()); for (size_t i = 0; i < keypointsPrev_.size(); ++i)