Commit 19462c87 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

Forbid incorrect patchSize values in gpu::ORB

parent 528ddb56
...@@ -401,6 +401,8 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg ...@@ -401,6 +401,8 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg
scoreType_(scoreType), patchSize_(patchSize), scoreType_(scoreType), patchSize_(patchSize),
fastDetector_(DEFAULT_FAST_THRESHOLD) fastDetector_(DEFAULT_FAST_THRESHOLD)
{ {
CV_Assert(patchSize_ >= 2);
// fill the extractors and descriptors for the corresponding scales // fill the extractors and descriptors for the corresponding scales
float factor = 1.0f / scaleFactor_; float factor = 1.0f / scaleFactor_;
float n_desired_features_per_scale = nFeatures_ * (1.0f - factor) / (1.0f - std::pow(factor, nLevels_)); 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 ...@@ -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 // pre-compute the end of a row in a circular patch
int half_patch_size = patchSize_ / 2; int half_patch_size = patchSize_ / 2;
vector<int> u_max(half_patch_size + 1); vector<int> u_max(half_patch_size + 2);
for (int v = 0; v <= half_patch_size * std::sqrt(2.f) / 2 + 1; ++v) for (int v = 0; v <= half_patch_size * std::sqrt(2.f) / 2 + 1; ++v)
u_max[v] = cvRound(std::sqrt(static_cast<float>(half_patch_size * half_patch_size - v * v))); u_max[v] = cvRound(std::sqrt(static_cast<float>(half_patch_size * half_patch_size - v * v)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment