From 909e484e747a3604e9c35c5cb13ceb1df472d3df Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Wed, 25 May 2011 00:33:50 +0000 Subject: [PATCH] - fix a possible crash when only asking for features and not descriptors --- modules/features2d/src/orb.cpp | 38 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 43a69b9d0e..6b2acac5e1 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -523,8 +523,6 @@ void ORB::operator()(const cv::Mat &image, const cv::Mat &mask, std::vectoroctave].push_back(*keypoint); } + keypoints_in_out.clear(); for (unsigned int level = 0; level < params_.n_levels_; ++level) { // Compute the resized image @@ -583,29 +582,22 @@ void ORB::operator()(const cv::Mat &image, const cv::Mat &mask, std::vector::iterator keypoint = keypoints.begin(), keypoint_end = keypoints.end(); keypoint - != keypoint_end; ++keypoint) - keypoint->pt *= scale; - } - // And add the keypoints to the output - keypoints_in_out.insert(keypoints_in_out.end(), keypoints.begin(), keypoints.end()); - } + float scale = std::pow(params_.scale_factor_, float(level - params_.first_level_)); + for (std::vector::iterator keypoint = keypoints.begin(), keypoint_end = keypoints.end(); keypoint + != keypoint_end; ++keypoint) + keypoint->pt *= scale; + } + // And add the keypoints to the output + keypoints_in_out.insert(keypoints_in_out.end(), keypoints.begin(), keypoints.end()); - if (do_descriptors) - { - if (descriptors.empty()) - desc.copyTo(descriptors); - else - descriptors.push_back(desc); - } + if (do_descriptors) + { + if (descriptors.empty()) + desc.copyTo(descriptors); + else + descriptors.push_back(desc); } } }