Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
dc3c691c
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,发现更多精彩内容 >>
提交
dc3c691c
编写于
7月 29, 2014
作者:
E
Elena Gvozdeva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new block size for dft
上级
e7216a59
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
23 deletion
+20
-23
modules/imgproc/src/templmatch.cpp
modules/imgproc/src/templmatch.cpp
+20
-23
未找到文件。
modules/imgproc/src/templmatch.cpp
浏览文件 @
dc3c691c
...
...
@@ -129,7 +129,6 @@ struct ConvolveBuf
UMat
image_block
,
templ_block
,
result_data
;
void
create
(
Size
image_size
,
Size
templ_size
);
static
Size
estimateBlockSize
(
Size
result_size
);
};
void
ConvolveBuf
::
create
(
Size
image_size
,
Size
templ_size
)
...
...
@@ -137,19 +136,26 @@ void ConvolveBuf::create(Size image_size, Size templ_size)
result_size
=
Size
(
image_size
.
width
-
templ_size
.
width
+
1
,
image_size
.
height
-
templ_size
.
height
+
1
);
block_size
=
user_block_size
;
if
(
user_block_size
.
width
==
0
||
user_block_size
.
height
==
0
)
block_size
=
estimateBlockSize
(
result_size
);
dft_size
.
width
=
1
<<
int
(
ceil
(
std
::
log
(
block_size
.
width
+
templ_size
.
width
-
1.
)
/
std
::
log
(
2.
)));
dft_size
.
height
=
1
<<
int
(
ceil
(
std
::
log
(
block_size
.
height
+
templ_size
.
height
-
1.
)
/
std
::
log
(
2.
)));
dft_size
.
width
=
getOptimalDFTSize
(
block_size
.
width
+
templ_size
.
width
-
1
);
const
double
blockScale
=
4.5
;
const
int
minBlockSize
=
256
;
block_size
.
width
=
cvRound
(
result_size
.
width
*
blockScale
);
block_size
.
width
=
MAX
(
block_size
.
width
,
minBlockSize
-
templ_size
.
width
+
1
);
block_size
.
width
=
std
::
min
(
block_size
.
width
,
result_size
.
width
);
block_size
.
height
=
cvRound
(
templ_size
.
height
*
blockScale
);
block_size
.
height
=
std
::
max
(
block_size
.
height
,
minBlockSize
-
templ_size
.
height
+
1
);
block_size
.
height
=
std
::
min
(
block_size
.
height
,
result_size
.
height
);
dft_size
.
width
=
MAX
(
getOptimalDFTSize
(
block_size
.
width
+
templ_size
.
width
-
1
),
2
);
dft_size
.
height
=
getOptimalDFTSize
(
block_size
.
height
+
templ_size
.
height
-
1
);
if
(
dft_size
.
width
<=
0
||
dft_size
.
height
<=
0
)
CV_Error
(
CV_StsOutOfRange
,
"the input arrays are too big"
);
// To avoid wasting time doing small DFTs
dft_size
.
width
=
std
::
max
(
dft_size
.
width
,
512
);
dft_size
.
height
=
std
::
max
(
dft_size
.
height
,
512
);
// recompute block size
block_size
.
width
=
dft_size
.
width
-
templ_size
.
width
+
1
;
block_size
.
width
=
MIN
(
block_size
.
width
,
result_size
.
width
);
block_size
.
height
=
dft_size
.
height
-
templ_size
.
height
+
1
;
block_size
.
height
=
MIN
(
block_size
.
height
,
result_size
.
height
);
image_block
.
create
(
dft_size
,
CV_32F
);
templ_block
.
create
(
dft_size
,
CV_32F
);
...
...
@@ -164,21 +170,12 @@ void ConvolveBuf::create(Size image_size, Size templ_size)
block_size
.
height
=
std
::
min
(
dft_size
.
height
-
templ_size
.
height
+
1
,
result_size
.
height
);
}
Size
ConvolveBuf
::
estimateBlockSize
(
Size
result_size
)
{
int
width
=
(
result_size
.
width
+
2
)
/
3
;
int
height
=
(
result_size
.
height
+
2
)
/
3
;
width
=
std
::
min
(
width
,
result_size
.
width
);
height
=
std
::
min
(
height
,
result_size
.
height
);
return
Size
(
width
,
height
);
}
static
bool
convolve_dft
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_result
)
{
ConvolveBuf
buf
;
CV_Assert
(
_image
.
type
()
==
CV_32F
);
CV_Assert
(
_templ
.
type
()
==
CV_32F
);
buf
.
create
(
_image
.
size
(),
_templ
.
size
());
_result
.
create
(
buf
.
result_size
,
CV_32F
);
...
...
@@ -202,7 +199,7 @@ static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _resu
copyMakeBorder
(
templ_roi
,
templ_block
,
0
,
templ_block
.
rows
-
templ_roi
.
rows
,
0
,
templ_block
.
cols
-
templ_roi
.
cols
,
BORDER_ISOLATED
);
dft
(
templ_block
,
templ_spect
,
0
);
dft
(
templ_block
,
templ_spect
,
0
,
templ
.
rows
);
// Process all blocks of the result matrix
for
(
int
y
=
0
;
y
<
result
.
rows
;
y
+=
block_size
.
height
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录