Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
883b995f
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,发现更多精彩内容 >>
提交
883b995f
编写于
8月 03, 2020
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18012 from sturkmen72:update_doc_and_sample
上级
a2853393
c262eea8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
8 deletion
+13
-8
modules/imgproc/include/opencv2/imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+1
-1
samples/cpp/warpPerspective_demo.cpp
samples/cpp/warpPerspective_demo.cpp
+12
-7
未找到文件。
modules/imgproc/include/opencv2/imgproc.hpp
浏览文件 @
883b995f
...
...
@@ -2263,7 +2263,7 @@ CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst,
const
Scalar
&
borderValue
=
Scalar
());
/** @example samples/cpp/warpPerspective_demo.cpp
An example program shows using cv::
findHomography
and cv::warpPerspective for image warping
An example program shows using cv::
getPerspectiveTransform
and cv::warpPerspective for image warping
*/
/** @brief Applies a perspective transformation to an image.
...
...
samples/cpp/warpPerspective_demo.cpp
浏览文件 @
883b995f
...
...
@@ -8,7 +8,6 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include <iostream>
using
namespace
std
;
...
...
@@ -36,6 +35,7 @@ Mat warping(Mat image, Size warped_image_size, vector< Point2f> srcPoints, vecto
String
windowTitle
=
"Perspective Transformation Demo"
;
String
labels
[
4
]
=
{
"TL"
,
"TR"
,
"BR"
,
"BL"
};
vector
<
Point2f
>
roi_corners
;
vector
<
Point2f
>
midpoints
(
4
);
vector
<
Point2f
>
dst_corners
(
4
);
int
roiIndex
=
0
;
bool
dragging
;
...
...
@@ -99,21 +99,26 @@ int main(int argc, char** argv)
imshow
(
windowTitle
,
image
);
midpoints
[
0
]
=
(
roi_corners
[
0
]
+
roi_corners
[
1
])
/
2
;
midpoints
[
1
]
=
(
roi_corners
[
1
]
+
roi_corners
[
2
])
/
2
;
midpoints
[
2
]
=
(
roi_corners
[
2
]
+
roi_corners
[
3
])
/
2
;
midpoints
[
3
]
=
(
roi_corners
[
3
]
+
roi_corners
[
0
])
/
2
;
dst_corners
[
0
].
x
=
0
;
dst_corners
[
0
].
y
=
0
;
dst_corners
[
1
].
x
=
(
float
)
std
::
max
(
norm
(
roi_corners
[
0
]
-
roi_corners
[
1
]),
norm
(
roi_corners
[
2
]
-
roi_corners
[
3
])
);
dst_corners
[
1
].
x
=
(
float
)
norm
(
midpoints
[
1
]
-
midpoints
[
3
]
);
dst_corners
[
1
].
y
=
0
;
dst_corners
[
2
].
x
=
(
float
)
std
::
max
(
norm
(
roi_corners
[
0
]
-
roi_corners
[
1
]),
norm
(
roi_corners
[
2
]
-
roi_corners
[
3
]))
;
dst_corners
[
2
].
y
=
(
float
)
std
::
max
(
norm
(
roi_corners
[
1
]
-
roi_corners
[
2
]),
norm
(
roi_corners
[
3
]
-
roi_corners
[
0
])
);
dst_corners
[
2
].
x
=
dst_corners
[
1
].
x
;
dst_corners
[
2
].
y
=
(
float
)
norm
(
midpoints
[
0
]
-
midpoints
[
2
]
);
dst_corners
[
3
].
x
=
0
;
dst_corners
[
3
].
y
=
(
float
)
std
::
max
(
norm
(
roi_corners
[
1
]
-
roi_corners
[
2
]),
norm
(
roi_corners
[
3
]
-
roi_corners
[
0
]))
;
dst_corners
[
3
].
y
=
dst_corners
[
2
].
y
;
Size
warped_image_size
=
Size
(
cvRound
(
dst_corners
[
2
].
x
),
cvRound
(
dst_corners
[
2
].
y
));
Mat
H
=
findHomography
(
roi_corners
,
dst_corners
);
//get homography
Mat
M
=
getPerspectiveTransform
(
roi_corners
,
dst_corners
);
Mat
warped_image
;
warpPerspective
(
original_image
,
warped_image
,
H
,
warped_image_size
);
// do perspective transformation
warpPerspective
(
original_image
,
warped_image
,
M
,
warped_image_size
);
// do perspective transformation
imshow
(
"Warped Image"
,
warped_image
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录