From 19462c871dc0b30d6c6b3f8b1b76d17ebcf88d66 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 15 Aug 2012 17:23:04 +0400 Subject: [PATCH] Forbid incorrect patchSize values in gpu::ORB --- modules/gpu/src/orb.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/gpu/src/orb.cpp b/modules/gpu/src/orb.cpp index 262139887..20f5a7d13 100644 --- a/modules/gpu/src/orb.cpp +++ b/modules/gpu/src/orb.cpp @@ -401,6 +401,8 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg scoreType_(scoreType), patchSize_(patchSize), fastDetector_(DEFAULT_FAST_THRESHOLD) { + CV_Assert(patchSize_ >= 2); + // fill the extractors and descriptors for the corresponding scales float factor = 1.0f / scaleFactor_; float n_desired_features_per_scale = nFeatures_ * (1.0f - factor) / (1.0f - std::pow(factor, nLevels_)); @@ -417,7 +419,7 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg // pre-compute the end of a row in a circular patch int half_patch_size = patchSize_ / 2; - vector u_max(half_patch_size + 1); + vector u_max(half_patch_size + 2); for (int v = 0; v <= half_patch_size * std::sqrt(2.f) / 2 + 1; ++v) u_max[v] = cvRound(std::sqrt(static_cast(half_patch_size * half_patch_size - v * v)));