Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
73c3d14a
Commit
73c3d14a
authored
Aug 03, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
akaze: fRound -> cvRound, fix bilinear interpolation
parent
f6ceeaa2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
78 deletions
+48
-78
AKAZEFeatures.cpp
modules/features2d/src/kaze/AKAZEFeatures.cpp
+26
-26
KAZEFeatures.cpp
modules/features2d/src/kaze/KAZEFeatures.cpp
+22
-22
utils.h
modules/features2d/src/kaze/utils.h
+0
-30
No files found.
modules/features2d/src/kaze/AKAZEFeatures.cpp
View file @
73c3d14a
...
...
@@ -74,12 +74,12 @@ void AKAZEFeatures::Allocate_Memory_Evolution(void) {
Evolution
step
;
step
.
size
=
Size
(
level_width
,
level_height
);
step
.
esigma
=
options_
.
soffset
*
pow
(
2.
f
,
(
float
)(
j
)
/
(
float
)(
options_
.
nsublevels
)
+
i
);
step
.
sigma_size
=
f
Round
(
step
.
esigma
*
options_
.
derivative_factor
/
power
);
// In fact sigma_size only depends on j
step
.
sigma_size
=
cv
Round
(
step
.
esigma
*
options_
.
derivative_factor
/
power
);
// In fact sigma_size only depends on j
step
.
etime
=
0.5
f
*
(
step
.
esigma
*
step
.
esigma
);
step
.
octave
=
i
;
step
.
sublevel
=
j
;
step
.
octave_ratio
=
(
float
)
power
;
step
.
border
=
f
Round
(
smax
*
step
.
sigma_size
)
+
1
;
step
.
border
=
cv
Round
(
smax
*
step
.
sigma_size
)
+
1
;
evolution_
.
push_back
(
step
);
}
...
...
@@ -1301,9 +1301,9 @@ void Compute_Main_Orientation(KeyPoint& kpt, const std::vector<Evolution>& evolu
// get the right evolution level for this keypoint
const
Evolution
&
e
=
evolution
[
kpt
.
class_id
];
// Get the information from the keypoint
int
scale
=
f
Round
(
0.5
f
*
kpt
.
size
/
e
.
octave_ratio
);
int
x0
=
f
Round
(
kpt
.
pt
.
x
/
e
.
octave_ratio
);
int
y0
=
f
Round
(
kpt
.
pt
.
y
/
e
.
octave_ratio
);
int
scale
=
cv
Round
(
0.5
f
*
kpt
.
size
/
e
.
octave_ratio
);
int
x0
=
cv
Round
(
kpt
.
pt
.
x
/
e
.
octave_ratio
);
int
y0
=
cv
Round
(
kpt
.
pt
.
y
/
e
.
octave_ratio
);
// Sample derivatives responses for the points within radius of 6*scale
const
int
ang_size
=
109
;
...
...
@@ -1443,7 +1443,7 @@ void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const
// Get the information from the keypoint
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
scale
=
f
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
scale
=
cv
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
const
int
level
=
kpt
.
class_id
;
Mat
Lx
=
evolution
[
level
].
Mx
;
Mat
Ly
=
evolution
[
level
].
My
;
...
...
@@ -1572,8 +1572,8 @@ void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, f
// Get the information from the keypoint
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
scale
=
f
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
angle
=
(
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
))
/
180.
f
;
scale
=
cv
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
angle
=
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
/
180.
f
)
;
const
int
level
=
kpt
.
class_id
;
Mat
Lx
=
evolution
[
level
].
Mx
;
Mat
Ly
=
evolution
[
level
].
My
;
...
...
@@ -1613,11 +1613,11 @@ void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, f
// Get the gaussian weighted x and y responses
gauss_s1
=
gaussian
(
xs
-
sample_x
,
ys
-
sample_y
,
2.5
f
*
scale
);
y1
=
f
Round
(
sample_y
-
0.5
f
);
x1
=
f
Round
(
sample_x
-
0.5
f
);
y1
=
cv
Round
(
sample_y
-
0.5
f
);
x1
=
cv
Round
(
sample_x
-
0.5
f
);
y2
=
f
Round
(
sample_y
+
0.5
f
);
x2
=
f
Round
(
sample_x
+
0.5
f
);
y2
=
cv
Round
(
sample_y
+
0.5
f
);
x2
=
cv
Round
(
sample_x
+
0.5
f
);
// fix crash: indexing with out-of-bounds index, this might happen near the edges of image
// clip values so they fit into the image
...
...
@@ -1706,7 +1706,7 @@ void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(cons
// Get the information from the keypoint
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
scale
=
f
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
scale
=
cv
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
const
int
level
=
kpt
.
class_id
;
Mat
Lx
=
evolution
[
level
].
Mx
;
Mat
Ly
=
evolution
[
level
].
My
;
...
...
@@ -1741,8 +1741,8 @@ void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(cons
sample_y
=
yf
+
l
*
scale
;
sample_x
=
xf
+
k
*
scale
;
y1
=
f
Round
(
sample_y
);
x1
=
f
Round
(
sample_x
);
y1
=
cv
Round
(
sample_y
);
x1
=
cv
Round
(
sample_x
);
ri
=
*
(
Lt
.
ptr
<
float
>
(
y1
)
+
x1
);
rx
=
*
(
Lx
.
ptr
<
float
>
(
y1
)
+
x1
);
...
...
@@ -1810,8 +1810,8 @@ void MLDB_Full_Descriptor_Invoker::MLDB_Fill_Values(float* values, int sample_st
float
sample_y
=
yf
+
(
l
*
co
*
scale
+
k
*
si
*
scale
);
float
sample_x
=
xf
+
(
-
l
*
si
*
scale
+
k
*
co
*
scale
);
int
y1
=
f
Round
(
sample_y
);
int
x1
=
f
Round
(
sample_x
);
int
y1
=
cv
Round
(
sample_y
);
int
x1
=
cv
Round
(
sample_x
);
// fix crash: indexing with out-of-bounds index, this might happen near the edges of image
// clip values so they fit into the image
...
...
@@ -1900,10 +1900,10 @@ void MLDB_Full_Descriptor_Invoker::Get_MLDB_Full_Descriptor(const KeyPoint& kpt,
};
float
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
float
scale
=
(
float
)
f
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
float
scale
=
(
float
)
cv
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
float
xf
=
kpt
.
pt
.
x
/
ratio
;
float
yf
=
kpt
.
pt
.
y
/
ratio
;
float
angle
=
(
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
))
/
180.
f
;
float
angle
=
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
/
180.
f
)
;
float
co
=
cos
(
angle
);
float
si
=
sin
(
angle
);
...
...
@@ -1941,8 +1941,8 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
// Get the information from the keypoint
float
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
int
scale
=
f
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
float
angle
=
(
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
))
/
180.
f
;
int
scale
=
cv
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
float
angle
=
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
/
180.
f
)
;
const
int
level
=
kpt
.
class_id
;
Mat
Lx
=
evolution
[
level
].
Mx
;
Mat
Ly
=
evolution
[
level
].
My
;
...
...
@@ -1983,8 +1983,8 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
sample_y
=
yf
+
(
l
*
scale
*
co
+
k
*
scale
*
si
);
sample_x
=
xf
+
(
-
l
*
scale
*
si
+
k
*
scale
*
co
);
y1
=
f
Round
(
sample_y
);
x1
=
f
Round
(
sample_x
);
y1
=
cv
Round
(
sample_y
);
x1
=
cv
Round
(
sample_x
);
di
+=
*
(
Lt
.
ptr
<
float
>
(
y1
)
+
x1
);
...
...
@@ -2049,7 +2049,7 @@ void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(
// Get the information from the keypoint
float
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
int
scale
=
f
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
int
scale
=
cv
Round
(
0.5
f
*
kpt
.
size
/
ratio
);
const
int
level
=
kpt
.
class_id
;
Mat
Lx
=
evolution
[
level
].
Mx
;
Mat
Ly
=
evolution
[
level
].
My
;
...
...
@@ -2081,8 +2081,8 @@ void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(
sample_y
=
yf
+
l
*
scale
;
sample_x
=
xf
+
k
*
scale
;
y1
=
f
Round
(
sample_y
);
x1
=
f
Round
(
sample_x
);
y1
=
cv
Round
(
sample_y
);
x1
=
cv
Round
(
sample_x
);
di
+=
*
(
Lt
.
ptr
<
float
>
(
y1
)
+
x1
);
if
(
options
.
descriptor_channels
>
1
)
{
...
...
modules/features2d/src/kaze/KAZEFeatures.cpp
View file @
73c3d14a
...
...
@@ -68,7 +68,7 @@ void KAZEFeatures::Allocate_Memory_Evolution(void) {
aux
.
Ldet
=
Mat
::
zeros
(
options_
.
img_height
,
options_
.
img_width
,
CV_32F
);
aux
.
esigma
=
options_
.
soffset
*
pow
((
float
)
2.0
f
,
(
float
)(
j
)
/
(
float
)(
options_
.
nsublevels
)
+
i
);
aux
.
etime
=
0.5
f
*
(
aux
.
esigma
*
aux
.
esigma
);
aux
.
sigma_size
=
f
Round
(
aux
.
esigma
);
aux
.
sigma_size
=
cv
Round
(
aux
.
esigma
);
aux
.
octave
=
i
;
aux
.
sublevel
=
j
;
evolution_
.
push_back
(
aux
);
...
...
@@ -363,10 +363,10 @@ 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
=
f
Round
(
kpts_par_
[
i
][
j
].
pt
.
x
-
smax
*
kpts_par_
[
i
][
j
].
size
);
right_x
=
f
Round
(
kpts_par_
[
i
][
j
].
pt
.
x
+
smax
*
kpts_par_
[
i
][
j
].
size
);
up_y
=
f
Round
(
kpts_par_
[
i
][
j
].
pt
.
y
-
smax
*
kpts_par_
[
i
][
j
].
size
);
down_y
=
f
Round
(
kpts_par_
[
i
][
j
].
pt
.
y
+
smax
*
kpts_par_
[
i
][
j
].
size
);
left_x
=
cv
Round
(
kpts_par_
[
i
][
j
].
pt
.
x
-
smax
*
kpts_par_
[
i
][
j
].
size
);
right_x
=
cv
Round
(
kpts_par_
[
i
][
j
].
pt
.
x
+
smax
*
kpts_par_
[
i
][
j
].
size
);
up_y
=
cv
Round
(
kpts_par_
[
i
][
j
].
pt
.
y
-
smax
*
kpts_par_
[
i
][
j
].
size
);
down_y
=
cv
Round
(
kpts_par_
[
i
][
j
].
pt
.
y
+
smax
*
kpts_par_
[
i
][
j
].
size
);
if
(
left_x
<
0
||
right_x
>=
evolution_
[
level
].
Ldet
.
cols
||
up_y
<
0
||
down_y
>=
evolution_
[
level
].
Ldet
.
rows
)
{
...
...
@@ -587,14 +587,14 @@ void KAZEFeatures::Compute_Main_Orientation(KeyPoint &kpt, const std::vector<TEv
xf
=
kpt
.
pt
.
x
;
yf
=
kpt
.
pt
.
y
;
level
=
kpt
.
class_id
;
s
=
f
Round
(
kpt
.
size
/
2.0
f
);
s
=
cv
Round
(
kpt
.
size
/
2.0
f
);
// Calculate derivatives responses for points within radius of 6*scale
for
(
int
i
=
-
6
;
i
<=
6
;
++
i
)
{
for
(
int
j
=
-
6
;
j
<=
6
;
++
j
)
{
if
(
i
*
i
+
j
*
j
<
36
)
{
iy
=
f
Round
(
yf
+
j
*
s
);
ix
=
f
Round
(
xf
+
i
*
s
);
iy
=
cv
Round
(
yf
+
j
*
s
);
ix
=
cv
Round
(
xf
+
i
*
s
);
if
(
iy
>=
0
&&
iy
<
options
.
img_height
&&
ix
>=
0
&&
ix
<
options
.
img_width
)
{
gweight
=
gaussian
(
iy
-
yf
,
ix
-
xf
,
2.5
f
*
s
);
...
...
@@ -676,7 +676,7 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Upright_Descriptor_64(const KeyPoint &kpt
// Get the information from the keypoint
yf
=
kpt
.
pt
.
y
;
xf
=
kpt
.
pt
.
x
;
scale
=
f
Round
(
kpt
.
size
/
2.0
f
);
scale
=
cv
Round
(
kpt
.
size
/
2.0
f
);
level
=
kpt
.
class_id
;
i
=
-
8
;
...
...
@@ -804,8 +804,8 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_64(const KeyPoint &kpt, float
// Get the information from the keypoint
yf
=
kpt
.
pt
.
y
;
xf
=
kpt
.
pt
.
x
;
scale
=
f
Round
(
kpt
.
size
/
2.0
f
);
angle
=
(
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
))
/
180.
f
;
scale
=
cv
Round
(
kpt
.
size
/
2.0
f
);
angle
=
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
/
180.
f
)
;
level
=
kpt
.
class_id
;
co
=
cos
(
angle
);
si
=
sin
(
angle
);
...
...
@@ -843,13 +843,13 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_64(const KeyPoint &kpt, float
// Get the gaussian weighted x and y responses
gauss_s1
=
gaussian
(
xs
-
sample_x
,
ys
-
sample_y
,
2.5
f
*
scale
);
y1
=
fRound
(
sample_y
-
0.5
f
);
x1
=
fRound
(
sample_x
-
0.5
f
);
y1
=
cvFloor
(
sample_y
);
x1
=
cvFloor
(
sample_x
);
checkDescriptorLimits
(
x1
,
y1
,
options_
.
img_width
,
options_
.
img_height
);
y2
=
(
int
)(
sample_y
+
0.5
f
)
;
x2
=
(
int
)(
sample_x
+
0.5
f
)
;
y2
=
y1
+
1
;
x2
=
x1
+
1
;
checkDescriptorLimits
(
x2
,
y2
,
options_
.
img_width
,
options_
.
img_height
);
...
...
@@ -935,7 +935,7 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Upright_Descriptor_128(const KeyPoint &kp
// Get the information from the keypoint
yf
=
kpt
.
pt
.
y
;
xf
=
kpt
.
pt
.
x
;
scale
=
f
Round
(
kpt
.
size
/
2.0
f
);
scale
=
cv
Round
(
kpt
.
size
/
2.0
f
);
level
=
kpt
.
class_id
;
i
=
-
8
;
...
...
@@ -1087,8 +1087,8 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_128(const KeyPoint &kpt, float
// Get the information from the keypoint
yf
=
kpt
.
pt
.
y
;
xf
=
kpt
.
pt
.
x
;
scale
=
f
Round
(
kpt
.
size
/
2.0
f
);
angle
=
(
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
))
/
180.
f
;
scale
=
cv
Round
(
kpt
.
size
/
2.0
f
);
angle
=
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
/
180.
f
)
;
level
=
kpt
.
class_id
;
co
=
cos
(
angle
);
si
=
sin
(
angle
);
...
...
@@ -1129,13 +1129,13 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_128(const KeyPoint &kpt, float
// Get the gaussian weighted x and y responses
gauss_s1
=
gaussian
(
xs
-
sample_x
,
ys
-
sample_y
,
2.5
f
*
scale
);
y1
=
fRound
(
sample_y
-
0.5
f
);
x1
=
fRound
(
sample_x
-
0.5
f
);
y1
=
cvFloor
(
sample_y
);
x1
=
cvFloor
(
sample_x
);
checkDescriptorLimits
(
x1
,
y1
,
options_
.
img_width
,
options_
.
img_height
);
y2
=
(
int
)(
sample_y
+
0.5
f
)
;
x2
=
(
int
)(
sample_x
+
0.5
f
)
;
y2
=
y1
+
1
;
x2
=
x1
+
1
;
checkDescriptorLimits
(
x2
,
y2
,
options_
.
img_width
,
options_
.
img_height
);
...
...
modules/features2d/src/kaze/utils.h
View file @
73c3d14a
...
...
@@ -39,34 +39,4 @@ inline void checkDescriptorLimits(int &x, int &y, int width, int height) {
}
}
/* ************************************************************************* */
/**
* @brief This funtion rounds float to nearest integer
* @param flt Input float
* @return dst Nearest integer
*/
inline
int
fRound
(
float
flt
)
{
return
(
int
)(
flt
+
0
.
5
f
);
}
/* ************************************************************************* */
/**
* @brief Exponentiation by squaring
* @param flt Exponentiation base
* @return dst Exponentiation value
*/
inline
int
fastpow
(
int
base
,
int
exp
)
{
int
res
=
1
;
while
(
exp
>
0
)
{
if
(
exp
&
1
)
{
exp
--
;
res
*=
base
;
}
else
{
exp
/=
2
;
base
*=
base
;
}
}
return
res
;
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment