Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
a39bce20
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,发现更多精彩内容 >>
提交
a39bce20
编写于
8月 02, 2012
作者:
A
alexey.spizhevoy
提交者:
Alexey Spizhevoy
8月 07, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented DP-based seam estimation method
上级
cd58b7e1
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
966 addition
and
1 deletion
+966
-1
modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp
...itching/include/opencv2/stitching/detail/seam_finders.hpp
+109
-0
modules/stitching/src/seam_finders.cpp
modules/stitching/src/seam_finders.cpp
+850
-0
samples/cpp/stitching_detailed.cpp
samples/cpp/stitching_detailed.cpp
+7
-1
未找到文件。
modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp
浏览文件 @
a39bce20
...
...
@@ -43,6 +43,7 @@
#ifndef __OPENCV_STITCHING_SEAM_FINDERS_HPP__
#define __OPENCV_STITCHING_SEAM_FINDERS_HPP__
#include <set>
#include "opencv2/core/core.hpp"
#include "opencv2/opencv_modules.hpp"
...
...
@@ -92,6 +93,114 @@ private:
};
class
CV_EXPORTS
DpSeamFinder
:
public
SeamFinder
{
public:
enum
CostFunction
{
COLOR
,
COLOR_GRAD
};
DpSeamFinder
(
CostFunction
costFunc
=
COLOR_GRAD
);
CostFunction
costFunction
()
const
{
return
costFunc_
;
}
void
setCostFunction
(
CostFunction
val
)
{
costFunc_
=
val
;
}
private:
enum
ComponentState
{
FIRST
=
1
,
SECOND
=
2
,
INTERS
=
4
,
INTERS_FIRST
=
INTERS
|
FIRST
,
INTERS_SECOND
=
INTERS
|
SECOND
};
class
ImagePairLess
{
public:
ImagePairLess
(
const
std
::
vector
<
Mat
>
&
images
,
const
std
::
vector
<
Point
>
&
corners
)
:
src_
(
&
images
[
0
]),
corners_
(
&
corners
[
0
])
{}
bool
operator
()
(
const
std
::
pair
<
int
,
int
>
&
l
,
const
std
::
pair
<
int
,
int
>
&
r
)
const
{
Point
c1
=
corners_
[
l
.
first
]
+
Point
(
src_
[
l
.
first
].
cols
/
2
,
src_
[
l
.
first
].
rows
/
2
);
Point
c2
=
corners_
[
l
.
second
]
+
Point
(
src_
[
l
.
second
].
cols
/
2
,
src_
[
l
.
second
].
rows
/
2
);
int
d1
=
(
c1
-
c2
).
dot
(
c1
-
c2
);
c1
=
corners_
[
r
.
first
]
+
Point
(
src_
[
r
.
first
].
cols
/
2
,
src_
[
r
.
first
].
rows
/
2
);
c2
=
corners_
[
r
.
second
]
+
Point
(
src_
[
r
.
second
].
cols
/
2
,
src_
[
r
.
second
].
rows
/
2
);
int
d2
=
(
c1
-
c2
).
dot
(
c1
-
c2
);
return
d1
<
d2
;
}
private:
const
Mat
*
src_
;
const
Point
*
corners_
;
};
class
ClosePoints
{
public:
ClosePoints
(
int
minDist
)
:
minDist_
(
minDist
)
{}
bool
operator
()
(
const
Point
&
p1
,
const
Point
&
p2
)
const
{
int
dist2
=
(
p1
.
x
-
p2
.
x
)
*
(
p1
.
x
-
p2
.
x
)
+
(
p1
.
y
-
p2
.
y
)
*
(
p1
.
y
-
p2
.
y
);
return
dist2
<
minDist_
*
minDist_
;
}
private:
int
minDist_
;
};
virtual
void
find
(
const
std
::
vector
<
Mat
>
&
src
,
const
std
::
vector
<
Point
>
&
corners
,
std
::
vector
<
Mat
>
&
masks
);
void
process
(
const
Mat
&
image1
,
const
Mat
&
image2
,
Point
tl1
,
Point
tl2
,
Mat
&
mask1
,
Mat
&
mask2
);
void
findComponents
();
void
findEdges
();
void
resolveConflicts
(
const
Mat
&
image1
,
const
Mat
&
image2
,
Point
tl1
,
Point
tl2
,
Mat
&
mask1
,
Mat
&
mask2
);
void
computeGradients
(
const
Mat
&
image1
,
const
Mat
&
image2
);
bool
hasOnlyOneNeighbor
(
int
c
);
bool
closeToContour
(
int
y
,
int
x
,
const
Mat_
<
uchar
>
&
contourMask
);
bool
getSeamTips
(
int
c1
,
int
c2
,
Point
&
p1
,
Point
&
p2
);
void
computeCosts
(
const
Mat
&
image1
,
const
Mat
&
image2
,
Point
tl1
,
Point
tl2
,
int
c
,
Mat_
<
float
>
&
costV
,
Mat_
<
float
>
&
costH
);
bool
estimateSeam
(
const
Mat
&
image1
,
const
Mat
&
image2
,
Point
tl1
,
Point
tl2
,
int
c
,
Point
p1
,
Point
p2
,
std
::
vector
<
Point
>
&
seam
,
bool
&
isHorizontal
);
void
updateLabelsUsingSeam
(
int
c1
,
int
c2
,
const
std
::
vector
<
Point
>
&
seam
,
bool
isHorizontalSeam
);
CostFunction
costFunc_
;
// processing images pair data
Point
unionTl_
,
unionBr_
;
Size
unionSize_
;
Mat_
<
uchar
>
mask1_
,
mask2_
;
Mat_
<
uchar
>
contour1mask_
,
contour2mask_
;
Mat_
<
float
>
gradx1_
,
grady1_
;
Mat_
<
float
>
gradx2_
,
grady2_
;
// components data
int
ncomps_
;
Mat_
<
int
>
labels_
;
std
::
vector
<
ComponentState
>
states_
;
std
::
vector
<
Point
>
tls_
,
brs_
;
std
::
vector
<
std
::
vector
<
Point
>
>
contours_
;
std
::
set
<
std
::
pair
<
int
,
int
>
>
edges_
;
};
class
CV_EXPORTS
GraphCutSeamFinderBase
{
public:
...
...
modules/stitching/src/seam_finders.cpp
浏览文件 @
a39bce20
此差异已折叠。
点击以展开。
samples/cpp/stitching_detailed.cpp
浏览文件 @
a39bce20
...
...
@@ -276,7 +276,9 @@ static int parseCmdArgs(int argc, char** argv)
if
(
string
(
argv
[
i
+
1
])
==
"no"
||
string
(
argv
[
i
+
1
])
==
"voronoi"
||
string
(
argv
[
i
+
1
])
==
"gc_color"
||
string
(
argv
[
i
+
1
])
==
"gc_colorgrad"
)
string
(
argv
[
i
+
1
])
==
"gc_colorgrad"
||
string
(
argv
[
i
+
1
])
==
"dp_color"
||
string
(
argv
[
i
+
1
])
==
"dp_colorgrad"
)
seam_find_type
=
argv
[
i
+
1
];
else
{
...
...
@@ -612,6 +614,10 @@ int main(int argc, char* argv[])
#endif
seam_finder
=
new
detail
::
GraphCutSeamFinder
(
GraphCutSeamFinderBase
::
COST_COLOR_GRAD
);
}
else
if
(
seam_find_type
==
"dp_color"
)
seam_finder
=
new
detail
::
DpSeamFinder
(
DpSeamFinder
::
COLOR
);
else
if
(
seam_find_type
==
"dp_colorgrad"
)
seam_finder
=
new
detail
::
DpSeamFinder
(
DpSeamFinder
::
COLOR_GRAD
);
if
(
seam_finder
.
empty
())
{
cout
<<
"Can't create the following seam finder '"
<<
seam_find_type
<<
"'
\n
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录