Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
f8ecc760
Commit
f8ecc760
authored
May 13, 2015
by
GilLevi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed warnings in LATCH
parent
422ae964
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
52 deletions
+32
-52
xfeatures2d.hpp
modules/xfeatures2d/include/opencv2/xfeatures2d.hpp
+1
-3
latch.cpp
modules/xfeatures2d/src/latch.cpp
+31
-49
No files found.
modules/xfeatures2d/include/opencv2/xfeatures2d.hpp
View file @
f8ecc760
...
...
@@ -156,9 +156,7 @@ Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", ar
class
CV_EXPORTS
LATCHDescriptorExtractor
:
public
DescriptorExtractor
{
public
:
static
Ptr
<
LATCHDescriptorExtractor
>
create
(
int
bytes
=
32
,
bool
rotationInvariance
=
true
,
int
ssdSize
=
7
);
protected
:
static
int
bit_pattern_64_
[
512
*
6
];
static
Ptr
<
LATCHDescriptorExtractor
>
create
(
int
bytes
=
32
,
bool
rotationInvariance
=
true
,
int
half_ssd_size
=
3
);
};
...
...
modules/xfeatures2d/src/latch.cpp
View file @
f8ecc760
...
...
@@ -63,7 +63,7 @@ namespace xfeatures2d
public
:
enum
{
PATCH_SIZE
=
48
};
LATCHDescriptorExtractorImpl
(
int
bytes
=
32
,
bool
rotationInvariance
=
true
,
int
ssdSize
=
7
);
LATCHDescriptorExtractorImpl
(
int
bytes
=
32
,
bool
rotationInvariance
=
true
,
int
half_ssd_size
=
3
);
virtual
void
read
(
const
FileNode
&
);
virtual
void
write
(
FileStorage
&
)
const
;
...
...
@@ -81,13 +81,13 @@ protected:
PixelTestFn
test_fn_
;
int
half_ssd_size_
;
bool
rotationInvariance_
;
std
::
vector
<
int
>
sampling_points_
;
//
std::vector<int> sampling_points_;
void
setTriplets
();
};
Ptr
<
LATCHDescriptorExtractor
>
LATCHDescriptorExtractor
::
create
(
int
bytes
,
bool
rotationInvariance
,
int
ssdS
ize
)
Ptr
<
LATCHDescriptorExtractor
>
LATCHDescriptorExtractor
::
create
(
int
bytes
,
bool
rotationInvariance
,
int
half_ssd_s
ize
)
{
return
makePtr
<
LATCHDescriptorExtractorImpl
>
(
bytes
,
rotationInvariance
,
ssdS
ize
);
return
makePtr
<
LATCHDescriptorExtractorImpl
>
(
bytes
,
rotationInvariance
,
half_ssd_s
ize
);
}
void
CacluateSums
(
int
count
,
const
std
::
vector
<
int
>
&
points
,
bool
rotationInvariance
,
const
Mat
&
grayImage
,
const
KeyPoint
&
pt
,
int
&
suma
,
int
&
sumc
,
float
cos_theta
,
float
sin_theta
,
int
half_ssd_size
);
...
...
@@ -106,15 +106,15 @@ static void pixelTests1(const Mat& grayImage, const std::vector<KeyPoint>& keypo
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
1
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
1
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
i
x
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -137,15 +137,15 @@ static void pixelTests2(const Mat& grayImage, const std::vector<KeyPoint>& keypo
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
2
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
2
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
i
x
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -168,15 +168,15 @@ static void pixelTests4(const Mat& grayImage, const std::vector<KeyPoint>& keypo
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
4
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
4
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
i
x
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -200,14 +200,15 @@ static void pixelTests8(const Mat& grayImage, const std::vector<KeyPoint>& keypo
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
8
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
8
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
i
x
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -230,14 +231,15 @@ static void pixelTests16(const Mat& grayImage, const std::vector<KeyPoint>& keyp
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
16
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
16
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
i
x
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -259,15 +261,15 @@ static void pixelTests32(const Mat& grayImage, const std::vector<KeyPoint>& keyp
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
32
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
32
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
ix
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -290,15 +292,15 @@ static void pixelTests64(const Mat& grayImage, const std::vector<KeyPoint>& keyp
angle
*=
(
float
)(
CV_PI
/
180.
f
);
float
cos_theta
=
cos
(
angle
);
float
sin_theta
=
sin
(
angle
);
for
(
int
i
=
0
;
i
<
64
;
i
++
){
desc
[
i
]
=
0
;
for
(
int
i
x
=
0
;
ix
<
64
;
ix
++
){
desc
[
i
x
]
=
0
;
for
(
int
j
=
7
;
j
>=
0
;
j
--
){
int
suma
=
0
;
int
sumc
=
0
;
CacluateSums
(
count
,
points
,
rotationInvariance
,
grayImage
,
pt
,
suma
,
sumc
,
cos_theta
,
sin_theta
,
half_ssd_size
);
desc
[
i
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
desc
[
i
x
]
+=
(
uchar
)((
suma
<
sumc
)
<<
j
);
count
+=
6
;
}
...
...
@@ -400,27 +402,9 @@ void CacluateSums(int count, const std::vector<int> &points, bool rotationInvari
LATCHDescriptorExtractorImpl
::
LATCHDescriptorExtractorImpl
(
int
bytes
,
bool
rotationInvariance
,
int
ssdS
ize
)
:
bytes_
(
bytes
),
test_fn_
(
NULL
),
rotationInvariance_
(
rotationInvariance
),
half_ssd_size_
(
(
ssdSize
-
1
)
/
2
)
LATCHDescriptorExtractorImpl
::
LATCHDescriptorExtractorImpl
(
int
bytes
,
bool
rotationInvariance
,
int
half_ssd_s
ize
)
:
bytes_
(
bytes
),
test_fn_
(
NULL
),
rotationInvariance_
(
rotationInvariance
),
half_ssd_size_
(
half_ssd_size
)
{
/*std::string triplets_file = "D:/Dropbox/BinaryDescriptors/CombinedLearningResultsOLD/CombinedLearnedTripletsOLD_yosemite_harris__crossCorT_0.2_lastMean_0.9448.txt";
FILE * fid = fopen(triplets_file.c_str(), "r");
int ax, ay, bx, by, cx, cy;
int D = 512;
for (int i = 0; i < D; i++)
{
fscanf(fid, "%d %d %d %d %d %d\n", &ax, &ay, &bx, &by, &cx, &cy);
sampling_points_.push_back(ax);
sampling_points_.push_back(ay);
sampling_points_.push_back(bx);
sampling_points_.push_back(by);
sampling_points_.push_back(cx);
sampling_points_.push_back(cy);
}*/
switch
(
bytes
)
{
case
1
:
...
...
@@ -524,10 +508,8 @@ void LATCHDescriptorExtractorImpl::compute(InputArray image,
test_fn_
(
grayImage
,
keypoints
,
descriptors
,
sampling_points_
,
rotationInvariance_
,
half_ssd_size_
);
}
void
LATCHDescriptorExtractorImpl
::
setTriplets
()
{
sampling_points_
=
{
13
,
-
6
,
19
,
19
,
23
,
-
4
,
static
std
::
vector
<
int
>
sampling_points_
{
13
,
-
6
,
19
,
19
,
23
,
-
4
,
4
,
16
,
24
,
-
11
,
4
,
-
21
,
22
,
-
14
,
-
2
,
-
20
,
23
,
5
,
17
,
-
10
,
2
,
10
,
14
,
-
18
,
...
...
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