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
28242f09
Commit
28242f09
authored
Nov 27, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Nov 27, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1869 from ilya-lavrenov:ocl_cvtColor_master
parents
96a228fd
90d62cac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
321 additions
and
22 deletions
+321
-22
color.cpp
modules/imgproc/src/color.cpp
+3
-5
cvtcolor.cl
modules/imgproc/src/opencl/cvtcolor.cl
+17
-17
test_color.cpp
modules/imgproc/test/ocl/test_color.cpp
+301
-0
No files found.
modules/imgproc/src/color.cpp
View file @
28242f09
...
@@ -2691,7 +2691,7 @@ struct mRGBA2RGBA
...
@@ -2691,7 +2691,7 @@ struct mRGBA2RGBA
static
bool
ocl_cvtColor
(
InputArray
_src
,
OutputArray
_dst
,
int
code
,
int
dcn
)
static
bool
ocl_cvtColor
(
InputArray
_src
,
OutputArray
_dst
,
int
code
,
int
dcn
)
{
{
bool
ok
=
tru
e
;
bool
ok
=
fals
e
;
UMat
src
=
_src
.
getUMat
(),
dst
;
UMat
src
=
_src
.
getUMat
(),
dst
;
Size
sz
=
src
.
size
(),
dstSz
=
sz
;
Size
sz
=
src
.
size
(),
dstSz
=
sz
;
int
scn
=
src
.
channels
(),
depth
=
src
.
depth
(),
bidx
;
int
scn
=
src
.
channels
(),
depth
=
src
.
depth
(),
bidx
;
...
@@ -2729,7 +2729,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
...
@@ -2729,7 +2729,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
CV_Assert
(
scn
==
1
);
CV_Assert
(
scn
==
1
);
dcn
=
code
==
COLOR_GRAY2BGRA
?
4
:
3
;
dcn
=
code
==
COLOR_GRAY2BGRA
?
4
:
3
;
k
.
create
(
"Gray2RGB"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
k
.
create
(
"Gray2RGB"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
format
(
"-D depth=%d -D scn=1 -D dcn=%d"
,
depth
,
dcn
));
format
(
"-D depth=%d -D
bidx=0 -D
scn=1 -D dcn=%d"
,
depth
,
dcn
));
break
;
break
;
}
}
case
COLOR_BGR2YUV
:
case
COLOR_BGR2YUV
:
...
@@ -2763,9 +2763,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
...
@@ -2763,9 +2763,7 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
bidx
=
code
==
COLOR_YUV2BGRA_NV12
||
code
==
COLOR_YUV2BGR_NV12
?
0
:
2
;
bidx
=
code
==
COLOR_YUV2BGRA_NV12
||
code
==
COLOR_YUV2BGR_NV12
?
0
:
2
;
dstSz
=
Size
(
sz
.
width
,
sz
.
height
*
2
/
3
);
dstSz
=
Size
(
sz
.
width
,
sz
.
height
*
2
/
3
);
globalsize
[
0
]
=
dstSz
.
height
/
2
;
k
.
create
(
"YUV2RGB_NV12"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
globalsize
[
1
]
=
dstSz
.
width
/
2
;
k
.
create
(
"YUV2RGBA_NV12"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
format
(
"-D depth=0 -D scn=1 -D dcn=%d -D bidx=%d"
,
dcn
,
bidx
));
format
(
"-D depth=0 -D scn=1 -D dcn=%d -D bidx=%d"
,
dcn
,
bidx
));
break
;
break
;
}
}
...
...
modules/imgproc/src/opencl/cvtcolor.cl
View file @
28242f09
...
@@ -208,19 +208,19 @@ __constant int ITUR_BT_601_CVG = 852492;
...
@@ -208,19 +208,19 @@ __constant int ITUR_BT_601_CVG = 852492;
__constant
int
ITUR_BT_601_CVR
=
1673527
;
__constant
int
ITUR_BT_601_CVR
=
1673527
;
__constant
int
ITUR_BT_601_SHIFT
=
20
;
__constant
int
ITUR_BT_601_SHIFT
=
20
;
__kernel
void
YUV2RGB
A
_NV12
(
__global
const
uchar*
srcptr,
int
srcstep,
int
srcoffset,
__kernel
void
YUV2RGB_NV12
(
__global
const
uchar*
srcptr,
int
srcstep,
int
srcoffset,
__global
uchar*
dstptr,
int
dststep,
int
dstoffset,
__global
uchar*
dstptr,
int
dststep,
int
dstoffset,
int
rows,
int
cols
)
int
rows,
int
cols
)
{
{
const
int
x
=
get_global_id
(
0
)
; // max_x = width / 2
int
x
=
get_global_id
(
0
)
;
const
int
y
=
get_global_id
(
1
)
; // max_y = height/ 2
int
y
=
get_global_id
(
1
)
;
if
(
y
<
rows
/
2
&&
x
<
cols
/
2
)
if
(
y
<
rows
/
2
&&
x
<
cols
/
2
)
{
{
__global
const
uchar*
ysrc
=
(
__global
const
uchar*
)(
srcptr
+
mad24
(
y
<<
1
,
srcstep,
(
x
<<
1
)
+
srcoffset
)
)
;
__global
const
uchar*
ysrc
=
srcptr
+
mad24
(
y
<<
1
,
srcstep,
(
x
<<
1
)
+
srcoffset
)
;
__global
const
uchar*
usrc
=
(
__global
const
uchar*
)(
srcptr
+
mad24
(
rows
+
y,
srcstep,
(
x
<<
1
)
+
srcoffset
)
)
;
__global
const
uchar*
usrc
=
srcptr
+
mad24
(
rows
+
y,
srcstep,
(
x
<<
1
)
+
srcoffset
)
;
__global
uchar*
dst1
=
(
__global
uchar*
)(
dstptr
+
mad24
(
y
<<
1
,
dststep,
x*
(
dcn*2
)
+
dstoffset
)
)
;
__global
uchar*
dst1
=
dstptr
+
mad24
(
y
<<
1
,
dststep,
x
*
(
dcn<<1
)
+
dstoffset
)
;
__global
uchar*
dst2
=
(
__global
uchar*
)(
dstptr
+
mad24
((
y
<<
1
)
+
1
,
dststep,
x*
(
dcn*2
)
+
dstoffset
)
)
;
__global
uchar*
dst2
=
dstptr
+
mad24
((
y
<<
1
)
+
1
,
dststep,
x
*
(
dcn<<1
)
+
dstoffset
)
;
int
Y1
=
ysrc[0]
;
int
Y1
=
ysrc[0]
;
int
Y2
=
ysrc[1]
;
int
Y2
=
ysrc[1]
;
...
@@ -243,7 +243,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
...
@@ -243,7 +243,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
#
endif
#
endif
Y2
=
max
(
0
,
Y2
-
16
)
*
ITUR_BT_601_CY
;
Y2
=
max
(
0
,
Y2
-
16
)
*
ITUR_BT_601_CY
;
dst1[
(
dcn
+
2
)
-
bidx]
=
convert_uchar_sat
((
Y2
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[
dcn
+
2
-
bidx]
=
convert_uchar_sat
((
Y2
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[dcn
+
1]
=
convert_uchar_sat
((
Y2
+
guv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[dcn
+
1]
=
convert_uchar_sat
((
Y2
+
guv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[dcn
+
bidx]
=
convert_uchar_sat
((
Y2
+
buv
)
>>
ITUR_BT_601_SHIFT
)
;
dst1[dcn
+
bidx]
=
convert_uchar_sat
((
Y2
+
buv
)
>>
ITUR_BT_601_SHIFT
)
;
#
if
dcn
==
4
#
if
dcn
==
4
...
@@ -259,7 +259,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
...
@@ -259,7 +259,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
#
endif
#
endif
Y4
=
max
(
0
,
Y4
-
16
)
*
ITUR_BT_601_CY
;
Y4
=
max
(
0
,
Y4
-
16
)
*
ITUR_BT_601_CY
;
dst2[
(
dcn
+
2
)
-
bidx]
=
convert_uchar_sat
((
Y4
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[
dcn
+
2
-
bidx]
=
convert_uchar_sat
((
Y4
+
ruv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[dcn
+
1]
=
convert_uchar_sat
((
Y4
+
guv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[dcn
+
1]
=
convert_uchar_sat
((
Y4
+
guv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[dcn
+
bidx]
=
convert_uchar_sat
((
Y4
+
buv
)
>>
ITUR_BT_601_SHIFT
)
;
dst2[dcn
+
bidx]
=
convert_uchar_sat
((
Y4
+
buv
)
>>
ITUR_BT_601_SHIFT
)
;
#
if
dcn
==
4
#
if
dcn
==
4
...
@@ -268,7 +268,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
...
@@ -268,7 +268,7 @@ __kernel void YUV2RGBA_NV12(__global const uchar* srcptr, int srcstep, int srcof
}
}
}
}
/////////////////////////////////////
RGB
<->
YUV
//////////////////////////////////////
/////////////////////////////////////
RGB
->
YCrCb
//////////////////////////////////////
__constant
float
c_RGB2YCrCbCoeffs_f[5]
=
{0.299f,
0.587f,
0.114f,
0.713f,
0.564f}
;
__constant
float
c_RGB2YCrCbCoeffs_f[5]
=
{0.299f,
0.587f,
0.114f,
0.713f,
0.564f}
;
__constant
int
c_RGB2YCrCbCoeffs_i[5]
=
{R2Y,
G2Y,
B2Y,
11682
,
9241}
;
__constant
int
c_RGB2YCrCbCoeffs_i[5]
=
{R2Y,
G2Y,
B2Y,
11682
,
9241}
;
...
@@ -288,15 +288,15 @@ __kernel void RGB2YCrCb(__global const uchar* srcptr, int srcstep, int srcoffset
...
@@ -288,15 +288,15 @@ __kernel void RGB2YCrCb(__global const uchar* srcptr, int srcstep, int srcoffset
#
ifdef
DEPTH_5
#
ifdef
DEPTH_5
__constant
float
*
coeffs
=
c_RGB2YCrCbCoeffs_f
;
__constant
float
*
coeffs
=
c_RGB2YCrCbCoeffs_f
;
const
DATA_TYPE
Y
=
b
*
coeffs[0]
+
g
*
coeffs[1]
+
r
*
coeffs[2
]
;
DATA_TYPE
Y
=
b
*
coeffs[2]
+
g
*
coeffs[1]
+
r
*
coeffs[0
]
;
const
DATA_TYPE
Cr
=
(
r
-
Y
)
*
coeffs[3]
+
HALF_MAX
;
DATA_TYPE
Cr
=
(
r
-
Y
)
*
coeffs[3]
+
HALF_MAX
;
const
DATA_TYPE
Cb
=
(
b
-
Y
)
*
coeffs[4]
+
HALF_MAX
;
DATA_TYPE
Cb
=
(
b
-
Y
)
*
coeffs[4]
+
HALF_MAX
;
#
else
#
else
__constant
int
*
coeffs
=
c_RGB2YCrCbCoeffs_i
;
__constant
int
*
coeffs
=
c_RGB2YCrCbCoeffs_i
;
const
int
delta
=
HALF_MAX
*
(
1
<<
yuv_shift
)
;
int
delta
=
HALF_MAX
*
(
1
<<
yuv_shift
)
;
const
int
Y
=
CV_DESCALE
(
b
*
coeffs[0]
+
g
*
coeffs[1]
+
r
*
coeffs[2
],
yuv_shift
)
;
int
Y
=
CV_DESCALE
(
b
*
coeffs[2]
+
g
*
coeffs[1]
+
r
*
coeffs[0
],
yuv_shift
)
;
const
int
Cr
=
CV_DESCALE
((
r
-
Y
)
*
coeffs[3]
+
delta,
yuv_shift
)
;
int
Cr
=
CV_DESCALE
((
r
-
Y
)
*
coeffs[3]
+
delta,
yuv_shift
)
;
const
int
Cb
=
CV_DESCALE
((
b
-
Y
)
*
coeffs[4]
+
delta,
yuv_shift
)
;
int
Cb
=
CV_DESCALE
((
b
-
Y
)
*
coeffs[4]
+
delta,
yuv_shift
)
;
#
endif
#
endif
dst[0]
=
SAT_CAST
(
Y
)
;
dst[0]
=
SAT_CAST
(
Y
)
;
...
...
modules/imgproc/test/ocl/test_color.cpp
0 → 100644
View file @
28242f09
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Peng Xiao, pengxiao@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "test_precomp.hpp"
#include "cvconfig.h"
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
namespace
cvtest
{
namespace
ocl
{
///////////////////////////////////////////////////////////////////////////////////////////////////////
// cvtColor
PARAM_TEST_CASE
(
CvtColor
,
MatDepth
,
bool
)
{
int
depth
;
bool
use_roi
;
TEST_DECLARE_INPUT_PARATEMER
(
src
)
TEST_DECLARE_OUTPUT_PARATEMER
(
dst
)
virtual
void
SetUp
()
{
depth
=
GET_PARAM
(
0
);
use_roi
=
GET_PARAM
(
1
);
}
virtual
void
generateTestData
(
int
channelsIn
,
int
channelsOut
)
{
const
int
srcType
=
CV_MAKE_TYPE
(
depth
,
channelsIn
);
const
int
dstType
=
CV_MAKE_TYPE
(
depth
,
channelsOut
);
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src
,
src_roi
,
roiSize
,
srcBorder
,
srcType
,
2
,
100
);
Border
dstBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
dst
,
dst_roi
,
roiSize
,
dstBorder
,
dstType
,
5
,
16
);
UMAT_UPLOAD_INPUT_PARAMETER
(
src
)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
dst
)
}
void
Near
(
double
threshold
)
{
EXPECT_MAT_NEAR
(
dst_roi
,
udst_roi
,
threshold
);
EXPECT_MAT_NEAR
(
dst
,
udst
,
threshold
);
}
void
performTest
(
int
channelsIn
,
int
channelsOut
,
int
code
,
double
threshold
=
1e-3
)
{
for
(
int
j
=
0
;
j
<
test_loop_times
;
j
++
)
{
generateTestData
(
channelsIn
,
channelsOut
);
OCL_OFF
(
cv
::
cvtColor
(
src_roi
,
dst_roi
,
code
,
channelsOut
));
OCL_ON
(
cv
::
cvtColor
(
usrc_roi
,
udst_roi
,
code
,
channelsOut
));
Near
(
threshold
);
}
}
};
#define CVTCODE(name) COLOR_ ## name
// RGB[A] <-> BGR[A]
//OCL_TEST_P(CvtColor, BGR2BGRA) { performTest(3, 4, CVTCODE(BGR2BGRA)); }
//OCL_TEST_P(CvtColor, RGB2RGBA) { performTest(3, 4, CVTCODE(RGB2RGBA)); }
//OCL_TEST_P(CvtColor, BGRA2BGR) { performTest(4, 3, CVTCODE(BGRA2BGR)); }
//OCL_TEST_P(CvtColor, RGBA2RGB) { performTest(4, 3, CVTCODE(RGBA2RGB)); }
//OCL_TEST_P(CvtColor, BGR2RGBA) { performTest(3, 4, CVTCODE(BGR2RGBA)); }
//OCL_TEST_P(CvtColor, RGB2BGRA) { performTest(3, 4, CVTCODE(RGB2BGRA)); }
//OCL_TEST_P(CvtColor, RGBA2BGR) { performTest(4, 3, CVTCODE(RGBA2BGR)); }
//OCL_TEST_P(CvtColor, BGRA2RGB) { performTest(4, 3, CVTCODE(BGRA2RGB)); }
//OCL_TEST_P(CvtColor, BGR2RGB) { performTest(3, 3, CVTCODE(BGR2RGB)); }
//OCL_TEST_P(CvtColor, RGB2BGR) { performTest(3, 3, CVTCODE(RGB2BGR)); }
//OCL_TEST_P(CvtColor, BGRA2RGBA) { performTest(4, 4, CVTCODE(BGRA2RGBA)); }
//OCL_TEST_P(CvtColor, RGBA2BGRA) { performTest(4, 4, CVTCODE(RGBA2BGRA)); }
// RGB <-> Gray
OCL_TEST_P
(
CvtColor
,
RGB2GRAY
)
{
performTest
(
3
,
1
,
CVTCODE
(
RGB2GRAY
));
}
OCL_TEST_P
(
CvtColor
,
GRAY2RGB
)
{
performTest
(
1
,
3
,
CVTCODE
(
GRAY2RGB
));
}
OCL_TEST_P
(
CvtColor
,
BGR2GRAY
)
{
performTest
(
3
,
1
,
CVTCODE
(
BGR2GRAY
));
}
OCL_TEST_P
(
CvtColor
,
GRAY2BGR
)
{
performTest
(
1
,
3
,
CVTCODE
(
GRAY2BGR
));
}
OCL_TEST_P
(
CvtColor
,
RGBA2GRAY
)
{
performTest
(
4
,
1
,
CVTCODE
(
RGBA2GRAY
));
}
OCL_TEST_P
(
CvtColor
,
GRAY2RGBA
)
{
performTest
(
1
,
4
,
CVTCODE
(
GRAY2RGBA
));
}
OCL_TEST_P
(
CvtColor
,
BGRA2GRAY
)
{
performTest
(
4
,
1
,
CVTCODE
(
BGRA2GRAY
));
}
OCL_TEST_P
(
CvtColor
,
GRAY2BGRA
)
{
performTest
(
1
,
4
,
CVTCODE
(
GRAY2BGRA
));
}
// RGB <-> YUV
OCL_TEST_P
(
CvtColor
,
RGB2YUV
)
{
performTest
(
3
,
3
,
CVTCODE
(
RGB2YUV
));
}
OCL_TEST_P
(
CvtColor
,
BGR2YUV
)
{
performTest
(
3
,
3
,
CVTCODE
(
BGR2YUV
));
}
OCL_TEST_P
(
CvtColor
,
RGBA2YUV
)
{
performTest
(
4
,
3
,
CVTCODE
(
RGB2YUV
));
}
OCL_TEST_P
(
CvtColor
,
BGRA2YUV
)
{
performTest
(
4
,
3
,
CVTCODE
(
BGR2YUV
));
}
OCL_TEST_P
(
CvtColor
,
YUV2RGB
)
{
performTest
(
3
,
3
,
CVTCODE
(
YUV2RGB
));
}
OCL_TEST_P
(
CvtColor
,
YUV2BGR
)
{
performTest
(
3
,
3
,
CVTCODE
(
YUV2BGR
));
}
OCL_TEST_P
(
CvtColor
,
YUV2RGBA
)
{
performTest
(
3
,
4
,
CVTCODE
(
YUV2RGB
));
}
OCL_TEST_P
(
CvtColor
,
YUV2BGRA
)
{
performTest
(
3
,
4
,
CVTCODE
(
YUV2BGR
));
}
// RGB <-> YCrCb
OCL_TEST_P
(
CvtColor
,
RGB2YCrCb
)
{
performTest
(
3
,
3
,
CVTCODE
(
RGB2YCrCb
));
}
OCL_TEST_P
(
CvtColor
,
BGR2YCrCb
)
{
performTest
(
3
,
3
,
CVTCODE
(
BGR2YCrCb
));
}
OCL_TEST_P
(
CvtColor
,
RGBA2YCrCb
)
{
performTest
(
4
,
3
,
CVTCODE
(
RGB2YCrCb
));
}
OCL_TEST_P
(
CvtColor
,
BGRA2YCrCb
)
{
performTest
(
4
,
3
,
CVTCODE
(
BGR2YCrCb
));
}
//OCL_TEST_P(CvtColor, YCrCb2RGB) { performTest(3, 3, CVTCODE(YCrCb2RGB)); }
//OCL_TEST_P(CvtColor, YCrCb2BGR) { performTest(3, 3, CVTCODE(YCrCb2BGR)); }
//OCL_TEST_P(CvtColor, YCrCb2RGBA) { performTest(3, 4, CVTCODE(YCrCb2RGB)); }
//OCL_TEST_P(CvtColor, YCrCb2BGRA) { performTest(3, 4, CVTCODE(YCrCb2BGR)); }
// RGB <-> XYZ
//OCL_TEST_P(CvtColor, RGB2XYZ) { performTest(3, 3, CVTCODE(RGB2XYZ)); }
//OCL_TEST_P(CvtColor, BGR2XYZ) { performTest(3, 3, CVTCODE(BGR2XYZ)); }
//OCL_TEST_P(CvtColor, RGBA2XYZ) { performTest(4, 3, CVTCODE(RGB2XYZ)); }
//OCL_TEST_P(CvtColor, BGRA2XYZ) { performTest(4, 3, CVTCODE(BGR2XYZ)); }
//OCL_TEST_P(CvtColor, XYZ2RGB) { performTest(3, 3, CVTCODE(XYZ2RGB)); }
//OCL_TEST_P(CvtColor, XYZ2BGR) { performTest(3, 3, CVTCODE(XYZ2BGR)); }
//OCL_TEST_P(CvtColor, XYZ2RGBA) { performTest(3, 4, CVTCODE(XYZ2RGB)); }
//OCL_TEST_P(CvtColor, XYZ2BGRA) { performTest(3, 4, CVTCODE(XYZ2BGR)); }
// RGB <-> HSV
//typedef CvtColor CvtColor8u32f;
//OCL_TEST_P(CvtColor8u32f, RGB2HSV) { performTest(3, 3, CVTCODE(RGB2HSV)); }
//OCL_TEST_P(CvtColor8u32f, BGR2HSV) { performTest(3, 3, CVTCODE(BGR2HSV)); }
//OCL_TEST_P(CvtColor8u32f, RGBA2HSV) { performTest(4, 3, CVTCODE(RGB2HSV)); }
//OCL_TEST_P(CvtColor8u32f, BGRA2HSV) { performTest(4, 3, CVTCODE(BGR2HSV)); }
//OCL_TEST_P(CvtColor8u32f, RGB2HSV_FULL) { performTest(3, 3, CVTCODE(RGB2HSV_FULL)); }
//OCL_TEST_P(CvtColor8u32f, BGR2HSV_FULL) { performTest(3, 3, CVTCODE(BGR2HSV_FULL)); }
//OCL_TEST_P(CvtColor8u32f, RGBA2HSV_FULL) { performTest(4, 3, CVTCODE(RGB2HSV_FULL)); }
//OCL_TEST_P(CvtColor8u32f, BGRA2HSV_FULL) { performTest(4, 3, CVTCODE(BGR2HSV_FULL)); }
//OCL_TEST_P(CvtColor8u32f, HSV2RGB) { performTest(3, 3, CVTCODE(HSV2RGB), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2BGR) { performTest(3, 3, CVTCODE(HSV2BGR), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2RGBA) { performTest(3, 4, CVTCODE(HSV2RGB), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2BGRA) { performTest(3, 4, CVTCODE(HSV2BGR), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2RGB_FULL) { performTest(3, 3, CVTCODE(HSV2RGB_FULL), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2BGR_FULL) { performTest(3, 3, CVTCODE(HSV2BGR_FULL), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2RGBA_FULL) { performTest(3, 4, CVTCODE(HSV2BGR_FULL), depth == CV_8U ? 1 : 4e-1); }
//OCL_TEST_P(CvtColor8u32f, HSV2BGRA_FULL) { performTest(3, 4, CVTCODE(HSV2BGR_FULL), depth == CV_8U ? 1 : 4e-1); }
// RGB <-> HLS
//OCL_TEST_P(CvtColor8u32f, RGB2HLS) { performTest(3, 3, CVTCODE(RGB2HLS), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, BGR2HLS) { performTest(3, 3, CVTCODE(BGR2HLS), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, RGBA2HLS) { performTest(4, 3, CVTCODE(RGB2HLS), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, BGRA2HLS) { performTest(4, 3, CVTCODE(BGR2HLS), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, RGB2HLS_FULL) { performTest(3, 3, CVTCODE(RGB2HLS_FULL), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, BGR2HLS_FULL) { performTest(3, 3, CVTCODE(BGR2HLS_FULL), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, RGBA2HLS_FULL) { performTest(4, 3, CVTCODE(RGB2HLS_FULL), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, BGRA2HLS_FULL) { performTest(4, 3, CVTCODE(BGR2HLS_FULL), depth == CV_8U ? 1 : 1e-3); }
//OCL_TEST_P(CvtColor8u32f, HLS2RGB) { performTest(3, 3, CVTCODE(HLS2RGB), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2BGR) { performTest(3, 3, CVTCODE(HLS2BGR), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2RGBA) { performTest(3, 4, CVTCODE(HLS2RGB), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2BGRA) { performTest(3, 4, CVTCODE(HLS2BGR), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2RGB_FULL) { performTest(3, 3, CVTCODE(HLS2RGB_FULL), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2BGR_FULL) { performTest(3, 3, CVTCODE(HLS2BGR_FULL), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2RGBA_FULL) { performTest(3, 4, CVTCODE(HLS2RGB_FULL), 1); }
//OCL_TEST_P(CvtColor8u32f, HLS2BGRA_FULL) { performTest(3, 4, CVTCODE(HLS2BGR_FULL), 1); }
// RGB5x5 <-> RGB
//typedef CvtColor CvtColor8u;
//OCL_TEST_P(CvtColor8u, BGR5652BGR) { performTest(2, 3, CVTCODE(BGR5652BGR)); }
//OCL_TEST_P(CvtColor8u, BGR5652RGB) { performTest(2, 3, CVTCODE(BGR5652RGB)); }
//OCL_TEST_P(CvtColor8u, BGR5652BGRA) { performTest(2, 4, CVTCODE(BGR5652BGRA)); }
//OCL_TEST_P(CvtColor8u, BGR5652RGBA) { performTest(2, 4, CVTCODE(BGR5652RGBA)); }
//OCL_TEST_P(CvtColor8u, BGR5552BGR) { performTest(2, 3, CVTCODE(BGR5552BGR)); }
//OCL_TEST_P(CvtColor8u, BGR5552RGB) { performTest(2, 3, CVTCODE(BGR5552RGB)); }
//OCL_TEST_P(CvtColor8u, BGR5552BGRA) { performTest(2, 4, CVTCODE(BGR5552BGRA)); }
//OCL_TEST_P(CvtColor8u, BGR5552RGBA) { performTest(2, 4, CVTCODE(BGR5552RGBA)); }
//OCL_TEST_P(CvtColor8u, BGR2BGR565) { performTest(3, 2, CVTCODE(BGR2BGR565)); }
//OCL_TEST_P(CvtColor8u, RGB2BGR565) { performTest(3, 2, CVTCODE(RGB2BGR565)); }
//OCL_TEST_P(CvtColor8u, BGRA2BGR565) { performTest(4, 2, CVTCODE(BGRA2BGR565)); }
//OCL_TEST_P(CvtColor8u, RGBA2BGR565) { performTest(4, 2, CVTCODE(RGBA2BGR565)); }
//OCL_TEST_P(CvtColor8u, BGR2BGR555) { performTest(3, 2, CVTCODE(BGR2BGR555)); }
//OCL_TEST_P(CvtColor8u, RGB2BGR555) { performTest(3, 2, CVTCODE(RGB2BGR555)); }
//OCL_TEST_P(CvtColor8u, BGRA2BGR555) { performTest(4, 2, CVTCODE(BGRA2BGR555)); }
//OCL_TEST_P(CvtColor8u, RGBA2BGR555) { performTest(4, 2, CVTCODE(RGBA2BGR555)); }
// RGB5x5 <-> Gray
//OCL_TEST_P(CvtColor8u, BGR5652GRAY) { performTest(2, 1, CVTCODE(BGR5652GRAY)); }
//OCL_TEST_P(CvtColor8u, BGR5552GRAY) { performTest(2, 1, CVTCODE(BGR5552GRAY)); }
//OCL_TEST_P(CvtColor8u, GRAY2BGR565) { performTest(1, 2, CVTCODE(GRAY2BGR565)); }
//OCL_TEST_P(CvtColor8u, GRAY2BGR555) { performTest(1, 2, CVTCODE(GRAY2BGR555)); }
// RGBA <-> mRGBA
//OCL_TEST_P(CvtColor8u, RGBA2mRGBA) { performTest(4, 4, CVTCODE(RGBA2mRGBA)); }
//OCL_TEST_P(CvtColor8u, mRGBA2RGBA) { performTest(4, 4, CVTCODE(mRGBA2RGBA)); }
// YUV -> RGBA_NV12
struct
CvtColor_YUV420
:
public
CvtColor
{
void
generateTestData
(
int
channelsIn
,
int
channelsOut
)
{
const
int
srcType
=
CV_MAKE_TYPE
(
depth
,
channelsIn
);
const
int
dstType
=
CV_MAKE_TYPE
(
depth
,
channelsOut
);
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
roiSize
.
width
*=
2
;
roiSize
.
height
*=
3
;
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src
,
src_roi
,
roiSize
,
srcBorder
,
srcType
,
2
,
100
);
Border
dstBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
dst
,
dst_roi
,
roiSize
,
dstBorder
,
dstType
,
5
,
16
);
UMAT_UPLOAD_INPUT_PARAMETER
(
src
)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
dst
)
}
};
OCL_TEST_P
(
CvtColor_YUV420
,
YUV2RGBA_NV12
)
{
performTest
(
1
,
4
,
COLOR_YUV2RGBA_NV12
);
}
OCL_TEST_P
(
CvtColor_YUV420
,
YUV2BGRA_NV12
)
{
performTest
(
1
,
4
,
COLOR_YUV2BGRA_NV12
);
}
OCL_TEST_P
(
CvtColor_YUV420
,
YUV2RGB_NV12
)
{
performTest
(
1
,
3
,
COLOR_YUV2RGB_NV12
);
}
OCL_TEST_P
(
CvtColor_YUV420
,
YUV2BGR_NV12
)
{
performTest
(
1
,
3
,
COLOR_YUV2BGR_NV12
);
}
//OCL_INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor8u,
// testing::Combine(testing::Values(MatDepth(CV_8U)), Bool()));
//OCL_INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor8u32f,
// testing::Combine(testing::Values(MatDepth(CV_8U), MatDepth(CV_32F)), Bool()));
OCL_INSTANTIATE_TEST_CASE_P
(
ImgProc
,
CvtColor
,
testing
::
Combine
(
testing
::
Values
(
MatDepth
(
CV_8U
),
MatDepth
(
CV_16U
),
MatDepth
(
CV_32F
)),
Bool
()));
OCL_INSTANTIATE_TEST_CASE_P
(
ImgProc
,
CvtColor_YUV420
,
testing
::
Combine
(
testing
::
Values
(
MatDepth
(
CV_8U
)),
Bool
()));
}
}
// namespace cvtest::ocl
#endif
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