Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
4567b432
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,发现更多精彩内容 >>
提交
4567b432
编写于
5月 18, 2011
作者:
A
Alexey Spizhevoy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reduced memory requirements in opencv_stitching
上级
71ca501b
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
34 addition
and
40 deletion
+34
-40
modules/stitching/autocalib.cpp
modules/stitching/autocalib.cpp
+1
-1
modules/stitching/blenders.cpp
modules/stitching/blenders.cpp
+11
-19
modules/stitching/blenders.hpp
modules/stitching/blenders.hpp
+0
-2
modules/stitching/main.cpp
modules/stitching/main.cpp
+13
-9
modules/stitching/motion_estimators.cpp
modules/stitching/motion_estimators.cpp
+7
-7
modules/stitching/motion_estimators.hpp
modules/stitching/motion_estimators.hpp
+2
-2
未找到文件。
modules/stitching/autocalib.cpp
浏览文件 @
4567b432
...
@@ -56,7 +56,7 @@ double estimateFocal(const vector<Mat> &images, const vector<ImageFeatures> &/*f
...
@@ -56,7 +56,7 @@ double estimateFocal(const vector<Mat> &images, const vector<ImageFeatures> &/*f
}
}
}
}
if
(
focals
.
size
()
+
1
>=
images
.
size
(
))
if
(
focals
.
size
()
>=
2
*
(
num_images
-
1
))
{
{
nth_element
(
focals
.
begin
(),
focals
.
end
(),
focals
.
begin
()
+
focals
.
size
()
/
2
);
nth_element
(
focals
.
begin
(),
focals
.
end
(),
focals
.
begin
()
+
focals
.
size
()
/
2
);
return
focals
[
focals
.
size
()
/
2
];
return
focals
[
focals
.
size
()
/
2
];
...
...
modules/stitching/blenders.cpp
浏览文件 @
4567b432
...
@@ -133,19 +133,20 @@ Point MultiBandBlender::blend(const vector<Mat> &src, const vector<Point> &corne
...
@@ -133,19 +133,20 @@ Point MultiBandBlender::blend(const vector<Mat> &src, const vector<Point> &corne
int
left
=
corners
[
img_idx
].
x
-
dst_roi
.
x
;
int
left
=
corners
[
img_idx
].
x
-
dst_roi
.
x
;
int
right
=
dst_roi
.
br
().
x
-
corners
[
img_idx
].
x
-
src
[
img_idx
].
cols
;
int
right
=
dst_roi
.
br
().
x
-
corners
[
img_idx
].
x
-
src
[
img_idx
].
cols
;
Mat
big_src
;
vector
<
Mat
>
src_pyr_gauss
(
num_bands_
+
1
);
copyMakeBorder
(
src
[
img_idx
],
big_src
,
top
,
bottom
,
left
,
right
,
BORDER_REFLECT
);
copyMakeBorder
(
src
[
img_idx
],
src_pyr_gauss
[
0
],
top
,
bottom
,
left
,
right
,
BORDER_REFLECT
);
vector
<
Mat
>
src_pyr_gauss
;
for
(
int
i
=
0
;
i
<
num_bands_
;
++
i
)
pyrDown
(
src_pyr_gauss
[
i
],
src_pyr_gauss
[
i
+
1
]);
vector
<
Mat
>
src_pyr_laplace
;
vector
<
Mat
>
src_pyr_laplace
;
createGaussPyr
(
big_src
,
num_bands_
,
src_pyr_gauss
);
createLaplacePyr
(
src_pyr_gauss
,
src_pyr_laplace
);
createLaplacePyr
(
src_pyr_gauss
,
src_pyr_laplace
);
Mat
big_mask
;
vector
<
Mat
>
weight_pyr_gauss
(
num_bands_
+
1
)
;
copyMakeBorder
(
masks
[
img_idx
],
big_mask
,
top
,
bottom
,
left
,
right
,
BORDER_CONSTANT
)
;
Mat
mask_f
;
Mat
weight_map
;
masks
[
img_idx
].
convertTo
(
mask_f
,
CV_32F
,
1.
/
255.
)
;
big_mask
.
convertTo
(
weight_map
,
CV_32F
,
1.
/
255.
);
copyMakeBorder
(
mask_f
,
weight_pyr_gauss
[
0
],
top
,
bottom
,
left
,
right
,
BORDER_CONSTANT
);
vector
<
Mat
>
weight_pyr_gauss
;
for
(
int
i
=
0
;
i
<
num_bands_
;
++
i
)
createGaussPyr
(
weight_map
,
num_bands_
,
weight_pyr_gauss
);
pyrDown
(
weight_pyr_gauss
[
i
],
weight_pyr_gauss
[
i
+
1
]
);
for
(
int
band_idx
=
0
;
band_idx
<=
num_bands_
;
++
band_idx
)
for
(
int
band_idx
=
0
;
band_idx
<=
num_bands_
;
++
band_idx
)
{
{
...
@@ -286,15 +287,6 @@ void createWeightMap(const Mat &mask, float sharpness, Mat &weight)
...
@@ -286,15 +287,6 @@ void createWeightMap(const Mat &mask, float sharpness, Mat &weight)
}
}
void
createGaussPyr
(
const
Mat
&
img
,
int
num_layers
,
vector
<
Mat
>
&
pyr
)
{
pyr
.
resize
(
num_layers
+
1
);
pyr
[
0
]
=
img
.
clone
();
for
(
int
i
=
0
;
i
<
num_layers
;
++
i
)
pyrDown
(
pyr
[
i
],
pyr
[
i
+
1
]);
}
void
createLaplacePyr
(
const
vector
<
Mat
>
&
pyr_gauss
,
vector
<
Mat
>
&
pyr_laplace
)
void
createLaplacePyr
(
const
vector
<
Mat
>
&
pyr_gauss
,
vector
<
Mat
>
&
pyr_laplace
)
{
{
if
(
pyr_gauss
.
size
()
==
0
)
if
(
pyr_gauss
.
size
()
==
0
)
...
...
modules/stitching/blenders.hpp
浏览文件 @
4567b432
...
@@ -63,8 +63,6 @@ void normalize(const cv::Mat& weight, cv::Mat& src);
...
@@ -63,8 +63,6 @@ void normalize(const cv::Mat& weight, cv::Mat& src);
void
createWeightMap
(
const
cv
::
Mat
&
mask
,
float
sharpness
,
cv
::
Mat
&
weight
);
void
createWeightMap
(
const
cv
::
Mat
&
mask
,
float
sharpness
,
cv
::
Mat
&
weight
);
void
createGaussPyr
(
const
cv
::
Mat
&
img
,
int
num_layers
,
std
::
vector
<
cv
::
Mat
>&
pyr
);
void
createLaplacePyr
(
const
std
::
vector
<
cv
::
Mat
>&
pyr_gauss
,
std
::
vector
<
cv
::
Mat
>&
pyr_laplace
);
void
createLaplacePyr
(
const
std
::
vector
<
cv
::
Mat
>&
pyr_gauss
,
std
::
vector
<
cv
::
Mat
>&
pyr_laplace
);
// Restores source image in-place. Result will be stored in pyr[0].
// Restores source image in-place. Result will be stored in pyr[0].
...
...
modules/stitching/main.cpp
浏览文件 @
4567b432
...
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
...
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
vector
<
string
>
img_names
;
vector
<
string
>
img_names
;
vector
<
Mat
>
images
;
vector
<
Mat
>
images
;
bool
trygpu
=
true
;
bool
trygpu
=
true
;
double
work_megapix
=
-
1
;
double
work_megapix
=
1
;
double
compose_megapix
=
-
1
;
double
compose_megapix
=
1
;
int
ba_space
=
BundleAdjuster
::
FOCAL_RAY_SPACE
;
int
ba_space
=
BundleAdjuster
::
FOCAL_RAY_SPACE
;
float
conf_thresh
=
1.
f
;
float
conf_thresh
=
1.
f
;
bool
wave_correct
=
true
;
bool
wave_correct
=
true
;
...
@@ -47,8 +47,8 @@ int main(int argc, char* argv[])
...
@@ -47,8 +47,8 @@ int main(int argc, char* argv[])
int
blend_type
=
Blender
::
MULTI_BAND
;
int
blend_type
=
Blender
::
MULTI_BAND
;
string
result_name
=
"result.png"
;
string
result_name
=
"result.png"
;
double
work_scale
=
1
,
compose_scale
=
1
;
double
work_scale
,
compose_scale
;
bool
is_work_scale_set
=
false
,
is_compose_scale_set
=
tru
e
;
bool
is_work_scale_set
=
false
,
is_compose_scale_set
=
fals
e
;
if
(
argc
==
1
)
if
(
argc
==
1
)
{
{
...
@@ -85,7 +85,6 @@ int main(int argc, char* argv[])
...
@@ -85,7 +85,6 @@ int main(int argc, char* argv[])
else
if
(
string
(
argv
[
i
])
==
"--compose_megapix"
)
else
if
(
string
(
argv
[
i
])
==
"--compose_megapix"
)
{
{
compose_megapix
=
atof
(
argv
[
i
+
1
]);
compose_megapix
=
atof
(
argv
[
i
+
1
]);
is_compose_scale_set
=
false
;
i
++
;
i
++
;
}
}
else
if
(
string
(
argv
[
i
])
==
"--result"
)
else
if
(
string
(
argv
[
i
])
==
"--result"
)
...
@@ -195,7 +194,7 @@ int main(int argc, char* argv[])
...
@@ -195,7 +194,7 @@ int main(int argc, char* argv[])
{
{
if
(
!
is_work_scale_set
)
if
(
!
is_work_scale_set
)
{
{
work_scale
=
min
(
1.0
,
sqrt
(
work_megapix
*
1
000000
/
full_img
.
size
().
area
()));
work_scale
=
min
(
1.0
,
sqrt
(
work_megapix
*
1
e6
/
full_img
.
size
().
area
()));
is_work_scale_set
=
true
;
is_work_scale_set
=
true
;
}
}
Mat
img
;
Mat
img
;
...
@@ -224,7 +223,11 @@ int main(int argc, char* argv[])
...
@@ -224,7 +223,11 @@ int main(int argc, char* argv[])
matcher
=
BestOf2NearestMatcher
(
true
,
match_conf
);
matcher
=
BestOf2NearestMatcher
(
true
,
match_conf
);
matcher
(
images
,
features
,
pairwise_matches
);
matcher
(
images
,
features
,
pairwise_matches
);
leaveBiggestComponent
(
images
,
features
,
pairwise_matches
,
conf_thresh
);
vector
<
int
>
indices
=
leaveBiggestComponent
(
images
,
features
,
pairwise_matches
,
conf_thresh
);
vector
<
string
>
img_names_subset
;
for
(
size_t
i
=
0
;
i
<
indices
.
size
();
++
i
)
img_names_subset
.
push_back
(
img_names
[
indices
[
i
]]);
img_names
=
img_names_subset
;
num_images
=
static_cast
<
int
>
(
images
.
size
());
num_images
=
static_cast
<
int
>
(
images
.
size
());
if
(
num_images
<
2
)
if
(
num_images
<
2
)
...
@@ -271,14 +274,15 @@ int main(int argc, char* argv[])
...
@@ -271,14 +274,15 @@ int main(int argc, char* argv[])
nth_element
(
focals
.
begin
(),
focals
.
end
(),
focals
.
begin
()
+
focals
.
size
()
/
2
);
nth_element
(
focals
.
begin
(),
focals
.
end
(),
focals
.
begin
()
+
focals
.
size
()
/
2
);
float
camera_focal
=
static_cast
<
float
>
(
focals
[
focals
.
size
()
/
2
]);
float
camera_focal
=
static_cast
<
float
>
(
focals
[
focals
.
size
()
/
2
]);
if
(
work_megapix
>
0
||
compose_megapix
>
0
)
if
((
work_megapix
>
0
||
compose_megapix
>
0
)
&&
abs
(
work_megapix
-
compose_megapix
)
>
1e-3
)
{
{
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
for
(
int
i
=
0
;
i
<
num_images
;
++
i
)
{
{
Mat
full_img
=
imread
(
img_names
[
i
]);
Mat
full_img
=
imread
(
img_names
[
i
]);
if
(
!
is_compose_scale_set
)
if
(
!
is_compose_scale_set
)
{
{
compose_scale
=
min
(
1.0
,
sqrt
(
compose_megapix
*
1
000000
/
full_img
.
size
().
area
()));
compose_scale
=
min
(
1.0
,
sqrt
(
compose_megapix
*
1
e6
/
full_img
.
size
().
area
()));
is_compose_scale_set
=
true
;
is_compose_scale_set
=
true
;
}
}
Mat
img
;
Mat
img
;
...
...
modules/stitching/motion_estimators.cpp
浏览文件 @
4567b432
...
@@ -328,8 +328,7 @@ void waveCorrect(vector<Mat> &rmats)
...
@@ -328,8 +328,7 @@ void waveCorrect(vector<Mat> &rmats)
SVD
svd
;
SVD
svd
;
svd
(
cov
,
SVD
::
FULL_UV
);
svd
(
cov
,
SVD
::
FULL_UV
);
svd
.
vt
.
row
(
2
).
copyTo
(
r1
);
svd
.
vt
.
row
(
2
).
copyTo
(
r1
);
if
(
determinant
(
svd
.
vt
)
<
0
)
if
(
determinant
(
svd
.
vt
)
<
0
)
r1
*=
-
1
;
r1
*=
-
1
;
Mat
avgz
=
Mat
::
zeros
(
3
,
1
,
CV_32F
);
Mat
avgz
=
Mat
::
zeros
(
3
,
1
,
CV_32F
);
for
(
size_t
i
=
0
;
i
<
rmats
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
rmats
.
size
();
++
i
)
...
@@ -338,8 +337,7 @@ void waveCorrect(vector<Mat> &rmats)
...
@@ -338,8 +337,7 @@ void waveCorrect(vector<Mat> &rmats)
normalize
(
r0
,
r0
);
normalize
(
r0
,
r0
);
r1
.
cross
(
r0
).
copyTo
(
r2
);
r1
.
cross
(
r0
).
copyTo
(
r2
);
if
(
determinant
(
R
)
<
0
)
if
(
determinant
(
R
)
<
0
)
R
*=
-
1
;
R
*=
-
1
;
for
(
size_t
i
=
0
;
i
<
rmats
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
rmats
.
size
();
++
i
)
rmats
[
i
]
=
R
*
rmats
[
i
];
rmats
[
i
]
=
R
*
rmats
[
i
];
...
@@ -348,7 +346,7 @@ void waveCorrect(vector<Mat> &rmats)
...
@@ -348,7 +346,7 @@ void waveCorrect(vector<Mat> &rmats)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
v
oid
leaveBiggestComponent
(
vector
<
Mat
>
&
images
,
vector
<
ImageFeatures
>
&
features
,
v
ector
<
int
>
leaveBiggestComponent
(
vector
<
Mat
>
&
images
,
vector
<
ImageFeatures
>
&
features
,
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
)
{
{
const
int
num_images
=
static_cast
<
int
>
(
images
.
size
());
const
int
num_images
=
static_cast
<
int
>
(
images
.
size
());
...
@@ -393,7 +391,7 @@ void leaveBiggestComponent(vector<Mat> &images, vector<ImageFeatures> &features,
...
@@ -393,7 +391,7 @@ void leaveBiggestComponent(vector<Mat> &images, vector<ImageFeatures> &features,
}
}
if
(
static_cast
<
int
>
(
images_subset
.
size
())
==
num_images
)
if
(
static_cast
<
int
>
(
images_subset
.
size
())
==
num_images
)
return
;
return
indices
;
LOG
(
"Removed some images, because can't match them: ("
);
LOG
(
"Removed some images, because can't match them: ("
);
LOG
(
indices_removed
[
0
]);
LOG
(
indices_removed
[
0
]);
...
@@ -403,6 +401,8 @@ void leaveBiggestComponent(vector<Mat> &images, vector<ImageFeatures> &features,
...
@@ -403,6 +401,8 @@ void leaveBiggestComponent(vector<Mat> &images, vector<ImageFeatures> &features,
images
=
images_subset
;
images
=
images_subset
;
features
=
features_subset
;
features
=
features_subset
;
pairwise_matches
=
pairwise_matches_subset
;
pairwise_matches
=
pairwise_matches_subset
;
return
indices
;
}
}
...
...
modules/stitching/motion_estimators.hpp
浏览文件 @
4567b432
...
@@ -83,7 +83,7 @@ void waveCorrect(std::vector<cv::Mat> &rmats);
...
@@ -83,7 +83,7 @@ void waveCorrect(std::vector<cv::Mat> &rmats);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Auxiliary functions
// Auxiliary functions
void
leaveBiggestComponent
(
std
::
vector
<
cv
::
Mat
>
&
images
,
std
::
vector
<
ImageFeatures
>
&
features
,
std
::
vector
<
int
>
leaveBiggestComponent
(
std
::
vector
<
cv
::
Mat
>
&
images
,
std
::
vector
<
ImageFeatures
>
&
features
,
std
::
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
);
std
::
vector
<
MatchesInfo
>
&
pairwise_matches
,
float
conf_threshold
);
void
findMaxSpanningTree
(
int
num_images
,
const
std
::
vector
<
MatchesInfo
>
&
pairwise_matches
,
void
findMaxSpanningTree
(
int
num_images
,
const
std
::
vector
<
MatchesInfo
>
&
pairwise_matches
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录