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
79d0dc25
Commit
79d0dc25
authored
Jul 30, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added gpu RGB<->Lab and BGR<->Luv conversions
parent
051adcb7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
6 deletions
+95
-6
color.cpp
modules/gpu/src/color.cpp
+28
-4
main.cpp
modules/gpu/test/main.cpp
+0
-2
precomp.hpp
modules/gpu/test/precomp.hpp
+5
-0
test_color.cpp
modules/gpu/test/test_color.cpp
+62
-0
No files found.
modules/gpu/src/color.cpp
View file @
79d0dc25
...
...
@@ -1170,6 +1170,12 @@ namespace
#endif
}
void
rgb_to_lab
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
,
Stream
&
stream
)
{
bgr_to_rgb
(
src
,
dst
,
-
1
,
stream
);
bgr_to_lab
(
dst
,
dst
,
-
1
,
stream
);
}
void
lab_to_bgr
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
dcn
,
Stream
&
stream
)
{
#if (CUDA_VERSION < 5000)
...
...
@@ -1196,6 +1202,12 @@ namespace
#endif
}
void
lab_to_rgb
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
,
Stream
&
stream
)
{
lab_to_bgr
(
src
,
dst
,
-
1
,
stream
);
bgr_to_rgb
(
dst
,
dst
,
-
1
,
stream
);
}
void
rgb_to_luv
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
dcn
,
Stream
&
stream
)
{
#if (CUDA_VERSION < 5000)
...
...
@@ -1225,6 +1237,12 @@ namespace
#endif
}
void
bgr_to_luv
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
,
Stream
&
stream
)
{
bgr_to_rgb
(
src
,
dst
,
-
1
,
stream
);
rgb_to_luv
(
dst
,
dst
,
-
1
,
stream
);
}
void
luv_to_rgb
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
dcn
,
Stream
&
stream
)
{
#if (CUDA_VERSION < 5000)
...
...
@@ -1253,6 +1271,12 @@ namespace
nppSafeCall
(
nppiLUVToRGB_8u_AC4R
(
src
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
src
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
)
);
#endif
}
void
luv_to_bgr
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
,
Stream
&
stream
)
{
luv_to_rgb
(
src
,
dst
,
-
1
,
stream
);
bgr_to_rgb
(
dst
,
dst
,
-
1
,
stream
);
}
}
void
cv
::
gpu
::
cvtColor
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
code
,
int
dcn
,
Stream
&
stream
)
...
...
@@ -1315,14 +1339,14 @@ void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, Stream
0
,
// =43
bgr_to_lab
,
// CV_BGR2Lab =44
0
,
// CV_RGB2Lab =45
rgb_to_lab
,
// CV_RGB2Lab =45
0
,
// CV_BayerBG2BGR =46
0
,
// CV_BayerGB2BGR =47
0
,
// CV_BayerRG2BGR =48
0
,
// CV_BayerGR2BGR =49
0
,
// CV_BGR2Luv =50
bgr_to_luv
,
// CV_BGR2Luv =50
rgb_to_luv
,
// CV_RGB2Luv =51
bgr_to_hls
,
// CV_BGR2HLS =52
...
...
@@ -1332,8 +1356,8 @@ void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, Stream
hsv_to_rgb
,
// CV_HSV2RGB =55
lab_to_bgr
,
// CV_Lab2BGR =56
0
,
// CV_Lab2RGB =57
0
,
// CV_Luv2BGR =58
lab_to_rgb
,
// CV_Lab2RGB =57
luv_to_bgr
,
// CV_Luv2BGR =58
luv_to_rgb
,
// CV_Luv2RGB =59
hls_to_bgr
,
// CV_HLS2BGR =60
...
...
modules/gpu/test/main.cpp
View file @
79d0dc25
...
...
@@ -43,8 +43,6 @@
#ifdef HAVE_CUDA
#include <cuda_runtime_api.h>
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
...
...
modules/gpu/test/precomp.hpp
View file @
79d0dc25
...
...
@@ -72,4 +72,9 @@
#include "utility.hpp"
#include "interpolation.hpp"
#ifdef HAVE_CUDA
#include <cuda.h>
#include <cuda_runtime.h>
#endif
#endif
modules/gpu/test/test_color.cpp
View file @
79d0dc25
...
...
@@ -1628,7 +1628,38 @@ TEST_P(CvtColor, BGR2Lab)
}
catch
(
const
cv
::
Exception
&
e
)
{
#if (CUDA_VERSION < 5000)
ASSERT_EQ
(
CV_StsBadFlag
,
e
.
code
);
#else
FAIL
();
#endif
}
}
TEST_P
(
CvtColor
,
RGB2Lab
)
{
if
(
depth
!=
CV_8U
)
return
;
try
{
cv
::
Mat
src
=
readImage
(
"stereobm/aloe-L.png"
);
cv
::
gpu
::
GpuMat
dst_lab
=
createMat
(
src
.
size
(),
src
.
type
(),
useRoi
);
cv
::
gpu
::
cvtColor
(
loadMat
(
src
,
useRoi
),
dst_lab
,
cv
::
COLOR_RGB2Lab
);
cv
::
gpu
::
GpuMat
dst_bgr
=
createMat
(
src
.
size
(),
src
.
type
(),
useRoi
);
cv
::
gpu
::
cvtColor
(
dst_lab
,
dst_bgr
,
cv
::
COLOR_Lab2RGB
);
EXPECT_MAT_NEAR
(
src
,
dst_bgr
,
10
);
}
catch
(
const
cv
::
Exception
&
e
)
{
#if (CUDA_VERSION < 5000)
ASSERT_EQ
(
CV_StsBadFlag
,
e
.
code
);
#else
FAIL
();
#endif
}
}
...
...
@@ -1641,6 +1672,33 @@ TEST_P(CvtColor, BGR2Luv)
{
cv
::
Mat
src
=
img
;
cv
::
gpu
::
GpuMat
dst_luv
=
createMat
(
src
.
size
(),
src
.
type
(),
useRoi
);
cv
::
gpu
::
cvtColor
(
loadMat
(
src
,
useRoi
),
dst_luv
,
cv
::
COLOR_BGR2Luv
);
cv
::
gpu
::
GpuMat
dst_rgb
=
createMat
(
src
.
size
(),
src
.
type
(),
useRoi
);
cv
::
gpu
::
cvtColor
(
dst_luv
,
dst_rgb
,
cv
::
COLOR_Luv2BGR
);
EXPECT_MAT_NEAR
(
src
,
dst_rgb
,
10
);
}
catch
(
const
cv
::
Exception
&
e
)
{
#if (CUDA_VERSION < 5000)
ASSERT_EQ
(
CV_StsBadFlag
,
e
.
code
);
#else
FAIL
();
#endif
}
}
TEST_P
(
CvtColor
,
RGB2Luv
)
{
if
(
depth
!=
CV_8U
)
return
;
try
{
cv
::
Mat
src
=
img
;
cv
::
gpu
::
GpuMat
dst_luv
=
createMat
(
src
.
size
(),
src
.
type
(),
useRoi
);
cv
::
gpu
::
cvtColor
(
loadMat
(
src
,
useRoi
),
dst_luv
,
cv
::
COLOR_RGB2Luv
);
...
...
@@ -1651,7 +1709,11 @@ TEST_P(CvtColor, BGR2Luv)
}
catch
(
const
cv
::
Exception
&
e
)
{
#if (CUDA_VERSION < 5000)
ASSERT_EQ
(
CV_StsBadFlag
,
e
.
code
);
#else
FAIL
();
#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