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
a509819b
Commit
a509819b
authored
Jan 20, 2014
by
Roman Donchenko
Committed by
OpenCV Buildbot
Jan 20, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2163 from ilya-lavrenov:tapi_channels
parents
9710b25c
5d18cf99
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
168 additions
and
6 deletions
+168
-6
perf_channels.cpp
modules/core/perf/opencl/perf_channels.cpp
+44
-0
convert.cpp
modules/core/src/convert.cpp
+27
-6
test_channels.cpp
modules/core/test/ocl/test_channels.cpp
+94
-0
ts_perf.hpp
modules/ts/include/opencv2/ts/ts_perf.hpp
+3
-0
No files found.
modules/core/perf/opencl/perf_channels.cpp
View file @
a509819b
...
@@ -154,6 +154,50 @@ OCL_PERF_TEST_P(MixChannelsFixture, MixChannels,
...
@@ -154,6 +154,50 @@ OCL_PERF_TEST_P(MixChannelsFixture, MixChannels,
SANITY_CHECK
(
dst1
);
SANITY_CHECK
(
dst1
);
}
}
///////////// InsertChannel ////////////////////////
typedef
Size_MatDepth
InsertChannelFixture
;
OCL_PERF_TEST_P
(
InsertChannelFixture
,
InsertChannel
,
::
testing
::
Combine
(
Values
(
OCL_SIZE_1
,
OCL_SIZE_2
,
OCL_SIZE_3
),
OCL_PERF_ENUM
(
CV_8U
,
CV_32F
)))
{
const
Size_MatDepth_t
params
=
GetParam
();
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
depth
=
get
<
1
>
(
params
),
type
=
CV_MAKE_TYPE
(
depth
,
3
);
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
UMat
src
(
srcSize
,
depth
),
dst
(
srcSize
,
type
,
Scalar
::
all
(
17
));
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
OCL_TEST_CYCLE
()
cv
::
insertChannel
(
src
,
dst
,
1
);
SANITY_CHECK
(
dst
);
}
///////////// ExtractChannel ////////////////////////
typedef
Size_MatDepth
ExtractChannelFixture
;
OCL_PERF_TEST_P
(
ExtractChannelFixture
,
ExtractChannel
,
::
testing
::
Combine
(
Values
(
OCL_SIZE_1
,
OCL_SIZE_2
,
OCL_SIZE_3
),
OCL_PERF_ENUM
(
CV_8U
,
CV_32F
)))
{
const
Size_MatDepth_t
params
=
GetParam
();
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
depth
=
get
<
1
>
(
params
),
type
=
CV_MAKE_TYPE
(
depth
,
3
);
checkDeviceMaxMemoryAllocSize
(
srcSize
,
type
);
UMat
src
(
srcSize
,
type
),
dst
(
srcSize
,
depth
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
OCL_TEST_CYCLE
()
cv
::
extractChannel
(
src
,
dst
,
1
);
SANITY_CHECK
(
dst
);
}
}
}
// namespace cvtest::ocl
}
}
// namespace cvtest::ocl
#endif // HAVE_OPENCL
#endif // HAVE_OPENCL
modules/core/src/convert.cpp
View file @
a509819b
...
@@ -763,20 +763,41 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
...
@@ -763,20 +763,41 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
void
cv
::
extractChannel
(
InputArray
_src
,
OutputArray
_dst
,
int
coi
)
void
cv
::
extractChannel
(
InputArray
_src
,
OutputArray
_dst
,
int
coi
)
{
{
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
CV_Assert
(
0
<=
coi
&&
coi
<
cn
);
int
ch
[]
=
{
coi
,
0
};
if
(
ocl
::
useOpenCL
()
&&
_src
.
dims
()
<=
2
&&
_dst
.
isUMat
())
{
UMat
src
=
_src
.
getUMat
();
_dst
.
create
(
src
.
dims
,
&
src
.
size
[
0
],
depth
);
UMat
dst
=
_dst
.
getUMat
();
mixChannels
(
std
::
vector
<
UMat
>
(
1
,
src
),
std
::
vector
<
UMat
>
(
1
,
dst
),
ch
,
1
);
return
;
}
Mat
src
=
_src
.
getMat
();
Mat
src
=
_src
.
getMat
();
CV_Assert
(
0
<=
coi
&&
coi
<
src
.
channels
()
);
_dst
.
create
(
src
.
dims
,
&
src
.
size
[
0
],
depth
);
_dst
.
create
(
src
.
dims
,
&
src
.
size
[
0
],
src
.
depth
());
Mat
dst
=
_dst
.
getMat
();
Mat
dst
=
_dst
.
getMat
();
int
ch
[]
=
{
coi
,
0
};
mixChannels
(
&
src
,
1
,
&
dst
,
1
,
ch
,
1
);
mixChannels
(
&
src
,
1
,
&
dst
,
1
,
ch
,
1
);
}
}
void
cv
::
insertChannel
(
InputArray
_src
,
InputOutputArray
_dst
,
int
coi
)
void
cv
::
insertChannel
(
InputArray
_src
,
InputOutputArray
_dst
,
int
coi
)
{
{
Mat
src
=
_src
.
getMat
(),
dst
=
_dst
.
getMat
();
int
stype
=
_src
.
type
(),
sdepth
=
CV_MAT_DEPTH
(
stype
),
scn
=
CV_MAT_CN
(
stype
);
CV_Assert
(
src
.
size
==
dst
.
size
&&
src
.
depth
()
==
dst
.
depth
()
);
int
dtype
=
_dst
.
type
(),
ddepth
=
CV_MAT_DEPTH
(
dtype
),
dcn
=
CV_MAT_CN
(
dtype
);
CV_Assert
(
0
<=
coi
&&
coi
<
dst
.
channels
()
&&
src
.
channels
()
==
1
);
CV_Assert
(
_src
.
sameSize
(
_dst
)
&&
sdepth
==
ddepth
);
CV_Assert
(
0
<=
coi
&&
coi
<
dcn
&&
scn
==
1
);
int
ch
[]
=
{
0
,
coi
};
int
ch
[]
=
{
0
,
coi
};
if
(
ocl
::
useOpenCL
()
&&
_src
.
dims
()
<=
2
&&
_dst
.
isUMat
())
{
UMat
src
=
_src
.
getUMat
(),
dst
=
_dst
.
getUMat
();
mixChannels
(
std
::
vector
<
UMat
>
(
1
,
src
),
std
::
vector
<
UMat
>
(
1
,
dst
),
ch
,
1
);
return
;
}
Mat
src
=
_src
.
getMat
(),
dst
=
_dst
.
getMat
();
mixChannels
(
&
src
,
1
,
&
dst
,
1
,
ch
,
1
);
mixChannels
(
&
src
,
1
,
&
dst
,
1
,
ch
,
1
);
}
}
...
...
modules/core/test/ocl/test_
split_merge
.cpp
→
modules/core/test/ocl/test_
channels
.cpp
View file @
a509819b
...
@@ -353,11 +353,105 @@ OCL_TEST_P(MixChannels, Accuracy)
...
@@ -353,11 +353,105 @@ OCL_TEST_P(MixChannels, Accuracy)
}
}
}
}
//////////////////////////////////////// InsertChannel ///////////////////////////////////////////////
PARAM_TEST_CASE
(
InsertChannel
,
MatDepth
,
Channels
,
bool
)
{
int
depth
,
cn
,
coi
;
bool
use_roi
;
TEST_DECLARE_INPUT_PARAMETER
(
src
)
TEST_DECLARE_OUTPUT_PARAMETER
(
dst
)
virtual
void
SetUp
()
{
depth
=
GET_PARAM
(
0
);
cn
=
GET_PARAM
(
1
);
use_roi
=
GET_PARAM
(
2
);
}
void
generateTestData
()
{
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
coi
=
randomInt
(
0
,
cn
);
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src
,
src_roi
,
roiSize
,
srcBorder
,
depth
,
2
,
11
);
Border
dstBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
dst
,
dst_roi
,
roiSize
,
dstBorder
,
CV_MAKE_TYPE
(
depth
,
cn
),
5
,
16
);
UMAT_UPLOAD_INPUT_PARAMETER
(
src
)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
dst
)
}
};
OCL_TEST_P
(
InsertChannel
,
Accuracy
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
insertChannel
(
src_roi
,
dst_roi
,
coi
));
OCL_ON
(
cv
::
insertChannel
(
usrc_roi
,
udst_roi
,
coi
));
OCL_EXPECT_MATS_NEAR
(
dst
,
0
);
}
}
//////////////////////////////////////// ExtractChannel ///////////////////////////////////////////////
PARAM_TEST_CASE
(
ExtractChannel
,
MatDepth
,
Channels
,
bool
)
{
int
depth
,
cn
,
coi
;
bool
use_roi
;
TEST_DECLARE_INPUT_PARAMETER
(
src
)
TEST_DECLARE_OUTPUT_PARAMETER
(
dst
)
virtual
void
SetUp
()
{
depth
=
GET_PARAM
(
0
);
cn
=
GET_PARAM
(
1
);
use_roi
=
GET_PARAM
(
2
);
}
void
generateTestData
()
{
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
coi
=
randomInt
(
0
,
cn
);
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src
,
src_roi
,
roiSize
,
srcBorder
,
CV_MAKE_TYPE
(
depth
,
cn
),
2
,
11
);
Border
dstBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
dst
,
dst_roi
,
roiSize
,
dstBorder
,
depth
,
5
,
16
);
UMAT_UPLOAD_INPUT_PARAMETER
(
src
)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
dst
)
}
};
OCL_TEST_P
(
ExtractChannel
,
Accuracy
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
();
OCL_OFF
(
cv
::
extractChannel
(
src_roi
,
dst_roi
,
coi
));
OCL_ON
(
cv
::
extractChannel
(
usrc_roi
,
udst_roi
,
coi
));
OCL_EXPECT_MATS_NEAR
(
dst
,
0
);
}
}
//////////////////////////////////////// Instantiation ///////////////////////////////////////////////
//////////////////////////////////////// Instantiation ///////////////////////////////////////////////
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
Merge
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
Merge
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
Split
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
Split
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
MixChannels
,
Combine
(
OCL_ALL_DEPTHS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
MixChannels
,
Combine
(
OCL_ALL_DEPTHS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
InsertChannel
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
Channels
,
ExtractChannel
,
Combine
(
OCL_ALL_DEPTHS
,
OCL_ALL_CHANNELS
,
Bool
()));
}
}
// namespace cvtest::ocl
}
}
// namespace cvtest::ocl
...
...
modules/ts/include/opencv2/ts/ts_perf.hpp
View file @
a509819b
...
@@ -379,6 +379,9 @@ template<typename T> class TestBaseWithParam: public TestBase, public ::testing:
...
@@ -379,6 +379,9 @@ template<typename T> class TestBaseWithParam: public TestBase, public ::testing:
typedef
std
::
tr1
::
tuple
<
cv
::
Size
,
MatType
>
Size_MatType_t
;
typedef
std
::
tr1
::
tuple
<
cv
::
Size
,
MatType
>
Size_MatType_t
;
typedef
TestBaseWithParam
<
Size_MatType_t
>
Size_MatType
;
typedef
TestBaseWithParam
<
Size_MatType_t
>
Size_MatType
;
typedef
std
::
tr1
::
tuple
<
cv
::
Size
,
MatDepth
>
Size_MatDepth_t
;
typedef
TestBaseWithParam
<
Size_MatDepth_t
>
Size_MatDepth
;
/*****************************************************************************************\
/*****************************************************************************************\
* Print functions for googletest *
* Print functions for googletest *
\*****************************************************************************************/
\*****************************************************************************************/
...
...
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