Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
11c6eb63
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
11c6eb63
编写于
11月 21, 2012
作者:
V
Vladislav Vinogradov
提交者:
Vladislav Vinogradov
11月 26, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
element operations
上级
f00efcfc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
4900 addition
and
2806 deletion
+4900
-2806
modules/gpu/include/opencv2/gpu/device/functional.hpp
modules/gpu/include/opencv2/gpu/device/functional.hpp
+34
-0
modules/gpu/src/cuda/element_operations.cu
modules/gpu/src/cuda/element_operations.cu
+2660
-1514
modules/gpu/src/element_operations.cpp
modules/gpu/src/element_operations.cpp
+2075
-1281
modules/gpu/test/test_core.cpp
modules/gpu/test/test_core.cpp
+131
-11
未找到文件。
modules/gpu/include/opencv2/gpu/device/functional.hpp
浏览文件 @
11c6eb63
...
...
@@ -357,6 +357,9 @@ namespace cv { namespace gpu { namespace device
{
return
abs
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
unsigned
char
>
:
unary_function
<
unsigned
char
,
unsigned
char
>
{
...
...
@@ -364,6 +367,9 @@ namespace cv { namespace gpu { namespace device
{
return
x
;
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
signed
char
>
:
unary_function
<
signed
char
,
signed
char
>
{
...
...
@@ -371,6 +377,9 @@ namespace cv { namespace gpu { namespace device
{
return
::
abs
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
char
>
:
unary_function
<
char
,
char
>
{
...
...
@@ -378,6 +387,9 @@ namespace cv { namespace gpu { namespace device
{
return
::
abs
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
unsigned
short
>
:
unary_function
<
unsigned
short
,
unsigned
short
>
{
...
...
@@ -385,6 +397,9 @@ namespace cv { namespace gpu { namespace device
{
return
x
;
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
short
>
:
unary_function
<
short
,
short
>
{
...
...
@@ -392,6 +407,9 @@ namespace cv { namespace gpu { namespace device
{
return
::
abs
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
unsigned
int
>
:
unary_function
<
unsigned
int
,
unsigned
int
>
{
...
...
@@ -399,6 +417,9 @@ namespace cv { namespace gpu { namespace device
{
return
x
;
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
int
>
:
unary_function
<
int
,
int
>
{
...
...
@@ -406,6 +427,9 @@ namespace cv { namespace gpu { namespace device
{
return
::
abs
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
float
>
:
unary_function
<
float
,
float
>
{
...
...
@@ -413,6 +437,9 @@ namespace cv { namespace gpu { namespace device
{
return
::
fabsf
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
template
<
>
struct
abs_func
<
double
>
:
unary_function
<
double
,
double
>
{
...
...
@@ -420,6 +447,9 @@ namespace cv { namespace gpu { namespace device
{
return
::
fabs
(
x
);
}
__device__
__forceinline__
abs_func
()
{}
__device__
__forceinline__
abs_func
(
const
abs_func
&
)
{}
};
#define OPENCV_GPU_IMPLEMENT_UN_FUNCTOR(name, func) \
...
...
@@ -429,6 +459,8 @@ namespace cv { namespace gpu { namespace device
{ \
return func ## f(v); \
} \
__device__ __forceinline__ name ## _func() {} \
__device__ __forceinline__ name ## _func(const name ## _func&) {} \
}; \
template <> struct name ## _func<double> : unary_function<double, double> \
{ \
...
...
@@ -436,6 +468,8 @@ namespace cv { namespace gpu { namespace device
{ \
return func(v); \
} \
__device__ __forceinline__ name ## _func() {} \
__device__ __forceinline__ name ## _func(const name ## _func&) {} \
};
#define OPENCV_GPU_IMPLEMENT_BIN_FUNCTOR(name, func) \
...
...
modules/gpu/src/cuda/element_operations.cu
浏览文件 @
11c6eb63
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
modules/gpu/src/element_operations.cpp
浏览文件 @
11c6eb63
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
modules/gpu/test/test_core.cpp
浏览文件 @
11c6eb63
...
...
@@ -210,7 +210,6 @@ TEST_P(Add_Array, Accuracy)
{
cv
::
Mat
mat1
=
randomMat
(
size
,
stype
);
cv
::
Mat
mat2
=
randomMat
(
size
,
stype
);
cv
::
Mat
mask
=
randomMat
(
size
,
CV_8UC1
,
0.0
,
2.0
);
if
((
depth
.
first
==
CV_64F
||
depth
.
second
==
CV_64F
)
&&
!
supportFeature
(
devInfo
,
cv
::
gpu
::
NATIVE_DOUBLE
))
{
...
...
@@ -228,10 +227,10 @@ TEST_P(Add_Array, Accuracy)
{
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
dtype
,
useRoi
);
dst
.
setTo
(
cv
::
Scalar
::
all
(
0
));
cv
::
gpu
::
add
(
loadMat
(
mat1
,
useRoi
),
loadMat
(
mat2
,
useRoi
),
dst
,
c
hannels
==
1
?
loadMat
(
mask
,
useRoi
)
:
c
v
::
gpu
::
GpuMat
(),
depth
.
second
);
cv
::
gpu
::
add
(
loadMat
(
mat1
,
useRoi
),
loadMat
(
mat2
,
useRoi
),
dst
,
cv
::
gpu
::
GpuMat
(),
depth
.
second
);
cv
::
Mat
dst_gold
(
size
,
dtype
,
cv
::
Scalar
::
all
(
0
));
cv
::
add
(
mat1
,
mat2
,
dst_gold
,
c
hannels
==
1
?
mask
:
c
v
::
noArray
(),
depth
.
second
);
cv
::
add
(
mat1
,
mat2
,
dst_gold
,
cv
::
noArray
(),
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-4
:
0.0
);
}
...
...
@@ -244,6 +243,67 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Add_Array, testing::Combine(
ALL_CHANNELS
,
WHOLE_SUBMAT
));
PARAM_TEST_CASE
(
Add_Array_Mask
,
cv
::
gpu
::
DeviceInfo
,
cv
::
Size
,
std
::
pair
<
MatDepth
,
MatDepth
>
,
UseRoi
)
{
cv
::
gpu
::
DeviceInfo
devInfo
;
cv
::
Size
size
;
std
::
pair
<
MatDepth
,
MatDepth
>
depth
;
bool
useRoi
;
int
stype
;
int
dtype
;
virtual
void
SetUp
()
{
devInfo
=
GET_PARAM
(
0
);
size
=
GET_PARAM
(
1
);
depth
=
GET_PARAM
(
2
);
useRoi
=
GET_PARAM
(
3
);
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
stype
=
CV_MAKE_TYPE
(
depth
.
first
,
1
);
dtype
=
CV_MAKE_TYPE
(
depth
.
second
,
1
);
}
};
TEST_P
(
Add_Array_Mask
,
Accuracy
)
{
cv
::
Mat
mat1
=
randomMat
(
size
,
stype
);
cv
::
Mat
mat2
=
randomMat
(
size
,
stype
);
cv
::
Mat
mask
=
randomMat
(
size
,
CV_8UC1
,
0
,
2
);
if
((
depth
.
first
==
CV_64F
||
depth
.
second
==
CV_64F
)
&&
!
supportFeature
(
devInfo
,
cv
::
gpu
::
NATIVE_DOUBLE
))
{
try
{
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
add
(
loadMat
(
mat1
),
loadMat
(
mat2
),
dst
,
cv
::
gpu
::
GpuMat
(),
depth
.
second
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsUnsupportedFormat
,
e
.
code
);
}
}
else
{
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
dtype
,
useRoi
);
dst
.
setTo
(
cv
::
Scalar
::
all
(
0
));
cv
::
gpu
::
add
(
loadMat
(
mat1
,
useRoi
),
loadMat
(
mat2
,
useRoi
),
dst
,
loadMat
(
mask
,
useRoi
),
depth
.
second
);
cv
::
Mat
dst_gold
(
size
,
dtype
,
cv
::
Scalar
::
all
(
0
));
cv
::
add
(
mat1
,
mat2
,
dst_gold
,
mask
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-4
:
0.0
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Core
,
Add_Array_Mask
,
testing
::
Combine
(
ALL_DEVICES
,
DIFFERENT_SIZES
,
DEPTH_PAIRS
,
WHOLE_SUBMAT
));
////////////////////////////////////////////////////////////////////////////////
// Add_Scalar
...
...
@@ -365,7 +425,6 @@ TEST_P(Subtract_Array, Accuracy)
{
cv
::
Mat
mat1
=
randomMat
(
size
,
stype
);
cv
::
Mat
mat2
=
randomMat
(
size
,
stype
);
cv
::
Mat
mask
=
randomMat
(
size
,
CV_8UC1
,
0.0
,
2.0
);
if
((
depth
.
first
==
CV_64F
||
depth
.
second
==
CV_64F
)
&&
!
supportFeature
(
devInfo
,
cv
::
gpu
::
NATIVE_DOUBLE
))
{
...
...
@@ -383,10 +442,10 @@ TEST_P(Subtract_Array, Accuracy)
{
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
dtype
,
useRoi
);
dst
.
setTo
(
cv
::
Scalar
::
all
(
0
));
cv
::
gpu
::
subtract
(
loadMat
(
mat1
,
useRoi
),
loadMat
(
mat2
,
useRoi
),
dst
,
c
hannels
==
1
?
loadMat
(
mask
,
useRoi
)
:
c
v
::
gpu
::
GpuMat
(),
depth
.
second
);
cv
::
gpu
::
subtract
(
loadMat
(
mat1
,
useRoi
),
loadMat
(
mat2
,
useRoi
),
dst
,
cv
::
gpu
::
GpuMat
(),
depth
.
second
);
cv
::
Mat
dst_gold
(
size
,
dtype
,
cv
::
Scalar
::
all
(
0
));
cv
::
subtract
(
mat1
,
mat2
,
dst_gold
,
c
hannels
==
1
?
mask
:
c
v
::
noArray
(),
depth
.
second
);
cv
::
subtract
(
mat1
,
mat2
,
dst_gold
,
cv
::
noArray
(),
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-4
:
0.0
);
}
...
...
@@ -399,6 +458,67 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Subtract_Array, testing::Combine(
ALL_CHANNELS
,
WHOLE_SUBMAT
));
PARAM_TEST_CASE
(
Subtract_Array_Mask
,
cv
::
gpu
::
DeviceInfo
,
cv
::
Size
,
std
::
pair
<
MatDepth
,
MatDepth
>
,
UseRoi
)
{
cv
::
gpu
::
DeviceInfo
devInfo
;
cv
::
Size
size
;
std
::
pair
<
MatDepth
,
MatDepth
>
depth
;
bool
useRoi
;
int
stype
;
int
dtype
;
virtual
void
SetUp
()
{
devInfo
=
GET_PARAM
(
0
);
size
=
GET_PARAM
(
1
);
depth
=
GET_PARAM
(
2
);
useRoi
=
GET_PARAM
(
3
);
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
stype
=
CV_MAKE_TYPE
(
depth
.
first
,
1
);
dtype
=
CV_MAKE_TYPE
(
depth
.
second
,
1
);
}
};
TEST_P
(
Subtract_Array_Mask
,
Accuracy
)
{
cv
::
Mat
mat1
=
randomMat
(
size
,
stype
);
cv
::
Mat
mat2
=
randomMat
(
size
,
stype
);
cv
::
Mat
mask
=
randomMat
(
size
,
CV_8UC1
,
0.0
,
2.0
);
if
((
depth
.
first
==
CV_64F
||
depth
.
second
==
CV_64F
)
&&
!
supportFeature
(
devInfo
,
cv
::
gpu
::
NATIVE_DOUBLE
))
{
try
{
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
subtract
(
loadMat
(
mat1
),
loadMat
(
mat2
),
dst
,
cv
::
gpu
::
GpuMat
(),
depth
.
second
);
}
catch
(
const
cv
::
Exception
&
e
)
{
ASSERT_EQ
(
CV_StsUnsupportedFormat
,
e
.
code
);
}
}
else
{
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
dtype
,
useRoi
);
dst
.
setTo
(
cv
::
Scalar
::
all
(
0
));
cv
::
gpu
::
subtract
(
loadMat
(
mat1
,
useRoi
),
loadMat
(
mat2
,
useRoi
),
dst
,
loadMat
(
mask
,
useRoi
),
depth
.
second
);
cv
::
Mat
dst_gold
(
size
,
dtype
,
cv
::
Scalar
::
all
(
0
));
cv
::
subtract
(
mat1
,
mat2
,
dst_gold
,
mask
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-4
:
0.0
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_Core
,
Subtract_Array_Mask
,
testing
::
Combine
(
ALL_DEVICES
,
DIFFERENT_SIZES
,
DEPTH_PAIRS
,
WHOLE_SUBMAT
));
////////////////////////////////////////////////////////////////////////////////
// Subtract_Scalar
...
...
@@ -541,7 +661,7 @@ TEST_P(Multiply_Array, WithOutScale)
cv
::
Mat
dst_gold
;
cv
::
multiply
(
mat1
,
mat2
,
dst_gold
,
1
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-
4
:
0.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-
2
:
0.0
);
}
}
...
...
@@ -571,7 +691,7 @@ TEST_P(Multiply_Array, WithScale)
cv
::
Mat
dst_gold
;
cv
::
multiply
(
mat1
,
mat2
,
dst_gold
,
scale
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
1
.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
2
.0
);
}
}
...
...
@@ -726,7 +846,7 @@ TEST_P(Multiply_Scalar, WithOutScale)
cv
::
Mat
dst_gold
;
cv
::
multiply
(
mat
,
val
,
dst_gold
,
1
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-2
:
0
.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
1
.0
);
}
}
...
...
@@ -757,7 +877,7 @@ TEST_P(Multiply_Scalar, WithScale)
cv
::
Mat
dst_gold
;
cv
::
multiply
(
mat
,
val
,
dst_gold
,
scale
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-4
:
0
.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
1
.0
);
}
}
...
...
@@ -1037,7 +1157,7 @@ TEST_P(Divide_Scalar, WithScale)
cv
::
Mat
dst_gold
;
cv
::
divide
(
mat
,
val
,
dst_gold
,
scale
,
depth
.
second
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-
4
:
0.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
depth
.
first
>=
CV_32F
||
depth
.
second
>=
CV_32F
?
1e-
2
:
0.0
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录