-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c973991
commit ad69913
Showing
2 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ | |
* Constact: [email protected] | ||
* Software developed in the PhD: Low-level vision for resource-limited devices | ||
*/ | ||
#ifndef EFFICIENT_DESCRIPTORS_BAD_H_ | ||
#define EFFICIENT_DESCRIPTORS_BAD_H_ | ||
#ifndef INTEREST_POINT_BAD_H_ | ||
#define INTEREST_POINT_BAD_H_ | ||
|
||
#include <vector> | ||
#include <opencv2/opencv.hpp> | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
namespace upm { | ||
|
||
/** | ||
|
@@ -94,4 +96,4 @@ class BAD : public cv::Feature2D { | |
}; | ||
|
||
} // namespace upm | ||
#endif // EFFICIENT_DESCRIPTORS_BAD_H_ | ||
#endif // INTEREST_POINT_BAD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,12 @@ | |
* Constact: [email protected] | ||
* Software developed in the PhD: Low-level vision for resource-limited devices | ||
*/ | ||
#include <cassert> | ||
#include <interest_point/BAD.h> | ||
#include <cassert> | ||
#include <vector> | ||
|
||
#define UPM_DEGREES_TO_RADS 0.017453292519943295 | ||
#define UPM_ROUNDNUM(x) ((int)(x + 0.5f)) | ||
#define UPM_ROUNDNUM(x) (static_cast<int>(x + 0.5f)) | ||
#define UPM_BAD_EXTRA_RATIO_MARGIN 1.75 | ||
|
||
namespace upm { | ||
|
@@ -40,8 +41,8 @@ static inline void rectifyBoxes(const std::vector<BAD::BoxPairParams> &boxes_par | |
m11 = s; | ||
m12 = -s * 0.5f * patch_size.height + kp.pt.y; | ||
} else { | ||
cosine = (kp.angle >= 0) ? float(cos(kp.angle * UPM_DEGREES_TO_RADS)) : 1.f; | ||
sine = (kp.angle >= 0) ? float(sin(kp.angle * UPM_DEGREES_TO_RADS)) : 0.f; | ||
cosine = (kp.angle >= 0) ? static_cast<float>(cos(kp.angle * UPM_DEGREES_TO_RADS)) : 1.f; | ||
sine = (kp.angle >= 0) ? static_cast<float>(sin(kp.angle * UPM_DEGREES_TO_RADS)) : 0.f; | ||
|
||
m00 = s * cosine; | ||
m01 = -s * sine; | ||
|
@@ -133,7 +134,7 @@ static inline float computeBadResponse(const BAD::BoxPairParams &box_params, | |
D = integral_img.at<int>(box1y2, box1x2); | ||
|
||
// Calculate the mean intensity value of the pixels in the box | ||
sum1 = float(A + D - B - C); | ||
sum1 = static_cast<float>(A + D - B - C); | ||
box_area1 = (box1y2 - box1y1) * (box1x2 - box1x1); | ||
assert(box_area1 > 0); | ||
average1 = sum1 / box_area1; | ||
|
@@ -145,7 +146,7 @@ static inline float computeBadResponse(const BAD::BoxPairParams &box_params, | |
D = integral_img.at<int>(box2y2, box2x2); | ||
|
||
// Calculate the mean intensity value of the pixels in the box | ||
sum2 = float(A + D - B - C); | ||
sum2 = static_cast<float>(A + D - B - C); | ||
box_area2 = (box2y2 - box2y1) * (box2x2 - box2x1); | ||
assert(box_area2 > 0); | ||
average2 = sum2 / box_area2; | ||
|
@@ -262,7 +263,33 @@ BAD::BAD(float scale_factor, BadSize n_bits) { | |
// {15,15,15,11,1}, {17,16,14,13,1}, {12,18,12,17,1}, {30,3,30,2,1}, {21,20,18,28,3}, {25,25,7,14,5}, {3,11,2,3,2}, | ||
// {25,5,9,21,4}, {6,15,4,28,3}, {9,9,3,3,3}, {16,19,14,16,2}, {10,25,10,20,1}, {2,17,2,15,1}, {17,15,15,16,1}, | ||
// {20,15,19,15,1}, {22,2,22,1,1}, {15,19,15,18,1}, {15,16,10,12,1}, {28,2,23,14,2}, {11,3,9,2,1}}; thresholds_ = | ||
// {14.45,4.15,7.75,9.65,2.25,0.15,0.45,-0.95,3.65,-1.75,1.05,5.45,-0.05,-2.65,3.35,1.65,-1.55,2.85,3.05,22.05,-3.65,-0.15,-0.55,-0.05,3.25,-2.85,-1.25,10.45,-1.05,1.25,3.15,2.05,-0.55,-1.25,3.45,4.35,2.45,2.55,1.35,1.25,2.75,-0.15,8.35,0.35,-1.25,0.75,-0.45,-0.05,0.85,3.65,1.55,1.75,-0.35,1.35,4.85,-2.25,0.25,-2.15,3.35,1.95,6.25,0.35,24.45,-1.15,0.85,-1.95,5.15,1.35,0.85,0.35,-0.45,4.95,-0.25,2.45,11.75,0.85,-1.65,0.05,4.05,-0.35,-0.95,-0.25,49.35,0.85,1.95,0.25,1.15,-2.65,-0.25,0.85,-5.65,1.15,3.05,4.05,7.35,9.05,0.35,1.65,1.65,2.55,6.95,1.75,0.85,-1.15,1.35,5.45,1.35,-2.35,-0.15,0.85,-3.05,0.05,-0.35,-0.65,11.65,-0.85,1.15,2.35,-9.25,16.05,-1.45,1.95,0.35,-0.35,0.15,0.25,-1.35,0.65,-4.05,-2.25,1.05,-0.05,-1.55,0.25,69.45,0.15,-1.25,-1.85,-0.65,8.75,-0.95,1.95,1.05,-1.45,2.15,-1.85,-1.75,-2.95,2.65,0.65,-1.05,4.35,0.25,19.65,0.35,1.65,0.65,2.75,2.85,-10.95,3.65,-4.15,0.25,-0.65,-2.25,3.75,35.75,3.15,-0.55,1.95,-6.55,88.35,7.25,1.75,-4.15,0.25,0.25,0.65,3.75,1.65,2.85,42.15,11.75,-1.25,-8.25,0.05,2.15,0.65,-1.55,-2.75,1.15,-0.15,-0.75,16.85,1.15,1.45,15.35,19.45,8.65,-1.25,0.25,2.15,0.15,2.85,-2.25,1.75,-15.15,4.15,-0.45,-8.25,1.25,-0.85,3.55,0.45,-1.25,9.65,1.25,3.15,-2.05,-6.85,-0.05,3.25,7.05,2.35,-1.45,-1.05,20.25,1.15,1.35,1.05,5.15,2.55,0.55,0.55,-0.15,0.65,-28.35,3.85,2.05,-1.15,3.05,-0.95,-1.55,-0.35,101.95,0.35,-2.05,-2.15,4.25,105.15,1.15,27.45,30.15,18.45,-2.45,1.85,2.95,-3.75,-0.65,0.05,0.25,34.45,-2.05,0.25,3.25,2.05,2.85,3.45,20.95,1.45,-1.95,-0.35,-6.85,1.15,-31.95,11.85,2.75,0.15,8.35,1.15,2.15,-1.15,-1.05,2.45,1.45,0.15,-1.65,41.85,0.35,0.65,-0.35,0.25,56.75,23.55,88.85,-7.25,1.05,0.75,-1.05,-1.65,-9.75,-16.95,-0.05,-10.05,34.15,14.75,-0.95,1.45,4.85,-0.05,-0.35,0.75,64.75,24.25,-0.35,-13.65,2.85,1.75,-0.35,0.25,-12.15,108.05,-0.35,-3.35,1.95,-0.35,21.25,-20.05,95.85,-1.05,-17.75,-0.55,2.75,0.65,0.75,-1.85,2.65,-2.15,1.05,-0.05,4.25,3.75,-13.55,-0.05,105.95,0.45,3.05,9.35,79.25,1.75,7.65,-0.45,0.95,79.15,28.05,0.05,0.65,-0.35,0.95,2.05,1.15,2.75,-1.65,8.65,3.55,-0.25,-28.95,-7.35,122.25,0.55,4.75,1.75,11.15,0.15,2.55,0.05,-7.95,51.05,6.25,0.05,-1.15,0.75,26.65,-1.25,1.15,-0.55,0.05,5.85,1.55,2.25,-1.65,-16.85,-62.65,-1.25,-1.05,-1.55,1.35,0.25,-0.65,0.85,17.45,0.25,-9.35,34.35,0.95,-0.95,-10.05,1.45,-6.05,93.25,3.15,-10.85,-1.65,-0.15,-2.45,-0.35,0.15,118.15,-81.85,4.05,1.05,-0.85,152.35,0.65,1.35,-12.35,95.35,-23.25,-0.75,75.65,50.85,47.85,2.55,0.55,0.15,0.25,38.15,-2.65,-1.95,-1.05,110.25,35.25,2.65,3.65,18.75,89.45,-0.55,0.35,0.25,105.05,0.25,1.25,-34.65,-0.55,-0.15,0.75,-0.15,-0.15,-94.25,-12.05,-15.35,-1.75,31.35,0.15,-2.15,-0.15,-12.05,-0.35,-0.65,-0.55,28.95,39.05,7.05,0.65,-1.65,2.85,4.85,-1.85,1.75,-31.65,0.05,13.75,-0.35,0.35,-5.75,83.85,0.95,27.95,-0.25,-19.05,2.45,-13.25,44.05,51.85,-0.05,0.05,79.35,111.25,-61.65,3.05,-69.95,35.65,62.05,-0.25,-1.05,-2.95,0.95,-0.15,-18.15,-18.65,74.55,2.65}; | ||
// {14.45,4.15,7.75,9.65,2.25,0.15,0.45,-0.95,3.65,-1.75,1.05,5.45,-0.05,-2.65,3.35,1.65,-1.55,2.85,3.05,22.05, | ||
// -3.65,-0.15,-0.55,-0.05,3.25,-2.85,-1.25,10.45,-1.05,1.25,3.15,2.05,-0.55,-1.25,3.45,4.35,2.45,2.55,1.35,1.25, | ||
// 2.75,-0.15,8.35,0.35,-1.25,0.75,-0.45,-0.05,0.85,3.65,1.55,1.75,-0.35,1.35,4.85,-2.25,0.25,-2.15,3.35,1.95,6.25, | ||
// 0.35,24.45,-1.15,0.85,-1.95,5.15,1.35,0.85,0.35,-0.45,4.95,-0.25,2.45,11.75,0.85,-1.65,0.05,4.05,-0.35,-0.95, | ||
// -0.25,49.35,0.85,1.95,0.25,1.15,-2.65,-0.25,0.85,-5.65,1.15,3.05,4.05,7.35,9.05,0.35,1.65,1.65,2.55,6.95,1.75, | ||
// 0.85,-1.15,1.35,5.45,1.35,-2.35,-0.15,0.85,-3.05,0.05,-0.35,-0.65,11.65,-0.85,1.15,2.35,-9.25,16.05,-1.45,1.95, | ||
// 0.35,-0.35,0.15,0.25,-1.35,0.65,-4.05,-2.25,1.05,-0.05,-1.55,0.25,69.45,0.15,-1.25,-1.85,-0.65,8.75,-0.95,1.95, | ||
// 1.05,-1.45,2.15,-1.85,-1.75,-2.95,2.65,0.65,-1.05,4.35,0.25,19.65,0.35,1.65,0.65,2.75,2.85,-10.95,3.65,-4.15, | ||
// 0.25,-0.65,-2.25,3.75,35.75,3.15,-0.55,1.95,-6.55,88.35,7.25,1.75,-4.15,0.25,0.25,0.65,3.75,1.65,2.85,42.15, | ||
// 11.75, -1.25,-8.25,0.05,2.15,0.65,-1.55,-2.75,1.15,-0.15,-0.75,16.85,1.15,1.45,15.35,19.45,8.65,-1.25,0.25, | ||
// 2.15,0.15,2.85, -2.25,1.75,-15.15,4.15,-0.45,-8.25,1.25,-0.85,3.55,0.45,-1.25,9.65,1.25,3.15,-2.05,-6.85,-0.05, | ||
// 3.25,7.05,2.35, -1.45,-1.05,20.25,1.15,1.35,1.05,5.15,2.55,0.55,0.55,-0.15,0.65,-28.35,3.85,2.05,-1.15,3.05, | ||
// -0.95,-1.55,-0.35, 101.95,0.35,-2.05,-2.15,4.25,105.15,1.15,27.45,30.15,18.45,-2.45,1.85,2.95,-3.75,-0.65,0.05, | ||
// 0.25,34.45,-2.05, 0.25,3.25,2.05,2.85,3.45,20.95,1.45,-1.95,-0.35,-6.85,1.15,-31.95,11.85,2.75,0.15,8.35,1.15, | ||
// 2.15,-1.15,-1.05, 2.45,1.45,0.15,-1.65,41.85,0.35,0.65,-0.35,0.25,56.75,23.55,88.85,-7.25,1.05,0.75,-1.05,-1.65, | ||
// -9.75,-16.95,-0.05, -10.05,34.15,14.75,-0.95,1.45,4.85,-0.05,-0.35,0.75,64.75,24.25,-0.35,-13.65,2.85,1.75, | ||
// -0.35,0.25,-12.15,108.05, -0.35,-3.35,1.95,-0.35,21.25,-20.05,95.85,-1.05,-17.75,-0.55,2.75,0.65,0.75,-1.85, | ||
// 2.65,-2.15,1.05,-0.05,4.25,3.75, -13.55,-0.05,105.95,0.45,3.05,9.35,79.25,1.75,7.65,-0.45,0.95,79.15,28.05,0.05, | ||
// 0.65,-0.35,0.95,2.05,1.15,2.75, -1.65,8.65,3.55,-0.25,-28.95,-7.35,122.25,0.55,4.75,1.75,11.15,0.15,2.55,0.05, | ||
// -7.95,51.05,6.25,0.05,-1.15,0.75, 26.65,-1.25,1.15,-0.55,0.05,5.85,1.55,2.25,-1.65,-16.85,-62.65,-1.25,-1.05, | ||
// -1.55,1.35,0.25,-0.65,0.85,17.45, 0.25, -9.35,34.35,0.95,-0.95,-10.05,1.45,-6.05,93.25,3.15,-10.85,-1.65,-0.15, | ||
// -2.45,-0.35,0.15,118.15,-81.85,4.05,1.05, -0.85,152.35,0.65,1.35,-12.35,95.35,-23.25,-0.75,75.65,50.85,47.85, | ||
// 2.55,0.55,0.15,0.25,38.15,-2.65,-1.95,-1.05, 110.25,35.25,2.65,3.65,18.75,89.45,-0.55,0.35,0.25,105.05,0.25, | ||
// 1.25,-34.65,-0.55,-0.15,0.75,-0.15,-0.15,-94.25, -12.05,-15.35,-1.75,31.35,0.15,-2.15,-0.15,-12.05,-0.35,-0.65, | ||
// -0.55,28.95,39.05,7.05,0.65,-1.65,2.85,4.85,-1.85, 1.75,-31.65,0.05,13.75,-0.35,0.35,-5.75,83.85,0.95,27.95, | ||
// -0.25,-19.05,2.45,-13.25,44.05,51.85,-0.05,0.05,79.35,111.25,-61.65,3.05,-69.95,35.65,62.05,-0.25,-1.05,-2.95, | ||
// 0.95,-0.15,-18.15,-18.65,74.55,2.65}; | ||
|
||
// Without data augmentation | ||
box_params_ = { | ||
|
@@ -510,7 +537,7 @@ void BAD::compute(cv::InputArray _image, | |
cv::integral(image, integral_img); | ||
|
||
// Create the output array of descriptors | ||
_descriptors.create((int)keypoints.size(), descriptorSize(), descriptorType()); | ||
_descriptors.create(static_cast<int>(keypoints.size()), descriptorSize(), descriptorType()); | ||
|
||
// descriptor storage | ||
cv::Mat descriptors = _descriptors.getMat(); | ||
|
@@ -533,7 +560,7 @@ void BAD::computeBAD(const cv::Mat &integral_img, | |
#ifndef UPM_BAD_PARALLEL | ||
const cv::Range range(0, keypoints.size()); | ||
#else | ||
cv::parallel_for_(cv::Range(0, int(keypoints.size())), [&](const cv::Range &range){ | ||
cv::parallel_for_(cv::Range(0, static_cast<int>(keypoints.size())), [&](const cv::Range &range){ // NOLINT | ||
#endif | ||
// Get a pointer to the first element in the range | ||
// Get a pointer to the first element in the range | ||
|
@@ -553,7 +580,7 @@ void BAD::computeBAD(const cv::Mat &integral_img, | |
if (isKeypointInTheBorder(keypoints[kpIdx], frame_size, patch_size_, scale_factor_)) { | ||
// Code to process the keypoints in the image margins | ||
for (box_pair_idx = 0; box_pair_idx < box_params_.size(); box_pair_idx++) { | ||
bit_idx = 7 - int(box_pair_idx % 8); | ||
bit_idx = 7 - static_cast<int>(box_pair_idx % 8); | ||
response_fun = computeBadResponse(img_boxes[box_pair_idx], integral_img); | ||
// Set the bit to 1 if the response function is less or equal to the threshod | ||
byte |= (response_fun <= thresholds_[box_pair_idx]) << bit_idx; | ||
|
@@ -568,7 +595,7 @@ void BAD::computeBAD(const cv::Mat &integral_img, | |
// Code to process the keypoints in the image center | ||
box_pair = img_boxes.data(); | ||
for (box_pair_idx = 0; box_pair_idx < box_params_.size(); box_pair_idx++) { | ||
bit_idx = 7 - int(box_pair_idx % 8); | ||
bit_idx = 7 - static_cast<int>(box_pair_idx % 8); | ||
|
||
// For the first box, we calculate its margin coordinates | ||
box1x1 = box_pair->x1 - box_pair->boxRadius; | ||
|
@@ -607,5 +634,5 @@ void BAD::computeBAD(const cv::Mat &integral_img, | |
#ifdef UPM_BAD_PARALLEL | ||
}); | ||
#endif | ||
} // namespace upm | ||
} // namespace upm ## NOLINT | ||
} |