From e646f9d2f1b276991a59edf01bc87dcdf28e2b8f Mon Sep 17 00:00:00 2001 From: Han Hu Date: Fri, 20 May 2016 11:45:46 +0800 Subject: [PATCH] Fix subpixel problem of akaze. This is found in the original akaze repo. Previous sub pixel localization method assumes the coordinate (0, 0) is the up-left corner of the up-left pixel. But as far as I know, opencv uses the center of the up-left corner, in this case it should be done in this way. https://github.com/pablofdezalc/akaze/commit/35aeb83a7142e9ec42419603a094ffc2a1401c05 https://github.com/pablofdezalc/akaze/commit/db3dc22981e856ca8111f2f7fe57d9c2e0286efc --- modules/features2d/src/kaze/AKAZEFeatures.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/features2d/src/kaze/AKAZEFeatures.cpp b/modules/features2d/src/kaze/AKAZEFeatures.cpp index 6f1b610ccf..cc317249a7 100644 --- a/modules/features2d/src/kaze/AKAZEFeatures.cpp +++ b/modules/features2d/src/kaze/AKAZEFeatures.cpp @@ -342,14 +342,14 @@ void AKAZEFeatures::Find_Scale_Space_Extrema(std::vector& kpts) if (is_out == false) { if (is_repeated == false) { - point.pt.x *= ratio; - point.pt.y *= ratio; + point.pt.x = (float)(point.pt.x*ratio + .5*(ratio-1.0)); + point.pt.y = (float)(point.pt.y*ratio + .5*(ratio-1.0)); kpts_aux.push_back(point); npoints++; } else { - point.pt.x *= ratio; - point.pt.y *= ratio; + point.pt.x = (float)(point.pt.x*ratio + .5*(ratio-1.0)); + point.pt.y = (float)(point.pt.y*ratio + .5*(ratio-1.0)); kpts_aux[id_repeated] = point; } } // if is_out @@ -439,8 +439,8 @@ void AKAZEFeatures::Do_Subpixel_Refinement(std::vector& kpts) kpts[i].pt.x = x + dst(0); kpts[i].pt.y = y + dst(1); int power = fastpow(2, evolution_[kpts[i].class_id].octave); - kpts[i].pt.x *= power; - kpts[i].pt.y *= power; + kpts[i].pt.x = (float)(kpts[i].pt.x*power + .5*(power-1)); + kpts[i].pt.y = (float)(kpts[i].pt.y*power + .5*(power-1)); kpts[i].angle = 0.0; // In OpenCV the size of a keypoint its the diameter