Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
18a59b48
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,发现更多精彩内容 >>
提交
18a59b48
编写于
3月 12, 2014
作者:
K
Konstantin Matskevich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes
上级
ddc23517
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
45 deletion
+49
-45
modules/calib3d/src/opencl/stereobm.cl
modules/calib3d/src/opencl/stereobm.cl
+46
-42
modules/calib3d/test/opencl/test_stereobm.cpp
modules/calib3d/test/opencl/test_stereobm.cpp
+3
-3
未找到文件。
modules/calib3d/src/opencl/stereobm.cl
浏览文件 @
18a59b48
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
#
define
MAX_VAL
32767
#
define
MAX_VAL
32767
void
calcDisp
(
__local
short
*
costFunc,
__global
short
*
disp,
int
uniquenessRatio/*,
int
textureTreshold,
short
textsum*/,
void
calcDisp
(
__local
short
*
costFunc,
__global
short
*
disp,
int
uniquenessRatio/*,
int
textureTreshold,
short
textsum*/,
int
mindisp,
int
ndisp,
int
w,
__local
short
*
dispbuf,
int
d
)
int
mindisp,
int
ndisp,
int
w,
__local
short
*
dispbuf,
int
d
,
int
x,
int
y,
int
cols,
int
rows,
int
wsz2
)
{
{
short
FILTERED
=
(
mindisp
-
1
)
<<4
;
short
FILTERED
=
(
mindisp
-
1
)
<<4
;
short
best_disp
=
FILTERED,
best_cost
=
MAX_VAL-1
;
short
best_disp
=
FILTERED,
best_cost
=
MAX_VAL-1
;
...
@@ -73,6 +73,7 @@ void calcDisp(__local short * costFunc, __global short * disp, int uniquenessRat
...
@@ -73,6 +73,7 @@ void calcDisp(__local short * costFunc, __global short * disp, int uniquenessRat
}
}
best_disp
=
ndisp
-
dispbuf[0]
-
1
;
best_disp
=
ndisp
-
dispbuf[0]
-
1
;
best_cost
=
costFunc[
(
ndisp-best_disp-1
)
*w]
;
best_cost
=
costFunc[
(
ndisp-best_disp-1
)
*w]
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
int
thresh
=
best_cost
+
(
best_cost
*
uniquenessRatio/100
)
;
int
thresh
=
best_cost
+
(
best_cost
*
uniquenessRatio/100
)
;
dispbuf[d]
=
(
(
cost[d*w]
<=
thresh
)
&&
(
d
<
(
ndisp
-
best_disp
-
2
)
|
| d > (ndisp - best_disp) ) ) ? FILTERED : best_disp;
dispbuf[d]
=
(
(
cost[d*w]
<=
thresh
)
&&
(
d
<
(
ndisp
-
best_disp
-
2
)
|
| d > (ndisp - best_disp) ) ) ? FILTERED : best_disp;
...
@@ -90,7 +91,7 @@ void calcDisp(__local short * costFunc, __global short * disp, int uniquenessRat
...
@@ -90,7 +91,7 @@ void calcDisp(__local short * costFunc, __global short * disp, int uniquenessRat
// best_disp = (textsum < textureTreshold) ? FILTERED : best_disp;
// best_disp = (textsum < textureTreshold) ? FILTERED : best_disp;
if( dispbuf[0] != FILTERED )
if( dispbuf[0] != FILTERED
&& x < cols-wsz2-mindisp && y < rows-wsz2
)
{
{
cost = &costFunc[0] + (ndisp - best_disp - 1)*w;
cost = &costFunc[0] + (ndisp - best_disp - 1)*w;
int y3 = ((ndisp - best_disp - 1) > 0) ? cost[-w] : cost[w],
int y3 = ((ndisp - best_disp - 1) > 0) ? cost[-w] : cost[w],
...
@@ -179,68 +180,71 @@ __kernel void stereoBM_opt(__global const uchar * leftptr, __global const uchar
...
@@ -179,68 +180,71 @@ __kernel void stereoBM_opt(__global const uchar * leftptr, __global const uchar
cost = costFunc + costIdx;
cost = costFunc + costIdx;
short tempcost = 0;
short tempcost = 0;
for(int i = 0; i < wsz; i++
)
if(x < cols-wsz2-mindisp && y < rows-wsz2
)
{
{
int idx = mad24(y-wsz2+i*nthread, cols, x-wsz2+i*(1-nthread));
for(int i = 0; i < wsz; i++)
left = leftptr + idx;
right = rightptr + (idx - d);
short costdiff = 0;
for(int j = 0; j < wsz; j++)
{
costdiff += abs( left[0] - right[0] );
left += 1*nthread + cols*(1-nthread);
right += 1*nthread + cols*(1-nthread);// maybe use ? operator
}
if(nthread==1)
{
{
tempcost += costdiff;
int idx = mad24(y-wsz2+i*nthread, cols, x-wsz2+i*(1-nthread));
left = leftptr + idx;
right = rightptr + (idx - d);
short costdiff = 0;
for(int j = 0; j < wsz; j++)
{
costdiff += abs( left[0] - right[0] );
left += 1*nthread + cols*(1-nthread);
right += 1*nthread + cols*(1-nthread);// maybe use ? operator
}
if(nthread==1)
{
tempcost += costdiff;
}
costbuf[head] = costdiff;
head++;
}
}
costbuf[head] = costdiff;
head++;
}
}
barrier(CLK_LOCAL_MEM_FENCE);
barrier(CLK_LOCAL_MEM_FENCE);
cost[0] = tempcost;
cost[0] = tempcost;
if(x < cols-wsz2-mindisp && y < rows-wsz2 && nthread == 1)
int dispIdx = mad24(gy, disp_step, disp_offset + gx*(int)sizeof(short));
{
disp = (__global short *)(dispptr + dispIdx);
int dispIdx = mad24(gy, disp_step, disp_offset + gx*(int)sizeof(short));
calcDisp(&costFunc[sizeY - 1 + lx - ly], disp, uniquenessRatio, /*textureTreshold, textsum,*/
disp = (__global short *)(dispptr + dispIdx);
mindisp, ndisp, 2*sizeY, &dispbuf[nthread*tsize/2], d, x, y, cols, rows, wsz2);
calcDisp(&costFunc[sizeY - 1 + lx - ly], disp, uniquenessRatio, /*textureTreshold, textsum,*/
mindisp, ndisp, 2*sizeY, &dispbuf[nthread*tsize/2], d);
}
barrier(CLK_LOCAL_MEM_FENCE);
barrier(CLK_LOCAL_MEM_FENCE);
lx = 1 - nthread;
lx = 1 - nthread;
ly = nthread;
ly = nthread;
while(lx < sizeX
&&
ly < sizeY )
while(lx < sizeX
||
ly < sizeY )
{
{
x =
gx + shiftX + lx
;
x =
(lx < sizeX) ? gx + shiftX + lx : cols
;
y =
gy + shiftY + ly
;
y =
(ly < sizeY) ? gy + shiftY + ly : rows
;
costIdx = calcLocalIdx(lx, ly, d, sizeY);
costIdx = calcLocalIdx(lx, ly, d, sizeY);
cost = costFunc + costIdx;
cost = costFunc + costIdx;
cost[0] = ( ly*(1-nthread) + lx*nthread == 0 ) ?
if(x < cols-wsz2-mindisp && y < rows-wsz2 )
calcCostBorder(leftptr, rightptr, x, y, nthread, wsz2, costbuf, &head, cols, d,
costFunc[calcLocalIdx(lx-1*(1-nthread), ly-1*nthread, d, sizeY)]) :
calcCostInside(leftptr, rightptr, x, y, wsz2, cols, d,
costFunc[calcLocalIdx(lx-1, ly-1, d, sizeY)],
costFunc[calcLocalIdx(lx, ly-1, d, sizeY)],
costFunc[calcLocalIdx(lx-1, ly, d, sizeY)]);
barrier(CLK_LOCAL_MEM_FENCE);
if(x < cols-mindisp-wsz2 && y < rows-wsz2)
{
{
int dispIdx = mad24(gy+ly, disp_step, disp_offset + (gx+lx)*(int)sizeof(short));
cost[0] = ( ly*(1-nthread) + lx*nthread == 0 ) ?
disp = (__global short *)(dispptr + dispIdx);
calcCostBorder(leftptr, rightptr, x, y, nthread, wsz2, costbuf, &head, cols, d,
calcDisp(&costFunc[sizeY - 1 - ly + lx], disp, uniquenessRatio, //textureTreshold, textsum,
costFunc[calcLocalIdx(lx-1*(1-nthread), ly-1*nthread, d, sizeY)]) :
mindisp, ndisp, 2*sizeY, &dispbuf[nthread*tsize/2], d);
calcCostInside(leftptr, rightptr, x, y, wsz2, cols, d,
costFunc[calcLocalIdx(lx-1, ly-1, d, sizeY)],
costFunc[calcLocalIdx(lx, ly-1, d, sizeY)],
costFunc[calcLocalIdx(lx-1, ly, d, sizeY)]);
}
}
barrier(CLK_LOCAL_MEM_FENCE);
barrier(CLK_LOCAL_MEM_FENCE);
int dispIdx = mad24(gy+ly, disp_step, disp_offset + (gx+lx)*(int)sizeof(short));
disp = (__global short *)(dispptr + dispIdx);
calcDisp(&costFunc[sizeY - 1 - ly + lx], disp, uniquenessRatio, //textureTreshold, textsum,
mindisp, ndisp, 2*sizeY, &dispbuf[nthread*tsize/2], d, x, y, cols, rows, wsz2);
barrier(CLK_LOCAL_MEM_FENCE);
calcNewCoordinates(&lx, &ly, nthread);
calcNewCoordinates(&lx, &ly, nthread);
}
}
}
}
#endif
#endif
...
...
modules/calib3d/test/opencl/test_stereobm.cpp
浏览文件 @
18a59b48
...
@@ -90,18 +90,18 @@ OCL_TEST_P(StereoBMFixture, StereoBM)
...
@@ -90,18 +90,18 @@ OCL_TEST_P(StereoBMFixture, StereoBM)
cv
::
ocl
::
finish
();
cv
::
ocl
::
finish
();
long
t3
=
clock
();
long
t3
=
clock
();
std
::
cout
<<
(
double
)(
t2
-
t1
)
/
CLOCKS_PER_SEC
<<
" "
<<
(
double
)(
t3
-
t2
)
/
CLOCKS_PER_SEC
<<
std
::
endl
;
std
::
cout
<<
(
double
)(
t2
-
t1
)
/
CLOCKS_PER_SEC
<<
" "
<<
(
double
)(
t3
-
t2
)
/
CLOCKS_PER_SEC
<<
std
::
endl
;
/*
Mat
t
;
absdiff
(
disp
,
udisp
,
t
);
Mat
t
;
absdiff
(
disp
,
udisp
,
t
);
for
(
int
i
=
0
;
i
<
t
.
rows
;
i
++
)
for
(
int
i
=
0
;
i
<
t
.
rows
;
i
++
)
for
(
int
j
=
0
;
j
<
t
.
cols
;
j
++
)
for
(
int
j
=
0
;
j
<
t
.
cols
;
j
++
)
if
(
t
.
at
<
short
>
(
i
,
j
)
>
0
)
if
(
t
.
at
<
short
>
(
i
,
j
)
>
0
)
// if(i== 255 && j == 375
)
// if(i== 12 && j == 44
)
printf
(
"%d %d cv: %d ocl: %d
\n
"
,
i
,
j
,
disp
.
at
<
short
>
(
i
,
j
),
udisp
.
getMat
(
ACCESS_READ
).
at
<
short
>
(
i
,
j
)
);
printf
(
"%d %d cv: %d ocl: %d
\n
"
,
i
,
j
,
disp
.
at
<
short
>
(
i
,
j
),
udisp
.
getMat
(
ACCESS_READ
).
at
<
short
>
(
i
,
j
)
);
/* imshow("diff.png", t*100);
/* imshow("diff.png", t*100);
imshow("cv.png", disp*100);
imshow("cv.png", disp*100);
imshow("ocl.png", udisp.getMat(ACCESS_READ)*100);
imshow("ocl.png", udisp.getMat(ACCESS_READ)*100);
waitKey(0);*/
waitKey(0);*/
//
Near(1e-3);
Near
(
1e-3
);
}
}
OCL_INSTANTIATE_TEST_CASE_P
(
StereoMatcher
,
StereoBMFixture
,
testing
::
Combine
(
testing
::
Values
(
32
,
64
,
128
),
OCL_INSTANTIATE_TEST_CASE_P
(
StereoMatcher
,
StereoBMFixture
,
testing
::
Combine
(
testing
::
Values
(
32
,
64
,
128
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录