Forbid incorrect patchSize values in gpu::ORB
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Wed, 15 Aug 2012 13:23:04 +0000 (17:23 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Wed, 15 Aug 2012 13:24:53 +0000 (17:24 +0400)
modules/gpu/src/orb.cpp

index 2621398..20f5a7d 100644 (file)
@@ -401,6 +401,8 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg
     scoreType_(scoreType), patchSize_(patchSize),\r
     fastDetector_(DEFAULT_FAST_THRESHOLD)\r
 {\r
+    CV_Assert(patchSize_ >= 2);\r
+\r
     // fill the extractors and descriptors for the corresponding scales\r
     float factor = 1.0f / scaleFactor_;\r
     float n_desired_features_per_scale = nFeatures_ * (1.0f - factor) / (1.0f - std::pow(factor, nLevels_));\r
@@ -417,7 +419,7 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg
 \r
     // pre-compute the end of a row in a circular patch\r
     int half_patch_size = patchSize_ / 2;\r
-    vector<int> u_max(half_patch_size + 1);\r
+    vector<int> u_max(half_patch_size + 2);\r
     for (int v = 0; v <= half_patch_size * std::sqrt(2.f) / 2 + 1; ++v)\r
         u_max[v] = cvRound(std::sqrt(static_cast<float>(half_patch_size * half_patch_size - v * v)));\r
 \r