Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
97530caa
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
97530caa
编写于
5月 21, 2011
作者:
A
Alexey Spizhevoy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more refactoring of opencv_stitching
上级
aadb1669
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
30 deletion
+45
-30
modules/stitching/main.cpp
modules/stitching/main.cpp
+42
-26
modules/stitching/matchers.cpp
modules/stitching/matchers.cpp
+3
-4
未找到文件。
modules/stitching/main.cpp
浏览文件 @
97530caa
...
...
@@ -31,34 +31,28 @@ void printUsage()
<<
"
\t
Try bigger values for --work_megapix if something is wrong.
\n\n
"
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int64
app_start_time
=
getTickCount
();
cv
::
setBreakOnError
(
true
);
vector
<
string
>
img_names
;
// Default parameters
bool
trygpu
=
false
;
double
work_megapix
=
0.2
;
double
compose_megapix
=
1
;
int
ba_space
=
BundleAdjuster
::
FOCAL_RAY_SPACE
;
float
conf_thresh
=
1.
f
;
bool
wave_correct
=
true
;
int
warp_type
=
Warper
::
SPHERICAL
;
bool
user_match_conf
=
false
;
float
match_conf
=
0.6
f
;
int
seam_find_type
=
SeamFinder
::
VORONOI
;
int
blend_type
=
Blender
::
MULTI_BAND
;
string
result_name
=
"result.png"
;
double
work_scale
=
1
,
compose_scale
=
1
;
bool
is_work_scale_set
=
false
,
is_compose_scale_set
=
false
;
// Command line args
vector
<
string
>
img_names
;
bool
trygpu
=
false
;
double
work_megapix
=
0.2
;
double
compose_megapix
=
1
;
int
ba_space
=
BundleAdjuster
::
FOCAL_RAY_SPACE
;
float
conf_thresh
=
1.
f
;
bool
wave_correct
=
true
;
int
warp_type
=
Warper
::
SPHERICAL
;
bool
user_match_conf
=
false
;
float
match_conf
=
0.6
f
;
int
seam_find_type
=
SeamFinder
::
VORONOI
;
int
blend_type
=
Blender
::
MULTI_BAND
;
string
result_name
=
"result.png"
;
int
parseCmdArgs
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
1
)
{
printUsage
();
return
0
;
return
-
1
;
}
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
...
...
@@ -70,7 +64,6 @@ int main(int argc, char* argv[])
}
}
int64
t
=
getTickCount
();
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
string
(
argv
[
i
])
==
"--trygpu"
)
...
...
@@ -188,7 +181,20 @@ int main(int argc, char* argv[])
else
img_names
.
push_back
(
argv
[
i
]);
}
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int64
app_start_time
=
getTickCount
();
cv
::
setBreakOnError
(
true
);
int
retval
=
parseCmdArgs
(
argc
,
argv
);
if
(
retval
)
return
retval
;
// Check if have enough images
int
num_images
=
static_cast
<
int
>
(
img_names
.
size
());
if
(
num_images
<
2
)
{
...
...
@@ -196,8 +202,12 @@ int main(int argc, char* argv[])
return
-
1
;
}
// We do all matching in work_scale sclae, and compositing in compose_scale scale
double
work_scale
=
1
,
compose_scale
=
1
;
bool
is_work_scale_set
=
false
,
is_compose_scale_set
=
false
;
LOGLN
(
"Reading images and finding features..."
);
t
=
getTickCount
();
int64
t
=
getTickCount
();
vector
<
Mat
>
images
(
num_images
);
vector
<
ImageFeatures
>
features
(
num_images
);
SurfFeaturesFinder
finder
(
trygpu
);
...
...
@@ -237,6 +247,7 @@ int main(int argc, char* argv[])
matcher
(
features
,
pairwise_matches
);
LOGLN
(
"Pairwise matching, time: "
<<
((
getTickCount
()
-
t
)
/
getTickFrequency
())
<<
" sec"
);
// Leave only images we are sure are from the same panorama
vector
<
int
>
indices
=
leaveBiggestComponent
(
features
,
pairwise_matches
,
conf_thresh
);
vector
<
Mat
>
img_subset
;
vector
<
string
>
img_names_subset
;
...
...
@@ -248,6 +259,7 @@ int main(int argc, char* argv[])
images
=
img_subset
;
img_names
=
img_names_subset
;
// Check if we still have enough images
num_images
=
static_cast
<
int
>
(
img_names
.
size
());
if
(
num_images
<
2
)
{
...
...
@@ -308,12 +320,14 @@ int main(int argc, char* argv[])
vector
<
Size
>
sizes
(
num_images
);
vector
<
Mat
>
masks
(
num_images
);
// Preapre original images masks
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
masks
[
i
].
create
(
images
[
i
].
size
(),
CV_8U
);
masks
[
i
].
setTo
(
Scalar
::
all
(
255
));
}
// Warp images and their masks
Ptr
<
Warper
>
warper
=
Warper
::
createByCameraFocal
(
camera_focal
,
warp_type
);
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
...
...
@@ -324,6 +338,7 @@ int main(int argc, char* argv[])
INTER_NEAREST
,
BORDER_CONSTANT
);
}
// Convert to float for blending
vector
<
Mat
>
images_warped_f
(
num_images
);
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
images_warped
[
i
].
convertTo
(
images_warped_f
[
i
],
CV_32F
);
...
...
@@ -333,6 +348,7 @@ int main(int argc, char* argv[])
LOGLN
(
"Finding seams..."
);
t
=
getTickCount
();
// Find seams
Ptr
<
SeamFinder
>
seam_finder
=
SeamFinder
::
createDefault
(
seam_find_type
);
seam_finder
->
find
(
images_warped_f
,
corners
,
masks_warped
);
...
...
modules/stitching/matchers.cpp
浏览文件 @
97530caa
...
...
@@ -169,11 +169,13 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
dists
[
j
].
idx
=
j
;
}
// Leave near images
vector
<
bool
>
is_near
(
num_images
,
false
);
for
(
int
j
=
0
;
j
<
num_images
;
++
j
)
if
(
dists
[
j
].
dist
<
0.6
)
is_near
[
dists
[
j
].
idx
]
=
true
;
// Leave k-nearest images
int
k
=
min
(
4
,
num_images
);
nth_element
(
dists
.
begin
(),
dists
.
end
(),
dists
.
begin
()
+
k
);
for
(
int
j
=
0
;
j
<
k
;
++
j
)
...
...
@@ -181,6 +183,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
for
(
int
j
=
i
+
1
;
j
<
num_images
;
++
j
)
{
// Ignore poor image pairs
if
(
!
is_near
[
j
])
continue
;
...
...
@@ -213,7 +216,6 @@ namespace
{
public:
inline
CpuMatcher
(
float
match_conf
)
:
match_conf_
(
match_conf
)
{}
void
match
(
const
ImageFeatures
&
features1
,
const
ImageFeatures
&
features2
,
MatchesInfo
&
matches_info
);
private:
...
...
@@ -257,15 +259,12 @@ namespace
{
public:
inline
GpuMatcher
(
float
match_conf
)
:
match_conf_
(
match_conf
)
{}
void
match
(
const
ImageFeatures
&
features1
,
const
ImageFeatures
&
features2
,
MatchesInfo
&
matches_info
);
private:
float
match_conf_
;
GpuMat
descriptors1_
;
GpuMat
descriptors2_
;
GpuMat
trainIdx_
,
distance_
,
allDist_
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录