From 859ee6087c4a1c02635dc392623b69d98ed84d8c Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 15 Aug 2012 16:50:02 +0400 Subject: [PATCH] #2216 Forbid incorrect patchSize values in ORB --- modules/features2d/src/orb.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 19491f1..8aeea82 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -633,7 +633,7 @@ static void computeKeyPoints(const vector& imagePyramid, // pre-compute the end of a row in a circular patch int halfPatchSize = patchSize / 2; - vector umax(halfPatchSize + 1); + vector umax(halfPatchSize + 2); int v, v0, vmax = cvFloor(halfPatchSize * sqrt(2.f) / 2 + 1); int vmin = cvCeil(halfPatchSize * sqrt(2.f) / 2); @@ -643,7 +643,7 @@ static void computeKeyPoints(const vector& imagePyramid, // Make sure we are symmetric for (v = halfPatchSize, v0 = 0; v >= vmin; --v) { - while (umax[v0] == umax[v0 + 1]) + while (umax[v0] == umax[v0 + 1]) ++v0; umax[v] = v0; ++v0; @@ -723,6 +723,8 @@ static void computeDescriptors(const Mat& image, vector& keypoints, Ma void ORB::operator()( InputArray _image, InputArray _mask, vector& _keypoints, OutputArray _descriptors, bool useProvidedKeypoints) const { + CV_Assert(patchSize >= 2); + bool do_keypoints = !useProvidedKeypoints; bool do_descriptors = _descriptors.needed(); -- 2.7.4