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
1796a26f
Commit
1796a26f
authored
Oct 13, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
yet another attempt to refactor features2d; the first commit, features2d does not even compile
parent
83ef2766
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
258 additions
and
325 deletions
+258
-325
features2d.hpp
modules/features2d/include/opencv2/features2d.hpp
+0
-0
blobdetector.cpp
modules/features2d/src/blobdetector.cpp
+26
-1
brisk.cpp
modules/features2d/src/brisk.cpp
+73
-0
descriptors.cpp
modules/features2d/src/descriptors.cpp
+0
-110
detectors.cpp
modules/features2d/src/detectors.cpp
+24
-77
fast.cpp
modules/features2d/src/fast.cpp
+19
-10
features2d_init.cpp
modules/features2d/src/features2d_init.cpp
+4
-0
kaze.cpp
modules/features2d/src/kaze.cpp
+20
-80
AKAZEConfig.h
modules/features2d/src/kaze/AKAZEConfig.h
+4
-17
AKAZEFeatures.cpp
modules/features2d/src/kaze/AKAZEFeatures.cpp
+28
-11
KAZEConfig.h
modules/features2d/src/kaze/KAZEConfig.h
+5
-1
KAZEFeatures.h
modules/features2d/src/kaze/KAZEFeatures.h
+5
-0
orb.cpp
modules/features2d/src/orb.cpp
+50
-18
No files found.
modules/features2d/include/opencv2/features2d.hpp
View file @
1796a26f
This diff is collapsed.
Click to expand it.
modules/features2d/src/blobdetector.cpp
View file @
1796a26f
...
...
@@ -55,7 +55,32 @@
# endif
#endif
using
namespace
cv
;
namespace
cv
{
class
CV_EXPORTS_W
SimpleBlobDetectorImpl
:
public
SimpleBlobDetector
{
public
:
explicit
SimpleBlobDetectorImpl
(
const
SimpleBlobDetector
::
Params
&
parameters
=
SimpleBlobDetector
::
Params
());
virtual
void
read
(
const
FileNode
&
fn
);
virtual
void
write
(
FileStorage
&
fs
)
const
;
protected
:
struct
CV_EXPORTS
Center
{
Point2d
location
;
double
radius
;
double
confidence
;
};
virtual
void
detectImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
=
noArray
()
)
const
;
virtual
void
findBlobs
(
InputArray
image
,
InputArray
binaryImage
,
std
::
vector
<
Center
>
&
centers
)
const
;
Params
params
;
AlgorithmInfo
*
info
()
const
;
};
/*
* SimpleBlobDetector
...
...
modules/features2d/src/brisk.cpp
View file @
1796a26f
...
...
@@ -53,6 +53,79 @@
namespace
cv
{
class
BRISK_Impl
:
public
BRISK
{
public
:
explicit
BRISK_Impl
(
int
thresh
=
30
,
int
octaves
=
3
,
float
patternScale
=
1.0
f
);
// custom setup
explicit
BRISK_Impl
(
const
std
::
vector
<
float
>
&
radiusList
,
const
std
::
vector
<
int
>
&
numberList
,
float
dMax
=
5.85
f
,
float
dMin
=
8.2
f
,
const
std
::
vector
<
int
>
indexChange
=
std
::
vector
<
int
>
());
// call this to generate the kernel:
// circle of radius r (pixels), with n points;
// short pairings with dMax, long pairings with dMin
void
generateKernel
(
std
::
vector
<
float
>
&
radiusList
,
std
::
vector
<
int
>
&
numberList
,
float
dMax
=
5.85
f
,
float
dMin
=
8.2
f
,
std
::
vector
<
int
>
indexChange
=
std
::
vector
<
int
>
());
protected
:
void
computeImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
;
void
detectImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
=
noArray
()
)
const
;
void
computeKeypointsNoOrientation
(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
)
const
;
void
computeDescriptorsAndOrOrientation
(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
,
bool
doDescriptors
,
bool
doOrientation
,
bool
useProvidedKeypoints
)
const
;
// Feature parameters
CV_PROP_RW
int
threshold
;
CV_PROP_RW
int
octaves
;
// some helper structures for the Brisk pattern representation
struct
BriskPatternPoint
{
float
x
;
// x coordinate relative to center
float
y
;
// x coordinate relative to center
float
sigma
;
// Gaussian smoothing sigma
};
struct
BriskShortPair
{
unsigned
int
i
;
// index of the first pattern point
unsigned
int
j
;
// index of other pattern point
};
struct
BriskLongPair
{
unsigned
int
i
;
// index of the first pattern point
unsigned
int
j
;
// index of other pattern point
int
weighted_dx
;
// 1024.0/dx
int
weighted_dy
;
// 1024.0/dy
};
inline
int
smoothedIntensity
(
const
cv
::
Mat
&
image
,
const
cv
::
Mat
&
integral
,
const
float
key_x
,
const
float
key_y
,
const
unsigned
int
scale
,
const
unsigned
int
rot
,
const
unsigned
int
point
)
const
;
// pattern properties
BriskPatternPoint
*
patternPoints_
;
//[i][rotation][scale]
unsigned
int
points_
;
// total number of collocation points
float
*
scaleList_
;
// lists the scaling per scale index [scale]
unsigned
int
*
sizeList_
;
// lists the total pattern size per scale index [scale]
static
const
unsigned
int
scales_
;
// scales discretization
static
const
float
scalerange_
;
// span of sizes 40->4 Octaves - else, this needs to be adjusted...
static
const
unsigned
int
n_rot_
;
// discretization of the rotation look-up
// pairs
int
strings_
;
// number of uchars the descriptor consists of
float
dMax_
;
// short pair maximum distance
float
dMin_
;
// long pair maximum distance
BriskShortPair
*
shortPairs_
;
// d<_dMax
BriskLongPair
*
longPairs_
;
// d>_dMin
unsigned
int
noShortPairs_
;
// number of shortParis
unsigned
int
noLongPairs_
;
// number of longParis
// general
static
const
float
basicSize_
;
};
// a layer in the Brisk detector pyramid
class
CV_EXPORTS
BriskLayer
{
...
...
modules/features2d/src/descriptors.cpp
deleted
100644 → 0
View file @
83ef2766
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include <limits>
namespace
cv
{
/****************************************************************************************\
* DescriptorExtractor *
\****************************************************************************************/
/*
* DescriptorExtractor
*/
DescriptorExtractor
::~
DescriptorExtractor
()
{}
void
DescriptorExtractor
::
compute
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
{
if
(
image
.
empty
()
||
keypoints
.
empty
()
)
{
descriptors
.
release
();
return
;
}
KeyPointsFilter
::
runByImageBorder
(
keypoints
,
image
.
size
(),
0
);
KeyPointsFilter
::
runByKeypointSize
(
keypoints
,
std
::
numeric_limits
<
float
>::
epsilon
()
);
computeImpl
(
image
,
keypoints
,
descriptors
);
}
void
DescriptorExtractor
::
compute
(
InputArrayOfArrays
_imageCollection
,
std
::
vector
<
std
::
vector
<
KeyPoint
>
>&
pointCollection
,
OutputArrayOfArrays
_descCollection
)
const
{
std
::
vector
<
Mat
>
imageCollection
,
descCollection
;
_imageCollection
.
getMatVector
(
imageCollection
);
_descCollection
.
getMatVector
(
descCollection
);
CV_Assert
(
imageCollection
.
size
()
==
pointCollection
.
size
()
);
descCollection
.
resize
(
imageCollection
.
size
()
);
for
(
size_t
i
=
0
;
i
<
imageCollection
.
size
();
i
++
)
compute
(
imageCollection
[
i
],
pointCollection
[
i
],
descCollection
[
i
]
);
}
/*void DescriptorExtractor::read( const FileNode& )
{}
void DescriptorExtractor::write( FileStorage& ) const
{}*/
bool
DescriptorExtractor
::
empty
()
const
{
return
false
;
}
void
DescriptorExtractor
::
removeBorderKeypoints
(
std
::
vector
<
KeyPoint
>&
keypoints
,
Size
imageSize
,
int
borderSize
)
{
KeyPointsFilter
::
runByImageBorder
(
keypoints
,
imageSize
,
borderSize
);
}
Ptr
<
DescriptorExtractor
>
DescriptorExtractor
::
create
(
const
String
&
descriptorExtractorType
)
{
return
Algorithm
::
create
<
DescriptorExtractor
>
(
"Feature2D."
+
descriptorExtractorType
);
}
CV_WRAP
void
Feature2D
::
compute
(
InputArray
image
,
CV_OUT
CV_IN_OUT
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
{
DescriptorExtractor
::
compute
(
image
,
keypoints
,
descriptors
);
}
}
modules/features2d/src/detectors.cpp
View file @
1796a26f
...
...
@@ -44,89 +44,19 @@
namespace
cv
{
/*
* FeatureDetector
*/
FeatureDetector
::~
FeatureDetector
()
{}
void
FeatureDetector
::
detect
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
)
const
{
keypoints
.
clear
();
if
(
image
.
empty
()
)
return
;
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8UC1
&&
mask
.
size
()
==
image
.
size
())
);
detectImpl
(
image
,
keypoints
,
mask
);
}
void
FeatureDetector
::
detect
(
InputArrayOfArrays
_imageCollection
,
std
::
vector
<
std
::
vector
<
KeyPoint
>
>&
pointCollection
,
InputArrayOfArrays
_masks
)
const
{
if
(
_imageCollection
.
isUMatVector
())
{
std
::
vector
<
UMat
>
uimageCollection
,
umasks
;
_imageCollection
.
getUMatVector
(
uimageCollection
);
_masks
.
getUMatVector
(
umasks
);
pointCollection
.
resize
(
uimageCollection
.
size
()
);
for
(
size_t
i
=
0
;
i
<
uimageCollection
.
size
();
i
++
)
detect
(
uimageCollection
[
i
],
pointCollection
[
i
],
umasks
.
empty
()
?
noArray
()
:
umasks
[
i
]
);
return
;
}
std
::
vector
<
Mat
>
imageCollection
,
masks
;
_imageCollection
.
getMatVector
(
imageCollection
);
_masks
.
getMatVector
(
masks
);
pointCollection
.
resize
(
imageCollection
.
size
()
);
for
(
size_t
i
=
0
;
i
<
imageCollection
.
size
();
i
++
)
detect
(
imageCollection
[
i
],
pointCollection
[
i
],
masks
.
empty
()
?
noArray
()
:
masks
[
i
]
);
}
/*void FeatureDetector::read( const FileNode& )
{}
void FeatureDetector::write( FileStorage& ) const
{}*/
bool
FeatureDetector
::
empty
()
const
{
return
false
;
}
void
FeatureDetector
::
removeInvalidPoints
(
const
Mat
&
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
)
class
GFTTDetector_Impl
:
public
GFTTDetector
{
KeyPointsFilter
::
runByPixelsMask
(
keypoints
,
mask
);
}
Ptr
<
FeatureDetector
>
FeatureDetector
::
create
(
const
String
&
detectorType
)
{
if
(
detectorType
.
compare
(
"HARRIS"
)
==
0
)
{
Ptr
<
FeatureDetector
>
fd
=
FeatureDetector
::
create
(
"GFTT"
);
fd
->
set
(
"useHarrisDetector"
,
true
);
return
fd
;
}
return
Algorithm
::
create
<
FeatureDetector
>
(
"Feature2D."
+
detectorType
);
}
GFTTDetector
::
GFTTDetector
(
int
_nfeatures
,
double
_qualityLevel
,
public
:
GFTTDetector_Impl
(
int
_nfeatures
,
double
_qualityLevel
,
double
_minDistance
,
int
_blockSize
,
bool
_useHarrisDetector
,
double
_k
)
:
nfeatures
(
_nfeatures
),
qualityLevel
(
_qualityLevel
),
minDistance
(
_minDistance
),
blockSize
(
_blockSize
),
useHarrisDetector
(
_useHarrisDetector
),
k
(
_k
)
{
}
{
}
void
GFTTDetector
::
detectImpl
(
InputArray
_image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
_mask
)
const
{
void
detect
(
InputArray
_image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
_mask
)
{
std
::
vector
<
Point2f
>
corners
;
if
(
_image
.
isUMat
())
...
...
@@ -156,6 +86,23 @@ void GFTTDetector::detectImpl( InputArray _image, std::vector<KeyPoint>& keypoin
for
(
;
corner_it
!=
corners
.
end
();
++
corner_it
,
++
keypoint_it
)
*
keypoint_it
=
KeyPoint
(
*
corner_it
,
(
float
)
blockSize
);
}
int
nfeatures
;
double
qualityLevel
;
double
minDistance
;
int
blockSize
;
bool
useHarrisDetector
;
double
k
;
};
Ptr
<
GFTTDetector
>
GFTTDetector
::
create
(
int
_nfeatures
,
double
_qualityLevel
,
double
_minDistance
,
int
_blockSize
,
bool
_useHarrisDetector
,
double
_k
)
{
return
makePtr
<
GFTTDetector_Impl
>
(
_nfeatures
,
_qualityLevel
,
_minDistance
,
_blockSize
,
_useHarrisDetector
,
_k
);
}
}
modules/features2d/src/fast.cpp
View file @
1796a26f
...
...
@@ -356,19 +356,17 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
{
FAST
(
_img
,
keypoints
,
threshold
,
nonmax_suppression
,
FastFeatureDetector
::
TYPE_9_16
);
}
/*
* FastFeatureDetector
*/
FastFeatureDetector
::
FastFeatureDetector
(
int
_threshold
,
bool
_nonmaxSuppression
)
:
threshold
(
_threshold
),
nonmaxSuppression
(
_nonmaxSuppression
),
type
(
FastFeatureDetector
::
TYPE_9_16
)
{}
FastFeatureDetector
::
FastFeatureDetector
(
int
_threshold
,
bool
_nonmaxSuppression
,
int
_type
)
:
threshold
(
_threshold
),
nonmaxSuppression
(
_nonmaxSuppression
),
type
((
short
)
_type
)
{}
void
FastFeatureDetector
::
detectImpl
(
InputArray
_image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
_mask
)
const
class
FastFeatureDetector_Impl
:
public
FastFeatureDetector
{
public
:
FastFeatureDetector_Impl
(
int
_threshold
,
bool
_nonmaxSuppression
,
int
_type
)
:
threshold
(
_threshold
),
nonmaxSuppression
(
_nonmaxSuppression
),
type
((
short
)
_type
)
{}
void
detect
(
InputArray
_image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
_mask
)
{
Mat
mask
=
_mask
.
getMat
(),
grayImage
;
UMat
ugrayImage
;
_InputArray
gray
=
_image
;
...
...
@@ -380,6 +378,17 @@ void FastFeatureDetector::detectImpl( InputArray _image, std::vector<KeyPoint>&
}
FAST
(
gray
,
keypoints
,
threshold
,
nonmaxSuppression
,
type
);
KeyPointsFilter
::
runByPixelsMask
(
keypoints
,
mask
);
}
int
threshold
;
bool
nonmaxSuppression
;
int
type
;
};
Ptr
<
FastFeatureDetector
>
FastFeatureDetector
::
create
(
int
threshold
,
bool
nonmaxSuppression
,
int
type
)
{
return
makePtr
<
FastFeatureDetector_Impl
>
(
threshold
,
nonmaxSuppression
,
type
);
}
}
modules/features2d/src/features2d_init.cpp
View file @
1796a26f
...
...
@@ -42,6 +42,8 @@
#include "precomp.hpp"
#if 0
using namespace cv;
Ptr<Feature2D> Feature2D::create( const String& feature2DType )
...
...
@@ -193,3 +195,5 @@ bool cv::initModule_features2d(void)
return all;
}
#endif
modules/features2d/src/kaze.cpp
View file @
1796a26f
...
...
@@ -52,17 +52,11 @@ http://www.robesafe.com/personal/pablo.alcantarilla/papers/Alcantarilla12eccv.pd
namespace
cv
{
KAZE
::
KAZE
()
:
extended
(
false
)
,
upright
(
false
)
,
threshold
(
0.001
f
)
,
octaves
(
4
)
,
sublevels
(
4
)
,
diffusivity
(
DIFF_PM_G2
)
{
}
KAZE
::
KAZE
(
bool
_extended
,
bool
_upright
,
float
_threshold
,
int
_octaves
,
class
KAZE_Impl
:
public
KAZE
{
public
:
KAZE_Impl
(
bool
_extended
,
bool
_upright
,
float
_threshold
,
int
_octaves
,
int
_sublevels
,
int
_diffusivity
)
:
extended
(
_extended
)
,
upright
(
_upright
)
...
...
@@ -71,40 +65,32 @@ namespace cv
,
sublevels
(
_sublevels
)
,
diffusivity
(
_diffusivity
)
{
}
KAZE
::~
KAZE
()
{
}
virtual
~
KAZE_Impl
()
{
}
// returns the descriptor size in bytes
int
KAZE
::
descriptorSize
()
const
int
descriptorSize
()
const
{
return
extended
?
128
:
64
;
}
// returns the descriptor type
int
KAZE
::
descriptorType
()
const
int
descriptorType
()
const
{
return
CV_32F
;
}
// returns the default norm type
int
KAZE
::
defaultNorm
()
const
int
defaultNorm
()
const
{
return
NORM_L2
;
}
void
KAZE
::
operator
()(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
)
const
{
detectImpl
(
image
,
keypoints
,
mask
);
}
void
KAZE
::
operator
()(
InputArray
image
,
InputArray
mask
,
void
detectAndCompute
(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
,
bool
useProvidedKeypoints
)
const
bool
useProvidedKeypoints
)
{
cv
::
Mat
img
=
image
.
getMat
();
if
(
img
.
type
()
!=
CV_8UC1
)
...
...
@@ -113,8 +99,6 @@ namespace cv
Mat
img1_32
;
img
.
convertTo
(
img1_32
,
CV_32F
,
1.0
/
255.0
,
0
);
cv
::
Mat
&
desc
=
descriptors
.
getMatRef
();
KAZEOptions
options
;
options
.
img_width
=
img
.
cols
;
options
.
img_height
=
img
.
rows
;
...
...
@@ -138,67 +122,23 @@ namespace cv
cv
::
KeyPointsFilter
::
runByPixelsMask
(
keypoints
,
mask
.
getMat
());
}
if
(
descriptors
.
needed
()
)
{
Mat
&
desc
=
descriptors
.
getMatRef
();
impl
.
Feature_Description
(
keypoints
,
desc
);
CV_Assert
((
!
desc
.
rows
||
desc
.
cols
==
descriptorSize
()));
CV_Assert
((
!
desc
.
rows
||
(
desc
.
type
()
==
descriptorType
())));
}
void
KAZE
::
detectImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
)
const
{
Mat
img
=
image
.
getMat
();
if
(
img
.
type
()
!=
CV_8UC1
)
cvtColor
(
image
,
img
,
COLOR_BGR2GRAY
);
Mat
img1_32
;
img
.
convertTo
(
img1_32
,
CV_32F
,
1.0
/
255.0
,
0
);
KAZEOptions
options
;
options
.
img_width
=
img
.
cols
;
options
.
img_height
=
img
.
rows
;
options
.
extended
=
extended
;
options
.
upright
=
upright
;
options
.
dthreshold
=
threshold
;
options
.
omax
=
octaves
;
options
.
nsublevels
=
sublevels
;
options
.
diffusivity
=
diffusivity
;
KAZEFeatures
impl
(
options
);
impl
.
Create_Nonlinear_Scale_Space
(
img1_32
);
impl
.
Feature_Detection
(
keypoints
);
if
(
!
mask
.
empty
())
{
cv
::
KeyPointsFilter
::
runByPixelsMask
(
keypoints
,
mask
.
getMat
());
}
}
void
KAZE
::
computeImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
{
cv
::
Mat
img
=
image
.
getMat
();
if
(
img
.
type
()
!=
CV_8UC1
)
cvtColor
(
image
,
img
,
COLOR_BGR2GRAY
);
Mat
img1_32
;
img
.
convertTo
(
img1_32
,
CV_32F
,
1.0
/
255.0
,
0
);
cv
::
Mat
&
desc
=
descriptors
.
getMatRef
();
KAZEOptions
options
;
options
.
img_width
=
img
.
cols
;
options
.
img_height
=
img
.
rows
;
options
.
extended
=
extended
;
options
.
upright
=
upright
;
options
.
dthreshold
=
threshold
;
options
.
omax
=
octaves
;
options
.
nsublevels
=
sublevels
;
options
.
diffusivity
=
diffusivity
;
bool
extended
;
bool
upright
;
float
threshold
;
int
octaves
;
int
sublevels
;
int
diffusivity
;
};
KAZEFeatures
impl
(
options
);
impl
.
Create_Nonlinear_Scale_Space
(
img1_32
);
impl
.
Feature_Description
(
keypoints
,
desc
);
CV_Assert
((
!
desc
.
rows
||
desc
.
cols
==
descriptorSize
()));
CV_Assert
((
!
desc
.
rows
||
(
desc
.
type
()
==
descriptorType
())));
}
}
modules/features2d/src/kaze/AKAZEConfig.h
View file @
1796a26f
...
...
@@ -8,23 +8,8 @@
#ifndef __OPENCV_FEATURES_2D_AKAZE_CONFIG_H__
#define __OPENCV_FEATURES_2D_AKAZE_CONFIG_H__
/* ************************************************************************* */
// OpenCV
#include "../precomp.hpp"
#include <opencv2/features2d.hpp>
/* ************************************************************************* */
/// Lookup table for 2d gaussian (sigma = 2.5) where (0,0) is top left and (6,6) is bottom right
const
float
gauss25
[
7
][
7
]
=
{
{
0
.
025464
81
f
,
0
.
023506
98
f
,
0
.
01
849125
f
,
0
.
0123
9505
f
,
0
.
0070
8017
f
,
0
.
0034462
9
f
,
0
.
00142
946
f
},
{
0
.
023506
98
f
,
0
.
0216
9968
f
,
0
.
01706
957
f
,
0
.
0114420
8
f
,
0
.
006535
82
f
,
0
.
0031
8132
f
,
0
.
00131
956
f
},
{
0
.
01
849125
f
,
0
.
01706
957
f
,
0
.
01342740
f
,
0
.
00
900066
f
,
0
.
00514126
f
,
0
.
00250252
f
,
0
.
00103
800
f
},
{
0
.
0123
9505
f
,
0
.
0114420
8
f
,
0
.
00
900066
f
,
0
.
00603332
f
,
0
.
0034462
9
f
,
0
.
0016774
9
f
,
0
.
0006
9579
f
},
{
0
.
0070
8017
f
,
0
.
006535
82
f
,
0
.
00514126
f
,
0
.
0034462
9
f
,
0
.
001
96855
f
,
0
.
000
95820
f
,
0
.
0003
9744
f
},
{
0
.
0034462
9
f
,
0
.
0031
8132
f
,
0
.
00250252
f
,
0
.
0016774
9
f
,
0
.
000
95820
f
,
0
.
00046640
f
,
0
.
0001
9346
f
},
{
0
.
00142
946
f
,
0
.
00131
956
f
,
0
.
00103
800
f
,
0
.
0006
9579
f
,
0
.
0003
9744
f
,
0
.
0001
9346
f
,
0
.
0000
8024
f
}
};
namespace
cv
{
/* ************************************************************************* */
/// AKAZE configuration options structure
struct
AKAZEOptions
{
...
...
@@ -75,4 +60,6 @@ struct AKAZEOptions {
int
kcontrast_nbins
;
///< Number of bins for the contrast factor histogram
};
}
#endif
modules/features2d/src/kaze/AKAZEFeatures.cpp
View file @
1796a26f
...
...
@@ -6,6 +6,7 @@
* @author Pablo F. Alcantarilla, Jesus Nuevo
*/
#include "../precomp.hpp"
#include "AKAZEFeatures.h"
#include "fed.h"
#include "nldiffusion_functions.h"
...
...
@@ -14,9 +15,9 @@
#include <iostream>
// Namespaces
namespace
cv
{
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
details
::
kaze
;
/* ************************************************************************* */
/**
...
...
@@ -29,7 +30,7 @@ AKAZEFeatures::AKAZEFeatures(const AKAZEOptions& options) : options_(options) {
ncycles_
=
0
;
reordering_
=
true
;
if
(
options_
.
descriptor_size
>
0
&&
options_
.
descriptor
>=
cv
::
DESCRIPTOR_MLDB_UPRIGHT
)
{
if
(
options_
.
descriptor_size
>
0
&&
options_
.
descriptor
>=
AKAZE
::
DESCRIPTOR_MLDB_UPRIGHT
)
{
generateDescriptorSubsample
(
descriptorSamples_
,
descriptorBits_
,
options_
.
descriptor_size
,
options_
.
descriptor_pattern_size
,
options_
.
descriptor_channels
);
}
...
...
@@ -264,10 +265,10 @@ void AKAZEFeatures::Find_Scale_Space_Extrema(std::vector<cv::KeyPoint>& kpts)
vector
<
cv
::
KeyPoint
>
kpts_aux
;
// Set maximum size
if
(
options_
.
descriptor
==
cv
::
DESCRIPTOR_MLDB_UPRIGHT
||
options_
.
descriptor
==
cv
::
DESCRIPTOR_MLDB
)
{
if
(
options_
.
descriptor
==
AKAZE
::
DESCRIPTOR_MLDB_UPRIGHT
||
options_
.
descriptor
==
AKAZE
::
DESCRIPTOR_MLDB
)
{
smax
=
10.0
f
*
sqrtf
(
2.0
f
);
}
else
if
(
options_
.
descriptor
==
cv
::
DESCRIPTOR_KAZE_UPRIGHT
||
options_
.
descriptor
==
cv
::
DESCRIPTOR_KAZE
)
{
else
if
(
options_
.
descriptor
==
AKAZE
::
DESCRIPTOR_KAZE_UPRIGHT
||
options_
.
descriptor
==
AKAZE
::
DESCRIPTOR_KAZE
)
{
smax
=
12.0
f
*
sqrtf
(
2.0
f
);
}
...
...
@@ -712,7 +713,7 @@ void AKAZEFeatures::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat
}
// Allocate memory for the matrix with the descriptors
if
(
options_
.
descriptor
<
cv
::
DESCRIPTOR_MLDB_UPRIGHT
)
{
if
(
options_
.
descriptor
<
AKAZE
::
DESCRIPTOR_MLDB_UPRIGHT
)
{
desc
=
cv
::
Mat
::
zeros
((
int
)
kpts
.
size
(),
64
,
CV_32FC1
);
}
else
{
...
...
@@ -729,17 +730,17 @@ void AKAZEFeatures::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat
switch
(
options_
.
descriptor
)
{
case
cv
:
:
DESCRIPTOR_KAZE_UPRIGHT
:
// Upright descriptors, not invariant to rotation
case
AKAZE
:
:
DESCRIPTOR_KAZE_UPRIGHT
:
// Upright descriptors, not invariant to rotation
{
cv
::
parallel_for_
(
cv
::
Range
(
0
,
(
int
)
kpts
.
size
()),
MSURF_Upright_Descriptor_64_Invoker
(
kpts
,
desc
,
evolution_
));
}
break
;
case
cv
:
:
DESCRIPTOR_KAZE
:
case
AKAZE
:
:
DESCRIPTOR_KAZE
:
{
cv
::
parallel_for_
(
cv
::
Range
(
0
,
(
int
)
kpts
.
size
()),
MSURF_Descriptor_64_Invoker
(
kpts
,
desc
,
evolution_
));
}
break
;
case
cv
:
:
DESCRIPTOR_MLDB_UPRIGHT
:
// Upright descriptors, not invariant to rotation
case
AKAZE
:
:
DESCRIPTOR_MLDB_UPRIGHT
:
// Upright descriptors, not invariant to rotation
{
if
(
options_
.
descriptor_size
==
0
)
cv
::
parallel_for_
(
cv
::
Range
(
0
,
(
int
)
kpts
.
size
()),
Upright_MLDB_Full_Descriptor_Invoker
(
kpts
,
desc
,
evolution_
,
options_
));
...
...
@@ -747,7 +748,7 @@ void AKAZEFeatures::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat
cv
::
parallel_for_
(
cv
::
Range
(
0
,
(
int
)
kpts
.
size
()),
Upright_MLDB_Descriptor_Subset_Invoker
(
kpts
,
desc
,
evolution_
,
options_
,
descriptorSamples_
,
descriptorBits_
));
}
break
;
case
cv
:
:
DESCRIPTOR_MLDB
:
case
AKAZE
:
:
DESCRIPTOR_MLDB
:
{
if
(
options_
.
descriptor_size
==
0
)
cv
::
parallel_for_
(
cv
::
Range
(
0
,
(
int
)
kpts
.
size
()),
MLDB_Full_Descriptor_Invoker
(
kpts
,
desc
,
evolution_
,
options_
));
...
...
@@ -765,7 +766,20 @@ void AKAZEFeatures::Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat
* @note The orientation is computed using a similar approach as described in the
* original SURF method. See Bay et al., Speeded Up Robust Features, ECCV 2006
*/
void
AKAZEFeatures
::
Compute_Main_Orientation
(
cv
::
KeyPoint
&
kpt
,
const
std
::
vector
<
TEvolution
>&
evolution_
)
{
void
AKAZEFeatures
::
Compute_Main_Orientation
(
cv
::
KeyPoint
&
kpt
,
const
std
::
vector
<
TEvolution
>&
evolution_
)
{
/* ************************************************************************* */
/// Lookup table for 2d gaussian (sigma = 2.5) where (0,0) is top left and (6,6) is bottom right
static
const
float
gauss25
[
7
][
7
]
=
{
{
0.02546481
f
,
0.02350698
f
,
0.01849125
f
,
0.01239505
f
,
0.00708017
f
,
0.00344629
f
,
0.00142946
f
},
{
0.02350698
f
,
0.02169968
f
,
0.01706957
f
,
0.01144208
f
,
0.00653582
f
,
0.00318132
f
,
0.00131956
f
},
{
0.01849125
f
,
0.01706957
f
,
0.01342740
f
,
0.00900066
f
,
0.00514126
f
,
0.00250252
f
,
0.00103800
f
},
{
0.01239505
f
,
0.01144208
f
,
0.00900066
f
,
0.00603332
f
,
0.00344629
f
,
0.00167749
f
,
0.00069579
f
},
{
0.00708017
f
,
0.00653582
f
,
0.00514126
f
,
0.00344629
f
,
0.00196855
f
,
0.00095820
f
,
0.00039744
f
},
{
0.00344629
f
,
0.00318132
f
,
0.00250252
f
,
0.00167749
f
,
0.00095820
f
,
0.00046640
f
,
0.00019346
f
},
{
0.00142946
f
,
0.00131956
f
,
0.00103800
f
,
0.00069579
f
,
0.00039744
f
,
0.00019346
f
,
0.00008024
f
}
};
int
ix
=
0
,
iy
=
0
,
idx
=
0
,
s
=
0
,
level
=
0
;
float
xf
=
0.0
,
yf
=
0.0
,
gweight
=
0.0
,
ratio
=
0.0
;
...
...
@@ -1702,3 +1716,6 @@ void generateDescriptorSubsample(cv::Mat& sampleList, cv::Mat& comparisons, int
sampleList
=
samples
.
rowRange
(
0
,
count
).
clone
();
comparisons
=
comps
.
rowRange
(
0
,
nbits
).
clone
();
}
}
}
modules/features2d/src/kaze/KAZEConfig.h
View file @
1796a26f
...
...
@@ -12,12 +12,14 @@
#include "../precomp.hpp"
#include <opencv2/features2d.hpp>
namespace
cv
{
//*************************************************************************************
struct
KAZEOptions
{
KAZEOptions
()
:
diffusivity
(
cv
::
DIFF_PM_G2
)
:
diffusivity
(
KAZE
::
DIFF_PM_G2
)
,
soffset
(
1
.
60
f
)
,
omax
(
4
)
...
...
@@ -49,4 +51,6 @@ struct KAZEOptions {
bool
extended
;
};
}
#endif
modules/features2d/src/kaze/KAZEFeatures.h
View file @
1796a26f
...
...
@@ -17,6 +17,9 @@
#include "fed.h"
#include "TEvolution.h"
namespace
cv
{
/* ************************************************************************* */
// KAZE Class Declaration
class
KAZEFeatures
{
...
...
@@ -56,4 +59,6 @@ public:
void
Do_Subpixel_Refinement
(
std
::
vector
<
cv
::
KeyPoint
>&
kpts
);
};
}
#endif
modules/features2d/src/orb.cpp
View file @
1796a26f
...
...
@@ -645,38 +645,70 @@ static inline float getScale(int level, int firstLevel, double scaleFactor)
return
(
float
)
std
::
pow
(
scaleFactor
,
(
double
)(
level
-
firstLevel
));
}
/** Constructor
* @param detector_params parameters to use
*/
ORB
::
ORB
(
int
_nfeatures
,
float
_scaleFactor
,
int
_nlevels
,
int
_edgeThreshold
,
class
ORB_Impl
:
public
ORB
{
public
:
explicit
ORB_Impl
(
int
_nfeatures
,
float
_scaleFactor
,
int
_nlevels
,
int
_edgeThreshold
,
int
_firstLevel
,
int
_WTA_K
,
int
_scoreType
,
int
_patchSize
,
int
_fastThreshold
)
:
nfeatures
(
_nfeatures
),
scaleFactor
(
_scaleFactor
),
nlevels
(
_nlevels
),
edgeThreshold
(
_edgeThreshold
),
firstLevel
(
_firstLevel
),
WTA_K
(
_WTA_K
),
scoreType
(
_scoreType
),
patchSize
(
_patchSize
),
fastThreshold
(
_fastThreshold
)
{}
{}
// returns the descriptor size in bytes
int
descriptorSize
()
const
;
// returns the descriptor type
int
descriptorType
()
const
;
// returns the default norm type
int
defaultNorm
()
const
;
// Compute the ORB_Impl features and descriptors on an image
void
operator
()(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
)
const
;
// Compute the ORB_Impl features and descriptors on an image
void
operator
()(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
,
bool
useProvidedKeypoints
=
false
)
const
;
AlgorithmInfo
*
info
()
const
;
protected
:
void
computeImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
;
void
detectImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
=
noArray
()
)
const
;
int
nfeatures
;
double
scaleFactor
;
int
nlevels
;
int
edgeThreshold
;
int
firstLevel
;
int
WTA_K
;
int
scoreType
;
int
patchSize
;
int
fastThreshold
;
};
int
ORB
::
descriptorSize
()
const
int
ORB
_Impl
::
descriptorSize
()
const
{
return
kBytes
;
}
int
ORB
::
descriptorType
()
const
int
ORB
_Impl
::
descriptorType
()
const
{
return
CV_8U
;
}
int
ORB
::
defaultNorm
()
const
int
ORB
_Impl
::
defaultNorm
()
const
{
return
NORM_HAMMING
;
}
/** Compute the ORB features and descriptors on an image
/** Compute the ORB
_Impl
features and descriptors on an image
* @param img the image to compute the features and descriptors on
* @param mask the mask to apply
* @param keypoints the resulting keypoints
*/
void
ORB
::
operator
()(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
)
const
void
ORB
_Impl
::
operator
()(
InputArray
image
,
InputArray
mask
,
std
::
vector
<
KeyPoint
>&
keypoints
)
const
{
(
*
this
)(
image
,
mask
,
keypoints
,
noArray
(),
false
);
}
...
...
@@ -716,7 +748,7 @@ static void uploadORBKeypoints(const std::vector<KeyPoint>& src,
}
/** Compute the ORB keypoints on an image
/** Compute the ORB
_Impl
keypoints on an image
* @param image_pyramid the image pyramid to compute the features and descriptors on
* @param mask_pyramid the masks to apply at every level
* @param keypoints the resulting keypoints, clustered per level
...
...
@@ -788,7 +820,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
KeyPointsFilter
::
runByImageBorder
(
keypoints
,
img
.
size
(),
edgeThreshold
);
// Keep more points than necessary as FAST does not give amazing corners
KeyPointsFilter
::
retainBest
(
keypoints
,
scoreType
==
ORB
::
HARRIS_SCORE
?
2
*
featuresNum
:
featuresNum
);
KeyPointsFilter
::
retainBest
(
keypoints
,
scoreType
==
ORB
_Impl
::
HARRIS_SCORE
?
2
*
featuresNum
:
featuresNum
);
nkeypoints
=
(
int
)
keypoints
.
size
();
counters
[
level
]
=
nkeypoints
;
...
...
@@ -814,7 +846,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
UMat
ukeypoints
,
uresponses
(
1
,
nkeypoints
,
CV_32F
);
// Select best features using the Harris cornerness (better scoring than FAST)
if
(
scoreType
==
ORB
::
HARRIS_SCORE
)
if
(
scoreType
==
ORB
_Impl
::
HARRIS_SCORE
)
{
if
(
useOCL
)
{
...
...
@@ -886,7 +918,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
}
/** Compute the ORB features and descriptors on an image
/** Compute the ORB
_Impl
features and descriptors on an image
* @param img the image to compute the features and descriptors on
* @param mask the mask to apply
* @param keypoints the resulting keypoints
...
...
@@ -894,7 +926,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
* @param do_keypoints if true, the keypoints are computed, otherwise used as an input
* @param do_descriptors if true, also computes the descriptors
*/
void
ORB
::
operator
()(
InputArray
_image
,
InputArray
_mask
,
std
::
vector
<
KeyPoint
>&
keypoints
,
void
ORB
_Impl
::
operator
()(
InputArray
_image
,
InputArray
_mask
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
_descriptors
,
bool
useProvidedKeypoints
)
const
{
CV_Assert
(
patchSize
>=
2
);
...
...
@@ -1121,12 +1153,12 @@ void ORB::operator()( InputArray _image, InputArray _mask, std::vector<KeyPoint>
}
}
void
ORB
::
detectImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
)
const
void
ORB
_Impl
::
detectImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
InputArray
mask
)
const
{
(
*
this
)(
image
.
getMat
(),
mask
.
getMat
(),
keypoints
,
noArray
(),
false
);
}
void
ORB
::
computeImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
void
ORB
_Impl
::
computeImpl
(
InputArray
image
,
std
::
vector
<
KeyPoint
>&
keypoints
,
OutputArray
descriptors
)
const
{
(
*
this
)(
image
,
Mat
(),
keypoints
,
descriptors
,
true
);
}
...
...
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