Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f44632ee
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,发现更多精彩内容 >>
提交
f44632ee
编写于
5月 23, 2011
作者:
A
Alexey Spizhevoy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
switched float with short in blending step (opencv_stitching)
上级
5bf8109d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
23 deletion
+37
-23
modules/imgproc/src/pyramids.cpp
modules/imgproc/src/pyramids.cpp
+4
-0
modules/stitching/autocalib.cpp
modules/stitching/autocalib.cpp
+1
-1
modules/stitching/blenders.cpp
modules/stitching/blenders.cpp
+29
-18
modules/stitching/main.cpp
modules/stitching/main.cpp
+3
-4
未找到文件。
modules/imgproc/src/pyramids.cpp
浏览文件 @
f44632ee
...
...
@@ -411,6 +411,8 @@ void cv::pyrDown( const InputArray& _src, OutputArray _dst, const Size& _dsz )
PyrFunc
func
=
0
;
if
(
depth
==
CV_8U
)
func
=
pyrDown_
<
FixPtCast
<
uchar
,
8
>
,
PyrDownVec_32s8u
>
;
else
if
(
depth
==
CV_16S
)
func
=
pyrDown_
<
FixPtCast
<
short
,
8
>
,
NoVec
<
int
,
short
>
>
;
else
if
(
depth
==
CV_16U
)
func
=
pyrDown_
<
FixPtCast
<
ushort
,
8
>
,
NoVec
<
int
,
ushort
>
>
;
else
if
(
depth
==
CV_32F
)
...
...
@@ -433,6 +435,8 @@ void cv::pyrUp( const InputArray& _src, OutputArray _dst, const Size& _dsz )
PyrFunc
func
=
0
;
if
(
depth
==
CV_8U
)
func
=
pyrUp_
<
FixPtCast
<
uchar
,
6
>
,
NoVec
<
int
,
uchar
>
>
;
else
if
(
depth
==
CV_16S
)
func
=
pyrUp_
<
FixPtCast
<
short
,
6
>
,
NoVec
<
int
,
short
>
>
;
else
if
(
depth
==
CV_16U
)
func
=
pyrUp_
<
FixPtCast
<
ushort
,
6
>
,
NoVec
<
int
,
ushort
>
>
;
else
if
(
depth
==
CV_32F
)
...
...
modules/stitching/autocalib.cpp
浏览文件 @
f44632ee
...
...
@@ -96,7 +96,7 @@ double estimateFocal(const vector<ImageFeatures> &features, const vector<Matches
}
}
if
(
static_cast
<
int
>
(
focals
.
size
())
>=
2
*
(
num_images
-
1
)
)
if
(
static_cast
<
int
>
(
focals
.
size
())
>=
num_images
*
(
num_images
-
1
)
/
2
)
{
nth_element
(
focals
.
begin
(),
focals
.
end
(),
focals
.
begin
()
+
focals
.
size
()
/
2
);
return
focals
[
focals
.
size
()
/
2
];
...
...
modules/stitching/blenders.cpp
浏览文件 @
f44632ee
...
...
@@ -68,7 +68,7 @@ void Blender::prepare(const vector<Point> &corners, const vector<Size> &sizes)
void
Blender
::
prepare
(
Rect
dst_roi
)
{
dst_
.
create
(
dst_roi
.
size
(),
CV_
32F
C3
);
dst_
.
create
(
dst_roi
.
size
(),
CV_
16S
C3
);
dst_
.
setTo
(
Scalar
::
all
(
0
));
dst_mask_
.
create
(
dst_roi
.
size
(),
CV_8U
);
dst_mask_
.
setTo
(
Scalar
::
all
(
0
));
...
...
@@ -78,7 +78,7 @@ void Blender::prepare(Rect dst_roi)
void
Blender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_
32F
C3
);
CV_Assert
(
img
.
type
()
==
CV_
16S
C3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
int
dx
=
tl
.
x
-
dst_roi_
.
x
;
...
...
@@ -86,8 +86,8 @@ void Blender::feed(const Mat &img, const Mat &mask, Point tl)
for
(
int
y
=
0
;
y
<
img
.
rows
;
++
y
)
{
const
Point3
f
*
src_row
=
img
.
ptr
<
Point3f
>
(
y
);
Point3
f
*
dst_row
=
dst_
.
ptr
<
Point3f
>
(
dy
+
y
);
const
Point3
_
<
short
>
*
src_row
=
img
.
ptr
<
Point3_
<
short
>
>
(
y
);
Point3
_
<
short
>
*
dst_row
=
dst_
.
ptr
<
Point3_
<
short
>
>
(
dy
+
y
);
const
uchar
*
mask_row
=
mask
.
ptr
<
uchar
>
(
y
);
uchar
*
dst_mask_row
=
dst_mask_
.
ptr
<
uchar
>
(
dy
+
y
);
...
...
@@ -122,7 +122,7 @@ void FeatherBlender::prepare(Rect dst_roi)
void
FeatherBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_
32F
C3
);
CV_Assert
(
img
.
type
()
==
CV_
16S
C3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
int
dx
=
tl
.
x
-
dst_roi_
.
x
;
...
...
@@ -132,15 +132,17 @@ void FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)
for
(
int
y
=
0
;
y
<
img
.
rows
;
++
y
)
{
const
Point3
f
*
src_row
=
img
.
ptr
<
Point3f
>
(
y
);
Point3
f
*
dst_row
=
dst_
.
ptr
<
Point3f
>
(
dy
+
y
);
const
Point3
_
<
short
>*
src_row
=
img
.
ptr
<
Point3_
<
short
>
>
(
y
);
Point3
_
<
short
>*
dst_row
=
dst_
.
ptr
<
Point3_
<
short
>
>
(
dy
+
y
);
const
float
*
weight_row
=
weight_map_
.
ptr
<
float
>
(
y
);
float
*
dst_weight_row
=
dst_weight_map_
.
ptr
<
float
>
(
dy
+
y
);
for
(
int
x
=
0
;
x
<
img
.
cols
;
++
x
)
{
dst_row
[
dx
+
x
]
+=
src_row
[
x
]
*
weight_row
[
x
];
dst_row
[
dx
+
x
].
x
+=
static_cast
<
short
>
(
src_row
[
x
].
x
*
weight_row
[
x
]);
dst_row
[
dx
+
x
].
y
+=
static_cast
<
short
>
(
src_row
[
x
].
y
*
weight_row
[
x
]);
dst_row
[
dx
+
x
].
z
+=
static_cast
<
short
>
(
src_row
[
x
].
z
*
weight_row
[
x
]);
dst_weight_row
[
dx
+
x
]
+=
weight_row
[
x
];
}
}
...
...
@@ -169,7 +171,7 @@ void MultiBandBlender::prepare(Rect dst_roi)
for
(
int
i
=
1
;
i
<=
num_bands_
;
++
i
)
{
dst_pyr_laplace_
[
i
].
create
((
dst_pyr_laplace_
[
i
-
1
].
rows
+
1
)
/
2
,
(
dst_pyr_laplace_
[
i
-
1
].
cols
+
1
)
/
2
,
CV_
32F
C3
);
(
dst_pyr_laplace_
[
i
-
1
].
cols
+
1
)
/
2
,
CV_
16S
C3
);
dst_band_weights_
[
i
].
create
((
dst_band_weights_
[
i
-
1
].
rows
+
1
)
/
2
,
(
dst_band_weights_
[
i
-
1
].
cols
+
1
)
/
2
,
CV_32F
);
dst_pyr_laplace_
[
i
].
setTo
(
Scalar
::
all
(
0
));
...
...
@@ -180,7 +182,7 @@ void MultiBandBlender::prepare(Rect dst_roi)
void
MultiBandBlender
::
feed
(
const
Mat
&
img
,
const
Mat
&
mask
,
Point
tl
)
{
CV_Assert
(
img
.
type
()
==
CV_
32F
C3
);
CV_Assert
(
img
.
type
()
==
CV_
16S
C3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
int
top
=
tl
.
y
-
dst_roi_
.
y
;
...
...
@@ -212,13 +214,17 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
{
for
(
int
y
=
0
;
y
<
dst_pyr_laplace_
[
i
].
rows
;
++
y
)
{
const
Point3
f
*
src_row
=
src_pyr_laplace
[
i
].
ptr
<
Point3f
>
(
y
);
Point3
f
*
dst_row
=
dst_pyr_laplace_
[
i
].
ptr
<
Point3f
>
(
y
);
const
Point3
_
<
short
>*
src_row
=
src_pyr_laplace
[
i
].
ptr
<
Point3_
<
short
>
>
(
y
);
Point3
_
<
short
>*
dst_row
=
dst_pyr_laplace_
[
i
].
ptr
<
Point3_
<
short
>
>
(
y
);
const
float
*
weight_row
=
weight_pyr_gauss
[
i
].
ptr
<
float
>
(
y
);
for
(
int
x
=
0
;
x
<
dst_pyr_laplace_
[
i
].
cols
;
++
x
)
dst_row
[
x
]
+=
src_row
[
x
]
*
weight_row
[
x
];
{
dst_row
[
x
].
x
+=
static_cast
<
short
>
(
src_row
[
x
].
x
*
weight_row
[
x
]);
dst_row
[
x
].
y
+=
static_cast
<
short
>
(
src_row
[
x
].
y
*
weight_row
[
x
]);
dst_row
[
x
].
z
+=
static_cast
<
short
>
(
src_row
[
x
].
z
*
weight_row
[
x
]);
}
}
dst_band_weights_
[
i
]
+=
weight_pyr_gauss
[
i
];
}
...
...
@@ -265,14 +271,18 @@ Rect resultRoi(const vector<Point> &corners, const vector<Size> &sizes)
void
normalize
(
const
Mat
&
weight
,
Mat
&
src
)
{
CV_Assert
(
weight
.
type
()
==
CV_32F
);
CV_Assert
(
src
.
type
()
==
CV_
32F
C3
);
CV_Assert
(
src
.
type
()
==
CV_
16S
C3
);
for
(
int
y
=
0
;
y
<
src
.
rows
;
++
y
)
{
Point3
f
*
row
=
src
.
ptr
<
Point3f
>
(
y
);
Point3
_
<
short
>
*
row
=
src
.
ptr
<
Point3_
<
short
>
>
(
y
);
const
float
*
weight_row
=
weight
.
ptr
<
float
>
(
y
);
for
(
int
x
=
0
;
x
<
src
.
cols
;
++
x
)
row
[
x
]
*=
1.
f
/
(
weight_row
[
x
]
+
WEIGHT_EPS
);
{
row
[
x
].
x
=
static_cast
<
short
>
(
row
[
x
].
x
/
(
weight_row
[
x
]
+
WEIGHT_EPS
));
row
[
x
].
y
=
static_cast
<
short
>
(
row
[
x
].
y
/
(
weight_row
[
x
]
+
WEIGHT_EPS
));
row
[
x
].
z
=
static_cast
<
short
>
(
row
[
x
].
z
/
(
weight_row
[
x
]
+
WEIGHT_EPS
));
}
}
}
...
...
@@ -296,7 +306,7 @@ void createLaplacePyr(const vector<Mat> &pyr_gauss, vector<Mat> &pyr_laplace)
for
(
size_t
i
=
0
;
i
<
pyr_laplace
.
size
()
-
1
;
++
i
)
{
pyrUp
(
pyr_gauss
[
i
+
1
],
tmp
,
pyr_gauss
[
i
].
size
());
pyr_laplace
[
i
]
=
pyr_gauss
[
i
]
-
tmp
;
subtract
(
pyr_gauss
[
i
],
tmp
,
pyr_laplace
[
i
])
;
}
pyr_laplace
[
pyr_laplace
.
size
()
-
1
]
=
pyr_gauss
[
pyr_laplace
.
size
()
-
1
].
clone
();
}
...
...
@@ -311,6 +321,7 @@ void restoreImageFromLaplacePyr(vector<Mat> &pyr)
for
(
size_t
i
=
pyr
.
size
()
-
1
;
i
>
0
;
--
i
)
{
pyrUp
(
pyr
[
i
],
tmp
,
pyr
[
i
-
1
].
size
());
pyr
[
i
-
1
]
+=
tmp
;
add
(
tmp
,
pyr
[
i
-
1
],
pyr
[
i
-
1
])
;
}
}
modules/stitching/main.cpp
浏览文件 @
f44632ee
...
...
@@ -401,7 +401,6 @@ int main(int argc, char* argv[])
cameras
[
i
].
R
,
masks_warped
[
i
],
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
);
...
...
@@ -426,7 +425,7 @@ int main(int argc, char* argv[])
LOGLN
(
"Compositing..."
);
t
=
getTickCount
();
Mat
img_warped
,
img_warped_
f
;
Mat
img_warped
,
img_warped_
s
;
Mat
dilated_mask
,
seam_mask
,
mask
,
mask_warped
;
Ptr
<
Blender
>
blender
;
double
compose_seam_aspect
=
1
;
...
...
@@ -461,7 +460,7 @@ int main(int argc, char* argv[])
// Warp the current image
warper
->
warp
(
img
,
static_cast
<
float
>
(
cameras
[
img_idx
].
focal
),
cameras
[
img_idx
].
R
,
img_warped
);
img_warped
.
convertTo
(
img_warped_
f
,
CV_32F
);
img_warped
.
convertTo
(
img_warped_
s
,
CV_16S
);
img_warped
.
release
();
img
.
release
();
...
...
@@ -497,7 +496,7 @@ int main(int argc, char* argv[])
}
// Blend the current image
blender
->
feed
(
img_warped_
f
,
mask_warped
,
corners
[
img_idx
]);
blender
->
feed
(
img_warped_
s
,
mask_warped
,
corners
[
img_idx
]);
}
Mat
result
,
result_mask
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录