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
8aca8d90
Commit
8aca8d90
authored
7 years ago
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
akaze: replace ceil()
- integer division => divUp() - cast to 'int' => cvCeil()
parent
9ca39821
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
38 deletions
+50
-38
akaze.cpp
modules/features2d/src/akaze.cpp
+2
-2
AKAZEFeatures.cpp
modules/features2d/src/kaze/AKAZEFeatures.cpp
+46
-34
fed.cpp
modules/features2d/src/kaze/fed.cpp
+1
-1
nldiffusion_functions.cpp
modules/features2d/src/kaze/nldiffusion_functions.cpp
+1
-1
No files found.
modules/features2d/src/akaze.cpp
View file @
8aca8d90
...
...
@@ -113,12 +113,12 @@ namespace cv
if
(
descriptor_size
==
0
)
{
int
t
=
(
6
+
36
+
120
)
*
descriptor_channels
;
return
(
int
)
ceil
(
t
/
8.
);
return
divUp
(
t
,
8
);
}
else
{
// We use the random bit selection length binary descriptor
return
(
int
)
ceil
(
descriptor_size
/
8.
);
return
divUp
(
descriptor_size
,
8
);
}
default
:
...
...
This diff is collapsed.
Click to expand it.
modules/features2d/src/kaze/AKAZEFeatures.cpp
View file @
8aca8d90
...
...
@@ -106,7 +106,7 @@ void AKAZEFeatures::Allocate_Memory_Evolution(void) {
*/
static
inline
int
getGaussianKernelSize
(
float
sigma
)
{
// Compute an appropriate kernel size according to the specified sigma
int
ksize
=
(
int
)
ceil
(
2.0
f
*
(
1.0
f
+
(
sigma
-
0.8
f
)
/
(
0.3
f
)));
int
ksize
=
(
int
)
c
vC
eil
(
2.0
f
*
(
1.0
f
+
(
sigma
-
0.8
f
)
/
(
0.3
f
)));
ksize
|=
1
;
// kernel should be odd
return
ksize
;
}
...
...
@@ -1131,20 +1131,17 @@ void AKAZEFeatures::Compute_Descriptors(std::vector<KeyPoint>& kpts, OutputArray
}
// Allocate memory for the matrix with the descriptors
if
(
options_
.
descriptor
<
AKAZE
::
DESCRIPTOR_MLDB_UPRIGHT
)
{
descriptors
.
create
((
int
)
kpts
.
size
(),
64
,
CV_32FC1
);
}
else
{
// We use the full length binary descriptor -> 486 bits
if
(
options_
.
descriptor_size
==
0
)
{
int
t
=
(
6
+
36
+
120
)
*
options_
.
descriptor_channels
;
descriptors
.
create
((
int
)
kpts
.
size
(),
(
int
)
ceil
(
t
/
8.
),
CV_8UC1
);
}
else
{
// We use the random bit selection length binary descriptor
descriptors
.
create
((
int
)
kpts
.
size
(),
(
int
)
ceil
(
options_
.
descriptor_size
/
8.
),
CV_8UC1
);
}
int
descriptor_size
=
64
;
int
descriptor_type
=
CV_32FC1
;
if
(
options_
.
descriptor
>=
AKAZE
::
DESCRIPTOR_MLDB_UPRIGHT
)
{
int
descriptor_bits
=
(
options_
.
descriptor_size
==
0
)
?
(
6
+
36
+
120
)
*
options_
.
descriptor_channels
// the full length binary descriptor -> 486 bits
:
options_
.
descriptor_size
;
// the random bit selection length binary descriptor
descriptor_size
=
divUp
(
descriptor_bits
,
8
);
descriptor_type
=
CV_8UC1
;
}
descriptors
.
create
((
int
)
kpts
.
size
(),
descriptor_size
,
descriptor_type
);
Mat
desc
=
descriptors
.
getMat
();
...
...
@@ -1701,10 +1698,11 @@ void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(cons
// For 2x2 grid, 3x3 grid and 4x4 grid
const
int
pattern_size
=
options_
->
descriptor_pattern_size
;
int
sample_step
[
3
]
=
{
CV_Assert
((
pattern_size
&
1
)
==
0
);
const
int
sample_step
[
3
]
=
{
pattern_size
,
static_cast
<
int
>
(
ceil
(
pattern_size
*
2.
/
3.
)
),
pattern_size
/
2
divUp
(
pattern_size
*
2
,
3
),
divUp
(
pattern_size
,
2
)
};
// For the three grids
...
...
@@ -1873,8 +1871,16 @@ void MLDB_Full_Descriptor_Invoker::Get_MLDB_Full_Descriptor(const KeyPoint& kpt,
const
int
max_channels
=
3
;
CV_Assert
(
options_
->
descriptor_channels
<=
max_channels
);
const
int
pattern_size
=
options_
->
descriptor_pattern_size
;
float
values
[
16
*
max_channels
];
const
double
size_mult
[
3
]
=
{
1
,
2.0
/
3.0
,
1.0
/
2.0
};
CV_Assert
((
pattern_size
&
1
)
==
0
);
//const double size_mult[3] = {1, 2.0/3.0, 1.0/2.0};
const
int
sample_step
[
3
]
=
{
// static_cast<int>(ceil(pattern_size * size_mult[lvl]))
pattern_size
,
divUp
(
pattern_size
*
2
,
3
),
divUp
(
pattern_size
,
2
)
};
float
ratio
=
(
float
)(
1
<<
kpt
.
octave
);
float
scale
=
(
float
)
fRound
(
0.5
f
*
kpt
.
size
/
ratio
);
...
...
@@ -1883,14 +1889,12 @@ void MLDB_Full_Descriptor_Invoker::Get_MLDB_Full_Descriptor(const KeyPoint& kpt,
float
angle
=
(
kpt
.
angle
*
static_cast
<
float
>
(
CV_PI
))
/
180.
f
;
float
co
=
cos
(
angle
);
float
si
=
sin
(
angle
);
int
pattern_size
=
options_
->
descriptor_pattern_size
;
int
dpos
=
0
;
for
(
int
lvl
=
0
;
lvl
<
3
;
lvl
++
)
{
int
val_count
=
(
lvl
+
2
)
*
(
lvl
+
2
);
int
sample_step
=
static_cast
<
int
>
(
ceil
(
pattern_size
*
size_mult
[
lvl
]));
MLDB_Fill_Values
(
values
,
sample_step
,
kpt
.
class_id
,
xf
,
yf
,
co
,
si
,
scale
);
MLDB_Fill_Values
(
values
,
sample_step
[
lvl
],
kpt
.
class_id
,
xf
,
yf
,
co
,
si
,
scale
);
MLDB_Binary_Comparisons
(
values
,
desc
,
val_count
,
dpos
);
}
}
...
...
@@ -1930,14 +1934,18 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
Mat
values
((
4
+
9
+
16
)
*
options
.
descriptor_channels
,
1
,
CV_32FC1
);
// Sample everything, but only do the comparisons
vector
<
int
>
steps
(
3
);
steps
.
at
(
0
)
=
options
.
descriptor_pattern_size
;
steps
.
at
(
1
)
=
(
int
)
ceil
(
2.
f
*
options
.
descriptor_pattern_size
/
3.
f
);
steps
.
at
(
2
)
=
options
.
descriptor_pattern_size
/
2
;
const
int
pattern_size
=
options
.
descriptor_pattern_size
;
CV_Assert
((
pattern_size
&
1
)
==
0
);
const
int
sample_steps
[
3
]
=
{
pattern_size
,
divUp
(
pattern_size
*
2
,
3
),
divUp
(
pattern_size
,
2
)
};
for
(
int
i
=
0
;
i
<
descriptorSamples_
.
rows
;
i
++
)
{
const
int
*
coords
=
descriptorSamples_
.
ptr
<
int
>
(
i
);
int
sample_step
=
steps
.
at
(
coords
[
0
]);
CV_Assert
(
coords
[
0
]
>=
0
&&
coords
[
0
]
<
3
);
const
int
sample_step
=
sample_steps
[
coords
[
0
]];
di
=
0.0
f
;
dx
=
0.0
f
;
dy
=
0.0
f
;
...
...
@@ -2025,14 +2033,18 @@ void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(
// Allocate memory for the matrix of values
Mat
values
((
4
+
9
+
16
)
*
options
.
descriptor_channels
,
1
,
CV_32FC1
);
vector
<
int
>
steps
(
3
);
steps
.
at
(
0
)
=
options
.
descriptor_pattern_size
;
steps
.
at
(
1
)
=
static_cast
<
int
>
(
ceil
(
2.
f
*
options
.
descriptor_pattern_size
/
3.
f
));
steps
.
at
(
2
)
=
options
.
descriptor_pattern_size
/
2
;
const
int
pattern_size
=
options
.
descriptor_pattern_size
;
CV_Assert
((
pattern_size
&
1
)
==
0
);
const
int
sample_steps
[
3
]
=
{
pattern_size
,
divUp
(
pattern_size
*
2
,
3
),
divUp
(
pattern_size
,
2
)
};
for
(
int
i
=
0
;
i
<
descriptorSamples_
.
rows
;
i
++
)
{
const
int
*
coords
=
descriptorSamples_
.
ptr
<
int
>
(
i
);
int
sample_step
=
steps
.
at
(
coords
[
0
]);
CV_Assert
(
coords
[
0
]
>=
0
&&
coords
[
0
]
<
3
);
int
sample_step
=
sample_steps
[
coords
[
0
]];
di
=
0.0
f
,
dx
=
0.0
f
,
dy
=
0.0
f
;
for
(
int
k
=
coords
[
1
];
k
<
coords
[
1
]
+
sample_step
;
k
++
)
{
...
...
@@ -2120,7 +2132,7 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
for
(
int
i
=
0
,
c
=
0
;
i
<
3
;
i
++
)
{
int
gdiv
=
i
+
2
;
//grid divisions, per row
int
gsz
=
gdiv
*
gdiv
;
int
psz
=
(
int
)
ceil
(
2.
f
*
pattern_size
/
(
float
)
gdiv
);
int
psz
=
divUp
(
2
*
pattern_size
,
gdiv
);
for
(
int
j
=
0
;
j
<
gsz
;
j
++
)
{
for
(
int
k
=
j
+
1
;
k
<
gsz
;
k
++
,
c
++
)
{
...
...
@@ -2134,12 +2146,12 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
}
RNG
rng
(
1024
);
Mat_
<
int
>
comps
=
Mat_
<
int
>
(
nchannels
*
(
int
)
ceil
(
nbits
/
(
float
)
nchannels
),
2
);
const
int
npicks
=
divUp
(
nbits
,
nchannels
);
Mat_
<
int
>
comps
=
Mat_
<
int
>
(
nchannels
*
npicks
,
2
);
comps
=
1000
;
// Select some samples. A sample includes all channels
int
count
=
0
;
int
npicks
=
(
int
)
ceil
(
nbits
/
(
float
)
nchannels
);
Mat_
<
int
>
samples
(
29
,
3
);
Mat_
<
int
>
fullcopy
=
fullM
.
clone
();
samples
=
-
1
;
...
...
This diff is collapsed.
Click to expand it.
modules/features2d/src/kaze/fed.cpp
View file @
8aca8d90
...
...
@@ -72,7 +72,7 @@ int fed_tau_by_cycle_time(const float& t, const float& tau_max,
float
scale
=
0.0
;
// Ratio of t we search to maximal t
// Compute necessary number of time steps
n
=
(
int
)(
ceilf
(
sqrtf
(
3.0
f
*
t
/
tau_max
+
0.25
f
)
-
0.5
f
-
1.0e-8
f
)
+
0.5
f
);
n
=
cvCeil
(
sqrtf
(
3.0
f
*
t
/
tau_max
+
0.25
f
)
-
0.5
f
-
1.0e-8
f
);
scale
=
3.0
f
*
t
/
(
tau_max
*
(
float
)(
n
*
(
n
+
1
)));
// Call internal FED time step creation routine
...
...
This diff is collapsed.
Click to expand it.
modules/features2d/src/kaze/nldiffusion_functions.cpp
View file @
8aca8d90
...
...
@@ -49,7 +49,7 @@ void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int
// Compute an appropriate kernel size according to the specified sigma
if
(
sigma
>
ksize_x
||
sigma
>
ksize_y
||
ksize_x
==
0
||
ksize_y
==
0
)
{
ksize_x_
=
(
int
)
c
eil
(
2.0
f
*
(
1.0
f
+
(
sigma
-
0.8
f
)
/
(
0.3
f
)));
ksize_x_
=
cvC
eil
(
2.0
f
*
(
1.0
f
+
(
sigma
-
0.8
f
)
/
(
0.3
f
)));
ksize_y_
=
ksize_x_
;
}
...
...
This diff is collapsed.
Click to expand it.
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