|
|
|
@ -311,7 +311,7 @@ private: |
|
|
|
|
void KAZEFeatures::Determinant_Hessian(std::vector<KeyPoint>& kpts) |
|
|
|
|
{ |
|
|
|
|
int level = 0; |
|
|
|
|
float dist = 0.0, smax = 3.0; |
|
|
|
|
float smax = 3.0; |
|
|
|
|
int npoints = 0, id_repeated = 0; |
|
|
|
|
int left_x = 0, right_x = 0, up_y = 0, down_y = 0; |
|
|
|
|
bool is_extremum = false, is_repeated = false, is_out = false; |
|
|
|
@ -338,17 +338,24 @@ void KAZEFeatures::Determinant_Hessian(std::vector<KeyPoint>& kpts) |
|
|
|
|
for (int j = 0; j < (int)kpts_par_[i].size(); j++) |
|
|
|
|
{ |
|
|
|
|
level = i + 1; |
|
|
|
|
const TEvolution& evolution_level = evolution_[level]; |
|
|
|
|
|
|
|
|
|
is_extremum = true; |
|
|
|
|
is_repeated = false; |
|
|
|
|
is_out = false; |
|
|
|
|
|
|
|
|
|
const KeyPoint& kpts_par_ij = kpts_par_[i][j]; |
|
|
|
|
|
|
|
|
|
// Check in case we have the same point as maxima in previous evolution levels
|
|
|
|
|
for (int ik = 0; ik < (int)kpts.size(); ik++) { |
|
|
|
|
if (kpts[ik].class_id == level || kpts[ik].class_id == level + 1 || kpts[ik].class_id == level - 1) { |
|
|
|
|
dist = pow(kpts_par_[i][j].pt.x - kpts[ik].pt.x, 2) + pow(kpts_par_[i][j].pt.y - kpts[ik].pt.y, 2); |
|
|
|
|
for (int ik = 0; ik < (int)kpts.size(); ik++) |
|
|
|
|
{ |
|
|
|
|
const KeyPoint& kpts_ik = kpts[ik]; |
|
|
|
|
if (kpts_ik.class_id == level || kpts_ik.class_id == level + 1 || kpts_ik.class_id == level - 1) { |
|
|
|
|
Point2f diff = kpts_par_ij.pt - kpts_ik.pt; |
|
|
|
|
float dist = diff.dot(diff); |
|
|
|
|
|
|
|
|
|
if (dist < evolution_[level].sigma_size*evolution_[level].sigma_size) { |
|
|
|
|
if (kpts_par_[i][j].response > kpts[ik].response) { |
|
|
|
|
if (dist < evolution_level.sigma_size*evolution_level.sigma_size) { |
|
|
|
|
if (kpts_par_ij.response > kpts_ik.response) { |
|
|
|
|
id_repeated = ik; |
|
|
|
|
is_repeated = true; |
|
|
|
|
} |
|
|
|
@ -363,23 +370,23 @@ void KAZEFeatures::Determinant_Hessian(std::vector<KeyPoint>& kpts) |
|
|
|
|
|
|
|
|
|
if (is_extremum == true) { |
|
|
|
|
// Check that the point is under the image limits for the descriptor computation
|
|
|
|
|
left_x = cvRound(kpts_par_[i][j].pt.x - smax*kpts_par_[i][j].size); |
|
|
|
|
right_x = cvRound(kpts_par_[i][j].pt.x + smax*kpts_par_[i][j].size); |
|
|
|
|
up_y = cvRound(kpts_par_[i][j].pt.y - smax*kpts_par_[i][j].size); |
|
|
|
|
down_y = cvRound(kpts_par_[i][j].pt.y + smax*kpts_par_[i][j].size); |
|
|
|
|
left_x = cvRound(kpts_par_ij.pt.x - smax*kpts_par_ij.size); |
|
|
|
|
right_x = cvRound(kpts_par_ij.pt.x + smax*kpts_par_ij.size); |
|
|
|
|
up_y = cvRound(kpts_par_ij.pt.y - smax*kpts_par_ij.size); |
|
|
|
|
down_y = cvRound(kpts_par_ij.pt.y + smax*kpts_par_ij.size); |
|
|
|
|
|
|
|
|
|
if (left_x < 0 || right_x >= evolution_[level].Ldet.cols || |
|
|
|
|
up_y < 0 || down_y >= evolution_[level].Ldet.rows) { |
|
|
|
|
if (left_x < 0 || right_x >= evolution_level.Ldet.cols || |
|
|
|
|
up_y < 0 || down_y >= evolution_level.Ldet.rows) { |
|
|
|
|
is_out = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (is_out == false) { |
|
|
|
|
if (is_repeated == false) { |
|
|
|
|
kpts.push_back(kpts_par_[i][j]); |
|
|
|
|
kpts.push_back(kpts_par_ij); |
|
|
|
|
npoints++; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
kpts[id_repeated] = kpts_par_[i][j]; |
|
|
|
|
kpts[id_repeated] = kpts_par_ij; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|