From 916d07cf2c2b3a8d9d8387a87b62e6a953d8492d Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 25 Apr 2012 09:23:16 +0000 Subject: [PATCH] merged bug fix from r8179 (ORB_GPU) --- modules/gpu/src/orb.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/gpu/src/orb.cpp b/modules/gpu/src/orb.cpp index a69547a0ec..e3a0c92955 100644 --- a/modules/gpu/src/orb.cpp +++ b/modules/gpu/src/orb.cpp @@ -568,13 +568,19 @@ void cv::gpu::ORB_GPU::computeKeyPointsPyramid() { keyPointsCount_[level] = fastDetector_.calcKeyPointsLocation(imagePyr_[level], maskPyr_[level]); + if (keyPointsCount_[level] == 0) + continue; + ensureSizeIsEnough(3, keyPointsCount_[level], CV_32FC1, keyPointsPyr_[level]); GpuMat fastKpRange = keyPointsPyr_[level].rowRange(0, 2); keyPointsCount_[level] = fastDetector_.getKeyPoints(fastKpRange); - int n_features = n_features_per_level_[level]; - + if (keyPointsCount_[level] == 0) + continue; + + int n_features = static_cast(n_features_per_level_[level]); + if (scoreType_ == ORB::HARRIS_SCORE) { // Keep more points than necessary as FAST does not give amazing corners @@ -613,6 +619,9 @@ void cv::gpu::ORB_GPU::computeDescriptors(GpuMat& descriptors) for (int level = 0; level < nLevels_; ++level) { + if (keyPointsCount_[level] == 0) + continue; + GpuMat descRange = descriptors.rowRange(offset, offset + keyPointsCount_[level]); if (blurForDescriptor) @@ -650,6 +659,9 @@ void cv::gpu::ORB_GPU::mergeKeyPoints(GpuMat& keypoints) for (int level = 0; level < nLevels_; ++level) { + if (keyPointsCount_[level] == 0) + continue; + float sf = getScale(scaleFactor_, firstLevel_, level); GpuMat keyPointsRange = keypoints.colRange(offset, offset + keyPointsCount_[level]);