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
26e8c621
Commit
26e8c621
authored
Apr 15, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cv:;sortIdx
parent
d5513f52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
4 deletions
+57
-4
perf_sort.cpp
modules/core/perf/perf_sort.cpp
+20
-0
matrix.cpp
modules/core/src/matrix.cpp
+37
-4
No files found.
modules/core/perf/perf_sort.cpp
View file @
26e8c621
...
...
@@ -30,3 +30,23 @@ PERF_TEST_P(sortFixture, sort, TYPICAL_MATS_SORT)
SANITY_CHECK
(
b
);
}
typedef
sortFixture
sortIdxFixture
;
#undef SORT_TYPES
#define SORT_TYPES SORT_EVERY_COLUMN | SORT_ASCENDING, SORT_EVERY_COLUMN | SORT_DESCENDING
PERF_TEST_P
(
sortIdxFixture
,
sorIdx
,
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
::
sortIdx
(
a
,
b
,
flags
);
SANITY_CHECK
(
b
);
}
modules/core/src/matrix.cpp
View file @
26e8c621
...
...
@@ -3556,7 +3556,29 @@ public:
const
_Tp
*
arr
;
};
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
typedef
IppStatus
(
CV_STDCALL
*
IppSortIndexFunc
)(
void
*
,
int
*
,
int
);
static
IppSortIndexFunc
getSortIndexFunc
(
int
depth
,
bool
sortDescending
)
{
if
(
!
sortDescending
)
return
depth
==
CV_8U
?
(
IppSortIndexFunc
)
ippsSortIndexAscend_8u_I
:
depth
==
CV_16U
?
(
IppSortIndexFunc
)
ippsSortIndexAscend_16u_I
:
depth
==
CV_16S
?
(
IppSortIndexFunc
)
ippsSortIndexAscend_16s_I
:
depth
==
CV_32S
?
(
IppSortIndexFunc
)
ippsSortIndexAscend_32s_I
:
depth
==
CV_32F
?
(
IppSortIndexFunc
)
ippsSortIndexAscend_32f_I
:
depth
==
CV_64F
?
(
IppSortIndexFunc
)
ippsSortIndexAscend_64f_I
:
0
;
else
return
depth
==
CV_8U
?
(
IppSortIndexFunc
)
ippsSortIndexDescend_8u_I
:
depth
==
CV_16U
?
(
IppSortIndexFunc
)
ippsSortIndexDescend_16u_I
:
depth
==
CV_16S
?
(
IppSortIndexFunc
)
ippsSortIndexDescend_16s_I
:
depth
==
CV_32S
?
(
IppSortIndexFunc
)
ippsSortIndexDescend_32s_I
:
depth
==
CV_32F
?
(
IppSortIndexFunc
)
ippsSortIndexDescend_32f_I
:
depth
==
CV_64F
?
(
IppSortIndexFunc
)
ippsSortIndexDescend_64f_I
:
0
;
}
#endif
template
<
typename
T
>
static
void
sortIdx_
(
const
Mat
&
src
,
Mat
&
dst
,
int
flags
)
{
...
...
@@ -3581,6 +3603,10 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
bptr
=
(
T
*
)
buf
;
_iptr
=
(
int
*
)
ibuf
;
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
IppSortIndexFunc
ippFunc
=
getSortIndexFunc
(
src
.
depth
(),
sortDescending
);
#endif
for
(
i
=
0
;
i
<
n
;
i
++
)
{
T
*
ptr
=
bptr
;
...
...
@@ -3598,10 +3624,17 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
}
for
(
j
=
0
;
j
<
len
;
j
++
)
iptr
[
j
]
=
j
;
std
::
sort
(
iptr
,
iptr
+
len
,
LessThanIdx
<
T
>
(
ptr
)
);
if
(
sortDescending
)
for
(
j
=
0
;
j
<
len
/
2
;
j
++
)
std
::
swap
(
iptr
[
j
],
iptr
[
len
-
1
-
j
]);
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
if
(
sortRows
||
!
ippFunc
||
ippFunc
(
ptr
,
iptr
,
len
)
<
0
)
#endif
{
std
::
sort
(
iptr
,
iptr
+
len
,
LessThanIdx
<
T
>
(
ptr
)
);
if
(
sortDescending
)
for
(
j
=
0
;
j
<
len
/
2
;
j
++
)
std
::
swap
(
iptr
[
j
],
iptr
[
len
-
1
-
j
]);
}
if
(
!
sortRows
)
for
(
j
=
0
;
j
<
len
;
j
++
)
((
int
*
)(
dst
.
data
+
dst
.
step
*
j
))[
i
]
=
iptr
[
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