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); } } }