Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
400eb371
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,发现更多精彩内容 >>
提交
400eb371
编写于
6月 15, 2010
作者:
M
Maria Dimashova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added parameter keypointIndexes to KeyPoint::convert, updated sample
上级
c4fded9a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
43 deletion
+42
-43
modules/features2d/include/opencv2/features2d/features2d.hpp
modules/features2d/include/opencv2/features2d/features2d.hpp
+3
-2
modules/features2d/src/keypoint.cpp
modules/features2d/src/keypoint.cpp
+26
-12
samples/cpp/descriptor_extractor_matcher.cpp
samples/cpp/descriptor_extractor_matcher.cpp
+13
-29
未找到文件。
modules/features2d/include/opencv2/features2d/features2d.hpp
浏览文件 @
400eb371
...
...
@@ -221,9 +221,10 @@ public:
:
pt
(
x
,
y
),
size
(
_size
),
angle
(
_angle
),
response
(
_response
),
octave
(
_octave
),
class_id
(
_class_id
)
{}
//! converts vector of keypoints to vector of points
static
void
convert
(
const
std
::
vector
<
KeyPoint
>&
u
,
std
::
vector
<
Point2f
>&
v
);
static
void
convert
(
const
std
::
vector
<
KeyPoint
>&
keypoints
,
std
::
vector
<
Point2f
>&
points2f
,
const
std
::
vector
<
int
>&
keypointIndexes
=
std
::
vector
<
int
>
());
//! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation
static
void
convert
(
const
std
::
vector
<
Point2f
>&
u
,
std
::
vector
<
KeyPoint
>&
v
,
static
void
convert
(
const
std
::
vector
<
Point2f
>&
points2f
,
std
::
vector
<
KeyPoint
>&
keypoints
,
float
size
=
1
,
float
response
=
1
,
int
octave
=
0
,
int
class_id
=-
1
);
Point2f
pt
;
//!< coordinates of the keypoints
float
size
;
//!< diameter of the meaningfull keypoint neighborhood
...
...
modules/features2d/src/keypoint.cpp
浏览文件 @
400eb371
...
...
@@ -76,23 +76,37 @@ void read(const FileNode& node, vector<KeyPoint>& keypoints)
}
void
KeyPoint
::
convert
(
const
std
::
vector
<
KeyPoint
>&
u
,
std
::
vector
<
Point2f
>&
v
)
void
KeyPoint
::
convert
(
const
std
::
vector
<
KeyPoint
>&
keypoints
,
std
::
vector
<
Point2f
>&
points2f
,
const
vector
<
int
>&
keypointIndexes
)
{
size_t
i
,
sz
=
u
.
size
();
v
.
resize
(
sz
);
for
(
i
=
0
;
i
<
sz
;
i
++
)
v
[
i
]
=
u
[
i
].
pt
;
if
(
keypointIndexes
.
empty
()
)
{
points2f
.
resize
(
keypoints
.
size
()
);
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
points2f
[
i
]
=
keypoints
[
i
].
pt
;
}
else
{
points2f
.
resize
(
keypointIndexes
.
size
()
);
for
(
size_t
i
=
0
;
i
<
keypointIndexes
.
size
();
i
++
)
{
int
idx
=
keypointIndexes
[
i
];
if
(
idx
>=
0
)
points2f
[
i
]
=
keypoints
[
idx
].
pt
;
else
{
CV_Error
(
CV_StsBadArg
,
"keypointIndexes has element < 0. TODO: process this case"
);
//points2f[i] = Point2f(-1, -1);
}
}
}
}
void
KeyPoint
::
convert
(
const
std
::
vector
<
Point2f
>&
u
,
std
::
vector
<
KeyPoint
>&
v
,
void
KeyPoint
::
convert
(
const
std
::
vector
<
Point2f
>&
points2f
,
std
::
vector
<
KeyPoint
>&
keypoints
,
float
size
,
float
response
,
int
octave
,
int
class_id
)
{
size_t
i
,
sz
=
u
.
size
();
v
.
resize
(
sz
);
for
(
i
=
0
;
i
<
sz
;
i
++
)
v
[
i
]
=
KeyPoint
(
u
[
i
],
size
,
-
1
,
response
,
octave
,
class_id
);
for
(
size_t
i
=
0
;
i
<
points2f
.
size
();
i
++
)
keypoints
[
i
]
=
KeyPoint
(
points2f
[
i
],
size
,
-
1
,
response
,
octave
,
class_id
);
}
}
samples/cpp/descriptor_extractor_matcher.cpp
浏览文件 @
400eb371
...
...
@@ -5,21 +5,9 @@
#include "opencv2/features2d/features2d.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
inline
Point2f
applyHomography
(
const
Mat_
<
double
>&
H
,
const
Point2f
&
pt
)
{
double
z
=
H
(
2
,
0
)
*
pt
.
x
+
H
(
2
,
1
)
*
pt
.
y
+
H
(
2
,
2
);
if
(
z
)
{
double
w
=
1.
/
z
;
return
Point2f
(
(
H
(
0
,
0
)
*
pt
.
x
+
H
(
0
,
1
)
*
pt
.
y
+
H
(
0
,
2
))
*
w
,
(
H
(
1
,
0
)
*
pt
.
x
+
H
(
1
,
1
)
*
pt
.
y
+
H
(
1
,
2
))
*
w
);
}
return
Point2f
(
numeric_limits
<
double
>::
max
(),
numeric_limits
<
double
>::
max
()
);
}
void
warpPerspectiveRand
(
const
Mat
&
src
,
Mat
&
dst
,
Mat
&
H
,
RNG
*
rng
)
{
H
.
create
(
3
,
3
,
CV_32FC1
);
...
...
@@ -74,40 +62,36 @@ void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective,
if
(
!
isWarpPerspective
&&
ransacReprojThreshold
>=
0
)
{
cout
<<
"< Computing homography (RANSAC)..."
<<
endl
;
vector
<
Point2f
>
points1
(
matches
.
size
()),
points2
(
matches
.
size
());
for
(
size_t
i
=
0
;
i
<
matches
.
size
();
i
++
)
{
points1
[
i
]
=
keypoints1
[
i
].
pt
;
points2
[
i
]
=
keypoints2
[
matches
[
i
]].
pt
;
}
vector
<
Point2f
>
points1
;
KeyPoint
::
convert
(
keypoints1
,
points1
);
vector
<
Point2f
>
points2
;
KeyPoint
::
convert
(
keypoints2
,
points2
,
matches
);
H12
=
findHomography
(
Mat
(
points1
),
Mat
(
points2
),
CV_RANSAC
,
ransacReprojThreshold
);
cout
<<
">"
<<
endl
;
}
Mat
drawImg
;
if
(
!
H12
.
empty
()
)
if
(
!
H12
.
empty
()
)
// filter outliers
{
vector
<
char
>
matchesMask
(
matches
.
size
(),
0
);
vector
<
Point2f
>
points1
;
KeyPoint
::
convert
(
keypoints1
,
points1
);
vector
<
Point2f
>
points2
;
KeyPoint
::
convert
(
keypoints2
,
points2
,
matches
);
Mat
points1t
;
perspectiveTransform
(
Mat
(
points1
),
points1t
,
H12
);
vector
<
int
>::
const_iterator
mit
=
matches
.
begin
();
for
(
size_t
i1
=
0
;
mit
!=
matches
.
end
();
++
mit
,
i1
++
)
for
(
size_t
i1
=
0
;
i1
<
points1
.
size
();
i1
++
)
{
Point2f
pt1
=
keypoints1
[
i1
].
pt
,
pt2
=
keypoints2
[
*
mit
].
pt
;
if
(
norm
(
pt2
-
applyHomography
(
H12
,
pt1
))
<
4
)
// inlier
if
(
norm
(
points2
[
i1
]
-
points1t
.
at
<
Point2f
>
(
i1
,
0
))
<
4
)
// inlier
matchesMask
[
i1
]
=
1
;
}
// draw inliers
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
matches
,
drawImg
,
CV_RGB
(
0
,
255
,
0
),
CV_RGB
(
0
,
0
,
255
),
matchesMask
);
// draw outliers
/*
for( size_t i1 = 0; i1 < matchesMask.size(); i1++ )
#if 0
// draw outliers
for( size_t i1 = 0; i1 < matchesMask.size(); i1++ )
matchesMask[i1] = !matchesMask[i1];
drawMatches( img1, keypoints1, img2, keypoints2, matches, drawImg, CV_RGB(0, 0, 255), CV_RGB(255, 0, 0), matchesMask,
DrawMatchesFlags::DRAW_OVER_OUTIMG | DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );*/
DrawMatchesFlags::DRAW_OVER_OUTIMG | DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS )
#endif
}
else
{
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
matches
,
drawImg
,
CV_RGB
(
0
,
255
,
0
)
);
}
drawMatches
(
img1
,
keypoints1
,
img2
,
keypoints2
,
matches
,
drawImg
);
imshow
(
winName
,
drawImg
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录