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
d5513f52
Commit
d5513f52
authored
Apr 14, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cv::sort
parent
cb8743f9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
2 deletions
+68
-2
perf_sort.cpp
modules/core/perf/perf_sort.cpp
+32
-0
matrix.cpp
modules/core/src/matrix.cpp
+36
-2
No files found.
modules/core/perf/perf_sort.cpp
0 → 100644
View file @
d5513f52
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
perf
;
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
#define TYPICAL_MAT_SIZES_SORT TYPICAL_MAT_SIZES
#define TYPICAL_MAT_TYPES_SORT CV_8SC1, CV_16UC1, CV_32FC1
#define SORT_TYPES SORT_EVERY_ROW | SORT_ASCENDING, SORT_EVERY_ROW | SORT_DESCENDING
#define TYPICAL_MATS_SORT testing::Combine( testing::Values(TYPICAL_MAT_SIZES_SORT), testing::Values(TYPICAL_MAT_TYPES_SORT), testing::Values(SORT_TYPES) )
typedef
tuple
<
Size
,
MatType
,
int
>
sortParams
;
typedef
TestBaseWithParam
<
sortParams
>
sortFixture
;
PERF_TEST_P
(
sortFixture
,
sort
,
TYPICAL_MATS_SORT
)
{
const
sortParams
params
=
GetParam
();
const
Size
sz
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
),
flags
=
get
<
2
>
(
params
);
cv
::
Mat
a
(
sz
,
type
),
b
(
sz
,
type
);
declare
.
in
(
a
,
WARMUP_RNG
).
out
(
b
);
TEST_CYCLE
()
cv
::
sort
(
a
,
b
,
flags
);
SANITY_CHECK
(
b
);
}
modules/core/src/matrix.cpp
View file @
d5513f52
...
...
@@ -3467,6 +3467,30 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
namespace
cv
{
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
typedef
IppStatus
(
CV_STDCALL
*
IppSortFunc
)(
void
*
,
int
);
static
IppSortFunc
getSortFunc
(
int
depth
,
bool
sortDescending
)
{
if
(
!
sortDescending
)
return
depth
==
CV_8U
?
(
IppSortFunc
)
ippsSortAscend_8u_I
:
depth
==
CV_16U
?
(
IppSortFunc
)
ippsSortAscend_16u_I
:
depth
==
CV_16S
?
(
IppSortFunc
)
ippsSortAscend_16s_I
:
depth
==
CV_32S
?
(
IppSortFunc
)
ippsSortAscend_32s_I
:
depth
==
CV_32F
?
(
IppSortFunc
)
ippsSortAscend_32f_I
:
depth
==
CV_64F
?
(
IppSortFunc
)
ippsSortAscend_64f_I
:
0
;
else
return
depth
==
CV_8U
?
(
IppSortFunc
)
ippsSortDescend_8u_I
:
depth
==
CV_16U
?
(
IppSortFunc
)
ippsSortDescend_16u_I
:
depth
==
CV_16S
?
(
IppSortFunc
)
ippsSortDescend_16s_I
:
depth
==
CV_32S
?
(
IppSortFunc
)
ippsSortDescend_32s_I
:
depth
==
CV_32F
?
(
IppSortFunc
)
ippsSortDescend_32f_I
:
depth
==
CV_64F
?
(
IppSortFunc
)
ippsSortDescend_64f_I
:
0
;
}
#endif
template
<
typename
T
>
static
void
sort_
(
const
Mat
&
src
,
Mat
&
dst
,
int
flags
)
{
AutoBuffer
<
T
>
buf
;
...
...
@@ -3485,6 +3509,10 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
}
bptr
=
(
T
*
)
buf
;
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
IppSortFunc
ippFunc
=
getSortFunc
(
src
.
depth
(),
sortDescending
);
#endif
for
(
i
=
0
;
i
<
n
;
i
++
)
{
T
*
ptr
=
bptr
;
...
...
@@ -3494,8 +3522,7 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
if
(
!
inplace
)
{
const
T
*
sptr
=
(
const
T
*
)(
src
.
data
+
src
.
step
*
i
);
for
(
j
=
0
;
j
<
len
;
j
++
)
dptr
[
j
]
=
sptr
[
j
];
memcpy
(
dptr
,
sptr
,
sizeof
(
T
)
*
len
);
}
ptr
=
dptr
;
}
...
...
@@ -3504,10 +3531,17 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
for
(
j
=
0
;
j
<
len
;
j
++
)
ptr
[
j
]
=
((
const
T
*
)(
src
.
data
+
src
.
step
*
j
))[
i
];
}
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
if
(
!
ippFunc
||
ippFunc
(
ptr
,
len
)
<
0
)
#endif
{
std
::
sort
(
ptr
,
ptr
+
len
);
if
(
sortDescending
)
for
(
j
=
0
;
j
<
len
/
2
;
j
++
)
std
::
swap
(
ptr
[
j
],
ptr
[
len
-
1
-
j
]);
}
if
(
!
sortRows
)
for
(
j
=
0
;
j
<
len
;
j
++
)
((
T
*
)(
dst
.
data
+
dst
.
step
*
j
))[
i
]
=
ptr
[
j
];
...
...
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