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
97640847
Commit
97640847
authored
Oct 11, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add methods to sort keypoints and corresponding descriptors
parent
18295bc7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
4 deletions
+66
-4
perf_orb.cpp
modules/features2d/perf/perf_orb.cpp
+3
-0
ts_perf.hpp
modules/ts/include/opencv2/ts/ts_perf.hpp
+18
-0
ts_perf.cpp
modules/ts/src/ts_perf.cpp
+45
-4
No files found.
modules/features2d/perf/perf_orb.cpp
View file @
97640847
...
...
@@ -27,6 +27,7 @@ PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
TEST_CYCLE
()
detector
(
frame
,
mask
,
points
);
sort
(
points
.
begin
(),
points
.
end
(),
comparators
::
KeypointGreater
());
SANITY_CHECK_KEYPOINTS
(
points
);
}
...
...
@@ -44,6 +45,7 @@ PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
ORB
detector
(
1500
,
1.3
f
,
5
);
vector
<
KeyPoint
>
points
;
detector
(
frame
,
mask
,
points
);
sort
(
points
.
begin
(),
points
.
end
(),
comparators
::
KeypointGreater
());
Mat
descriptors
;
...
...
@@ -69,6 +71,7 @@ PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
TEST_CYCLE
()
detector
(
frame
,
mask
,
points
,
descriptors
,
false
);
perf
::
sort
(
points
,
descriptors
);
SANITY_CHECK_KEYPOINTS
(
points
);
SANITY_CHECK
(
descriptors
);
}
modules/ts/include/opencv2/ts/ts_perf.hpp
View file @
97640847
...
...
@@ -510,7 +510,25 @@ struct CV_EXPORTS RectLess_
typedef
RectLess_
<
int
>
RectLess
;
struct
CV_EXPORTS
KeypointGreater
{
bool
operator
()(
const
cv
::
KeyPoint
&
kp1
,
const
cv
::
KeyPoint
&
kp2
)
const
{
if
(
kp1
.
response
>
kp2
.
response
)
return
true
;
if
(
kp1
.
response
<
kp2
.
response
)
return
false
;
if
(
kp1
.
size
>
kp2
.
size
)
return
true
;
if
(
kp1
.
size
<
kp2
.
size
)
return
false
;
if
(
kp1
.
octave
>
kp2
.
octave
)
return
true
;
if
(
kp1
.
octave
<
kp2
.
octave
)
return
false
;
if
(
kp1
.
pt
.
y
<
kp2
.
pt
.
y
)
return
false
;
if
(
kp1
.
pt
.
y
>
kp2
.
pt
.
y
)
return
true
;
return
kp1
.
pt
.
x
<
kp2
.
pt
.
x
;
}
};
}
//namespace comparators
void
CV_EXPORTS
sort
(
std
::
vector
<
cv
::
KeyPoint
>&
pts
,
cv
::
InputOutputArray
descriptors
);
}
//namespace perf
#endif //__OPENCV_TS_PERF_HPP__
modules/ts/src/ts_perf.cpp
View file @
97640847
...
...
@@ -1246,6 +1246,51 @@ TestBase::_declareHelper::_declareHelper(TestBase* t) : test(t)
{
}
/*****************************************************************************************\
* miscellaneous
\*****************************************************************************************/
namespace
{
struct
KeypointComparator
{
std
::
vector
<
cv
::
KeyPoint
>&
pts_
;
comparators
::
KeypointGreater
cmp
;
KeypointComparator
(
std
::
vector
<
cv
::
KeyPoint
>&
pts
)
:
pts_
(
pts
),
cmp
()
{}
bool
operator
()(
int
idx1
,
int
idx2
)
const
{
return
cmp
(
pts_
[
idx1
],
pts_
[
idx2
]);
}
};
}
//namespace
void
perf
::
sort
(
std
::
vector
<
cv
::
KeyPoint
>&
pts
,
cv
::
InputOutputArray
descriptors
)
{
cv
::
Mat
desc
=
descriptors
.
getMat
();
CV_Assert
(
pts
.
size
()
==
(
size_t
)
desc
.
rows
);
cv
::
AutoBuffer
<
int
>
idxs
(
desc
.
rows
);
for
(
int
i
=
0
;
i
<
desc
.
rows
;
++
i
)
idxs
[
i
]
=
i
;
std
::
sort
((
int
*
)
idxs
,
(
int
*
)
idxs
+
desc
.
rows
,
KeypointComparator
(
pts
));
std
::
vector
<
cv
::
KeyPoint
>
spts
(
pts
.
size
());
cv
::
Mat
sdesc
(
desc
.
size
(),
desc
.
type
());
for
(
int
j
=
0
;
j
<
desc
.
rows
;
++
j
)
{
spts
[
j
]
=
pts
[
idxs
[
j
]];
cv
::
Mat
row
=
sdesc
.
row
(
j
);
desc
.
row
(
idxs
[
j
]).
copyTo
(
row
);
}
spts
.
swap
(
pts
);
sdesc
.
copyTo
(
desc
);
}
/*****************************************************************************************\
* ::perf::GpuPerf
\*****************************************************************************************/
...
...
@@ -1293,7 +1338,3 @@ void PrintTo(const Size& sz, ::std::ostream* os)
}
// namespace cv
/*****************************************************************************************\
* ::cv::PrintTo
\*****************************************************************************************/
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