Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
905e5f17
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,发现更多精彩内容 >>
提交
905e5f17
编写于
12月 08, 2010
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added support of 4-channels images to StereoConstantSpaceBP.
refactored transpose_gpu, made it non template function.
上级
c18aa438
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
31 deletion
+32
-31
modules/gpu/src/arithm.cpp
modules/gpu/src/arithm.cpp
+2
-11
modules/gpu/src/constantspacebp.cpp
modules/gpu/src/constantspacebp.cpp
+1
-1
modules/gpu/src/cuda/constantspacebp.cu
modules/gpu/src/cuda/constantspacebp.cu
+22
-6
modules/gpu/src/cuda/mathfunc.cu
modules/gpu/src/cuda/mathfunc.cu
+4
-13
tests/gpu/src/stereo_csbp.cpp
tests/gpu/src/stereo_csbp.cpp
+3
-0
未找到文件。
modules/gpu/src/arithm.cpp
浏览文件 @
905e5f17
...
@@ -272,20 +272,11 @@ void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst)
...
@@ -272,20 +272,11 @@ void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst)
namespace
cv
{
namespace
gpu
{
namespace
mathfunc
namespace
cv
{
namespace
gpu
{
namespace
mathfunc
{
{
template
<
typename
T
>
void
transpose_gpu
(
const
DevMem2Di
&
src
,
const
DevMem2Di
&
dst
);
void
transpose_gpu
(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
}}}
}}}
void
cv
::
gpu
::
transpose
(
const
GpuMat
&
src
,
GpuMat
&
dst
)
void
cv
::
gpu
::
transpose
(
const
GpuMat
&
src
,
GpuMat
&
dst
)
{
{
using
namespace
cv
::
gpu
::
mathfunc
;
typedef
void
(
*
func_t
)(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
static
const
func_t
funcs
[]
=
{
transpose_gpu
<
uchar4
>
,
transpose_gpu
<
char4
>
,
transpose_gpu
<
ushort2
>
,
transpose_gpu
<
short2
>
,
transpose_gpu
<
int
>
,
transpose_gpu
<
float
>
};
CV_Assert
(
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_8UC4
||
src
.
type
()
==
CV_8SC4
CV_Assert
(
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_8UC4
||
src
.
type
()
==
CV_8SC4
||
src
.
type
()
==
CV_16UC2
||
src
.
type
()
==
CV_16SC2
||
src
.
type
()
==
CV_32SC1
||
src
.
type
()
==
CV_32FC1
);
||
src
.
type
()
==
CV_16UC2
||
src
.
type
()
==
CV_16SC2
||
src
.
type
()
==
CV_32SC1
||
src
.
type
()
==
CV_32FC1
);
...
@@ -301,7 +292,7 @@ void cv::gpu::transpose(const GpuMat& src, GpuMat& dst)
...
@@ -301,7 +292,7 @@ void cv::gpu::transpose(const GpuMat& src, GpuMat& dst)
}
}
else
else
{
{
funcs
[
src
.
depth
()]
(
src
,
dst
);
mathfunc
::
transpose_gpu
(
src
,
dst
);
}
}
}
}
...
...
modules/gpu/src/constantspacebp.cpp
浏览文件 @
905e5f17
...
@@ -141,7 +141,7 @@ static void csbp_operator(StereoConstantSpaceBP& rthis, GpuMat u[2], GpuMat d[2]
...
@@ -141,7 +141,7 @@ static void csbp_operator(StereoConstantSpaceBP& rthis, GpuMat u[2], GpuMat d[2]
CV_DbgAssert
(
0
<
rthis
.
ndisp
&&
0
<
rthis
.
iters
&&
0
<
rthis
.
levels
&&
0
<
rthis
.
nr_plane
CV_DbgAssert
(
0
<
rthis
.
ndisp
&&
0
<
rthis
.
iters
&&
0
<
rthis
.
levels
&&
0
<
rthis
.
nr_plane
&&
left
.
rows
==
right
.
rows
&&
left
.
cols
==
right
.
cols
&&
left
.
type
()
==
right
.
type
());
&&
left
.
rows
==
right
.
rows
&&
left
.
cols
==
right
.
cols
&&
left
.
type
()
==
right
.
type
());
CV_Assert
(
rthis
.
levels
<=
8
&&
(
left
.
type
()
==
CV_8UC1
||
left
.
type
()
==
CV_8UC3
));
CV_Assert
(
rthis
.
levels
<=
8
&&
(
left
.
type
()
==
CV_8UC1
||
left
.
type
()
==
CV_8UC3
||
left
.
type
()
==
CV_8UC4
));
const
Scalar
zero
=
Scalar
::
all
(
0
);
const
Scalar
zero
=
Scalar
::
all
(
0
);
...
...
modules/gpu/src/cuda/constantspacebp.cu
浏览文件 @
905e5f17
...
@@ -99,8 +99,15 @@ namespace cv { namespace gpu { namespace csbp
...
@@ -99,8 +99,15 @@ namespace cv { namespace gpu { namespace csbp
/////////////////////// init data cost ////////////////////////
/////////////////////// init data cost ////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
template
<
int
channels
>
template
<
int
channels
>
struct
DataCostPerPixel
;
struct
DataCostPerPixel
template
<
>
struct
DataCostPerPixel
<
1
>
{
static
__device__
float
compute
(
const
uchar
*
left
,
const
uchar
*
right
)
{
return
fmin
(
cdata_weight
*
abs
((
int
)
*
left
-
*
right
),
cdata_weight
*
cmax_data_term
);
}
};
template
<
>
struct
DataCostPerPixel
<
3
>
{
{
static
__device__
float
compute
(
const
uchar
*
left
,
const
uchar
*
right
)
static
__device__
float
compute
(
const
uchar
*
left
,
const
uchar
*
right
)
{
{
...
@@ -111,13 +118,18 @@ namespace cv { namespace gpu { namespace csbp
...
@@ -111,13 +118,18 @@ namespace cv { namespace gpu { namespace csbp
return
fmin
(
cdata_weight
*
(
tr
+
tg
+
tb
),
cdata_weight
*
cmax_data_term
);
return
fmin
(
cdata_weight
*
(
tr
+
tg
+
tb
),
cdata_weight
*
cmax_data_term
);
}
}
};
};
template
<
>
struct
DataCostPerPixel
<
4
>
template
<
>
struct
DataCostPerPixel
<
1
>
{
{
static
__device__
float
compute
(
const
uchar
*
left
,
const
uchar
*
right
)
static
__device__
float
compute
(
const
uchar
*
left
,
const
uchar
*
right
)
{
{
return
fmin
(
cdata_weight
*
abs
((
int
)
*
left
-
*
right
),
cdata_weight
*
cmax_data_term
);
uchar4
l
=
*
((
const
uchar4
*
)
left
);
uchar4
r
=
*
((
const
uchar4
*
)
right
);
float
tb
=
0.114
f
*
abs
((
int
)
l
.
x
-
r
.
x
);
float
tg
=
0.587
f
*
abs
((
int
)
l
.
y
-
r
.
y
);
float
tr
=
0.299
f
*
abs
((
int
)
l
.
z
-
r
.
z
);
return
fmin
(
cdata_weight
*
(
tr
+
tg
+
tb
),
cdata_weight
*
cmax_data_term
);
}
}
};
};
...
@@ -327,6 +339,7 @@ namespace cv { namespace gpu { namespace csbp
...
@@ -327,6 +339,7 @@ namespace cv { namespace gpu { namespace csbp
{
{
case
1
:
init_data_cost
<
T
,
1
><<<
grid
,
threads
,
0
,
stream
>>>
(
h
,
w
,
level
);
break
;
case
1
:
init_data_cost
<
T
,
1
><<<
grid
,
threads
,
0
,
stream
>>>
(
h
,
w
,
level
);
break
;
case
3
:
init_data_cost
<
T
,
3
><<<
grid
,
threads
,
0
,
stream
>>>
(
h
,
w
,
level
);
break
;
case
3
:
init_data_cost
<
T
,
3
><<<
grid
,
threads
,
0
,
stream
>>>
(
h
,
w
,
level
);
break
;
case
4
:
init_data_cost
<
T
,
4
><<<
grid
,
threads
,
0
,
stream
>>>
(
h
,
w
,
level
);
break
;
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
}
}
}
}
...
@@ -345,6 +358,7 @@ namespace cv { namespace gpu { namespace csbp
...
@@ -345,6 +358,7 @@ namespace cv { namespace gpu { namespace csbp
{
{
case
1
:
init_data_cost_reduce
<
T
,
winsz
,
1
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
level
,
rows
,
cols
,
h
);
break
;
case
1
:
init_data_cost_reduce
<
T
,
winsz
,
1
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
level
,
rows
,
cols
,
h
);
break
;
case
3
:
init_data_cost_reduce
<
T
,
winsz
,
3
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
level
,
rows
,
cols
,
h
);
break
;
case
3
:
init_data_cost_reduce
<
T
,
winsz
,
3
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
level
,
rows
,
cols
,
h
);
break
;
case
4
:
init_data_cost_reduce
<
T
,
winsz
,
4
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
level
,
rows
,
cols
,
h
);
break
;
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
}
}
}
}
...
@@ -517,6 +531,7 @@ namespace cv { namespace gpu { namespace csbp
...
@@ -517,6 +531,7 @@ namespace cv { namespace gpu { namespace csbp
{
{
case
1
:
compute_data_cost
<
T
,
1
><<<
grid
,
threads
,
0
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
h
,
w
,
level
,
nr_plane
);
break
;
case
1
:
compute_data_cost
<
T
,
1
><<<
grid
,
threads
,
0
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
h
,
w
,
level
,
nr_plane
);
break
;
case
3
:
compute_data_cost
<
T
,
3
><<<
grid
,
threads
,
0
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
h
,
w
,
level
,
nr_plane
);
break
;
case
3
:
compute_data_cost
<
T
,
3
><<<
grid
,
threads
,
0
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
h
,
w
,
level
,
nr_plane
);
break
;
case
4
:
compute_data_cost
<
T
,
4
><<<
grid
,
threads
,
0
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
h
,
w
,
level
,
nr_plane
);
break
;
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
}
}
}
}
...
@@ -536,6 +551,7 @@ namespace cv { namespace gpu { namespace csbp
...
@@ -536,6 +551,7 @@ namespace cv { namespace gpu { namespace csbp
{
{
case
1
:
compute_data_cost_reduce
<
T
,
winsz
,
1
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
level
,
rows
,
cols
,
h
,
nr_plane
);
break
;
case
1
:
compute_data_cost_reduce
<
T
,
winsz
,
1
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
level
,
rows
,
cols
,
h
,
nr_plane
);
break
;
case
3
:
compute_data_cost_reduce
<
T
,
winsz
,
3
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
level
,
rows
,
cols
,
h
,
nr_plane
);
break
;
case
3
:
compute_data_cost_reduce
<
T
,
winsz
,
3
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
level
,
rows
,
cols
,
h
,
nr_plane
);
break
;
case
4
:
compute_data_cost_reduce
<
T
,
winsz
,
4
><<<
grid
,
threads
,
smem_size
,
stream
>>>
(
disp_selected_pyr
,
data_cost
,
level
,
rows
,
cols
,
h
,
nr_plane
);
break
;
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
default:
cv
::
gpu
::
error
(
"Unsupported channels count"
,
__FILE__
,
__LINE__
);
}
}
}
}
...
...
modules/gpu/src/cuda/mathfunc.cu
浏览文件 @
905e5f17
...
@@ -1254,10 +1254,9 @@ namespace cv { namespace gpu { namespace mathfunc
...
@@ -1254,10 +1254,9 @@ namespace cv { namespace gpu { namespace mathfunc
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// transpose
// transpose
template
<
typename
T
>
__global__
void
transpose
(
const
DevMem2Di
src
,
PtrStepi
dst
)
__global__
void
transpose
(
const
DevMem2D_
<
T
>
src
,
PtrStep_
<
T
>
dst
)
{
{
__shared__
T
s_mem
[
16
*
17
];
__shared__
int
s_mem
[
16
*
17
];
int
x
=
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
;
int
x
=
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
;
int
y
=
blockIdx
.
y
*
blockDim
.
y
+
threadIdx
.
y
;
int
y
=
blockIdx
.
y
*
blockDim
.
y
+
threadIdx
.
y
;
...
@@ -1280,22 +1279,14 @@ namespace cv { namespace gpu { namespace mathfunc
...
@@ -1280,22 +1279,14 @@ namespace cv { namespace gpu { namespace mathfunc
}
}
}
}
template
<
typename
T
>
void
transpose_gpu
(
const
DevMem2Di
&
src
,
const
DevMem2Di
&
dst
)
void
transpose_gpu
(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
)
{
{
dim3
threads
(
16
,
16
,
1
);
dim3
threads
(
16
,
16
,
1
);
dim3
grid
(
divUp
(
src
.
cols
,
16
),
divUp
(
src
.
rows
,
16
),
1
);
dim3
grid
(
divUp
(
src
.
cols
,
16
),
divUp
(
src
.
rows
,
16
),
1
);
transpose
<
T
><<<
grid
,
threads
>>>
((
DevMem2D_
<
T
>
)
src
,
(
DevMem2D_
<
T
>
)
dst
);
transpose
<
<<
grid
,
threads
>>>
(
src
,
dst
);
cudaSafeCall
(
cudaThreadSynchronize
()
);
cudaSafeCall
(
cudaThreadSynchronize
()
);
}
}
template
void
transpose_gpu
<
uchar4
>(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
template
void
transpose_gpu
<
char4
>(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
template
void
transpose_gpu
<
ushort2
>(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
template
void
transpose_gpu
<
short2
>(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
template
void
transpose_gpu
<
int
>(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
template
void
transpose_gpu
<
float
>(
const
DevMem2D
&
src
,
const
DevMem2D
&
dst
);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// min/max
// min/max
...
...
tests/gpu/src/stereo_csbp.cpp
浏览文件 @
905e5f17
...
@@ -62,6 +62,9 @@ struct CV_GpuStereoCSBPTest : public CvTest
...
@@ -62,6 +62,9 @@ struct CV_GpuStereoCSBPTest : public CvTest
try
try
{
{
{
cv
::
Mat
temp
;
cv
::
cvtColor
(
img_l
,
temp
,
CV_BGR2BGRA
);
cv
::
swap
(
temp
,
img_l
);}
{
cv
::
Mat
temp
;
cv
::
cvtColor
(
img_r
,
temp
,
CV_BGR2BGRA
);
cv
::
swap
(
temp
,
img_r
);}
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
GpuMat
disp
;
cv
::
gpu
::
StereoConstantSpaceBP
bpm
(
128
,
16
,
4
,
4
);
cv
::
gpu
::
StereoConstantSpaceBP
bpm
(
128
,
16
,
4
,
4
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录