Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
36598677
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,发现更多精彩内容 >>
未验证
提交
36598677
编写于
10月 25, 2020
作者:
Q
Quentin Chateau
提交者:
GitHub
10月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #18646 from qchateau:wave-auto
* stitching: add WAVE_CORRECT_AUTO * stitching: use CV_EXPORTS
上级
72dfd484
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
107 addition
and
1 deletion
+107
-1
modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp
...ng/include/opencv2/stitching/detail/motion_estimators.hpp
+11
-1
modules/stitching/src/motion_estimators.cpp
modules/stitching/src/motion_estimators.cpp
+45
-0
modules/stitching/test/test_precomp.hpp
modules/stitching/test/test_precomp.hpp
+1
-0
modules/stitching/test/test_wave_correction.cpp
modules/stitching/test/test_wave_correction.cpp
+50
-0
未找到文件。
modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp
浏览文件 @
36598677
...
...
@@ -328,9 +328,19 @@ private:
enum
WaveCorrectKind
{
WAVE_CORRECT_HORIZ
,
WAVE_CORRECT_VERT
WAVE_CORRECT_VERT
,
WAVE_CORRECT_AUTO
};
/** @brief Tries to detect the wave correction kind depending
on whether a panorama spans horizontally or vertically
@param rmats Camera rotation matrices.
@return The correction kind to use for this panorama
*/
CV_EXPORTS
WaveCorrectKind
autoDetectWaveCorrectKind
(
const
std
::
vector
<
Mat
>
&
rmats
);
/** @brief Tries to make panorama more horizontal (or vertical).
@param rmats Camera rotation matrices.
...
...
modules/stitching/src/motion_estimators.cpp
浏览文件 @
36598677
...
...
@@ -886,6 +886,45 @@ void BundleAdjusterAffinePartial::calcJacobian(Mat &jac)
//////////////////////////////////////////////////////////////////////////////
WaveCorrectKind
autoDetectWaveCorrectKind
(
const
std
::
vector
<
Mat
>
&
rmats
)
{
std
::
vector
<
float
>
xs
,
ys
;
xs
.
reserve
(
rmats
.
size
());
ys
.
reserve
(
rmats
.
size
());
// Project a [0, 0, 1, 1] point to the camera image frame
// Ignore intrinsic parameters and camera translation as they
// have little influence
// This also means we can simply use "rmat.col(2)" as the
// projected point homogeneous coordinate
for
(
const
Mat
&
rmat
:
rmats
)
{
CV_Assert
(
rmat
.
type
()
==
CV_32F
);
xs
.
push_back
(
rmat
.
at
<
float
>
(
0
,
2
)
/
rmat
.
at
<
float
>
(
2
,
2
));
ys
.
push_back
(
rmat
.
at
<
float
>
(
1
,
2
)
/
rmat
.
at
<
float
>
(
2
,
2
));
}
// Calculate the delta between the max and min values for
// both the X and Y axis
auto
min_max_x
=
std
::
minmax_element
(
xs
.
begin
(),
xs
.
end
());
auto
min_max_y
=
std
::
minmax_element
(
ys
.
begin
(),
ys
.
end
());
double
delta_x
=
*
min_max_x
.
second
-
*
min_max_x
.
first
;
double
delta_y
=
*
min_max_y
.
second
-
*
min_max_y
.
first
;
// If the Y delta is the biggest, it means the images
// mostly span along the vertical axis: correct this axis
if
(
delta_y
>
delta_x
)
{
LOGLN
(
" using vertical wave correction"
);
return
WAVE_CORRECT_VERT
;
}
else
{
LOGLN
(
" using horizontal wave correction"
);
return
WAVE_CORRECT_HORIZ
;
}
}
void
waveCorrect
(
std
::
vector
<
Mat
>
&
rmats
,
WaveCorrectKind
kind
)
{
LOGLN
(
"Wave correcting..."
);
...
...
@@ -898,12 +937,18 @@ void waveCorrect(std::vector<Mat> &rmats, WaveCorrectKind kind)
return
;
}
if
(
kind
==
WAVE_CORRECT_AUTO
)
{
kind
=
autoDetectWaveCorrectKind
(
rmats
);
}
Mat
moment
=
Mat
::
zeros
(
3
,
3
,
CV_32F
);
for
(
size_t
i
=
0
;
i
<
rmats
.
size
();
++
i
)
{
Mat
col
=
rmats
[
i
].
col
(
0
);
moment
+=
col
*
col
.
t
();
}
Mat
eigen_vals
,
eigen_vecs
;
eigen
(
moment
,
eigen_vals
,
eigen_vecs
);
...
...
modules/stitching/test/test_precomp.hpp
浏览文件 @
36598677
...
...
@@ -6,6 +6,7 @@
#include "opencv2/ts.hpp"
#include "opencv2/stitching.hpp"
#include "opencv2/stitching/detail/motion_estimators.hpp"
#include "opencv2/stitching/detail/matchers.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
#include "opencv2/stitching/detail/exposure_compensate.hpp"
...
...
modules/stitching/test/test_wave_correction.cpp
0 → 100644
浏览文件 @
36598677
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace
opencv_test
{
namespace
{
detail
::
WaveCorrectKind
correctionKind
(
const
std
::
vector
<
UMat
>&
images
)
{
Ptr
<
Stitcher
>
stitcher
=
Stitcher
::
create
(
Stitcher
::
PANORAMA
);
stitcher
->
estimateTransform
(
images
);
std
::
vector
<
Mat
>
rmats
;
auto
cameras
=
stitcher
->
cameras
();
for
(
const
auto
&
camera
:
cameras
)
rmats
.
push_back
(
camera
.
R
);
return
detail
::
autoDetectWaveCorrectKind
(
rmats
);
}
TEST
(
WaveCorrection
,
AutoWaveCorrection
)
{
std
::
vector
<
UMat
>
images
(
2
);
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"stitching/s1.jpg"
).
copyTo
(
images
[
0
]);
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"stitching/s2.jpg"
).
copyTo
(
images
[
1
]);
EXPECT_EQ
(
detail
::
WAVE_CORRECT_HORIZ
,
correctionKind
(
images
));
std
::
vector
<
UMat
>
rotated_images
(
2
);
rotate
(
images
[
0
],
rotated_images
[
0
],
cv
::
ROTATE_90_CLOCKWISE
);
rotate
(
images
[
1
],
rotated_images
[
1
],
cv
::
ROTATE_90_CLOCKWISE
);
EXPECT_EQ
(
detail
::
WAVE_CORRECT_VERT
,
correctionKind
(
rotated_images
));
rotate
(
images
[
0
],
rotated_images
[
0
],
cv
::
ROTATE_90_COUNTERCLOCKWISE
);
rotate
(
images
[
1
],
rotated_images
[
1
],
cv
::
ROTATE_90_COUNTERCLOCKWISE
);
EXPECT_EQ
(
detail
::
WAVE_CORRECT_VERT
,
correctionKind
(
rotated_images
));
rotate
(
images
[
0
],
rotated_images
[
0
],
cv
::
ROTATE_180
);
rotate
(
images
[
1
],
rotated_images
[
1
],
cv
::
ROTATE_180
);
EXPECT_EQ
(
detail
::
WAVE_CORRECT_HORIZ
,
correctionKind
(
rotated_images
));
}
}
// namespace
}
// namespace opencv_test
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录