From 87c2b8197ac4b4af3d049577d5c0e3443fc33c28 Mon Sep 17 00:00:00 2001 From: Olexa Bilaniuk Date: Thu, 5 Feb 2015 02:18:41 -0500 Subject: [PATCH] Bug fixes in mask output. Previously, the output mask of inliers could remain completely uninitialized. This fix is the first part of a solution. --- modules/calib3d/src/fundam.cpp | 7 ++----- modules/calib3d/src/rhorefc.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index 327670249..1366e9baa 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -286,7 +286,7 @@ static bool createAndRunRHORegistrator(double confidence, OutputArray _tempMask){ Mat src = _src.getMat(); Mat dst = _dst.getMat(); - Mat tempMask = _tempMask.getMat(); + Mat tempMask; bool result; double beta = 0.35;/* 0.35 is a value that often works. */ @@ -294,10 +294,7 @@ static bool createAndRunRHORegistrator(double confidence, Mat tmpH = Mat(3, 3, CV_32FC1); /* Create output mask. */ - if(!tempMask.data){ - tempMask = Mat(npoints, 1, CV_8U); - } - + tempMask = Mat(npoints, 1, CV_8U); /** * Make use of the RHO estimator API. diff --git a/modules/calib3d/src/rhorefc.cpp b/modules/calib3d/src/rhorefc.cpp index 6d8924480..3cc9a8a1c 100644 --- a/modules/calib3d/src/rhorefc.cpp +++ b/modules/calib3d/src/rhorefc.cpp @@ -512,6 +512,9 @@ static inline int sacInitRun(RHO_HEST_REFC* p){ return 0; } + memset(p->best.inl, 0, p->arg.N); + memset(p->curr.inl, 0, p->arg.N); + /** * LevMarq workspace alloc. * @@ -1155,6 +1158,9 @@ static inline void sacUpdateBounds(RHO_HEST_REFC* p){ static inline void sacOutputModel(RHO_HEST_REFC* p){ if(sacIsBestModelGoodEnough(p)){ memcpy(p->arg.finalH, p->best.H, HSIZE); + if(p->arg.inl != p->best.inl){ + memcpy(p->arg.inl, p->best.inl, p->arg.N); + } }else{ sacOutputZeroH(p); }