Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
99948127
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,发现更多精彩内容 >>
提交
99948127
编写于
8月 10, 2011
作者:
M
Maria Dimashova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed memory leak in SIFT wrapper (#1288)
上级
ff1fb9f7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
49 addition
and
32 deletion
+49
-32
modules/features2d/src/sift.cpp
modules/features2d/src/sift.cpp
+49
-32
未找到文件。
modules/features2d/src/sift.cpp
浏览文件 @
99948127
...
@@ -1673,6 +1673,48 @@ void SIFT::operator()(const Mat& image, const Mat& mask,
...
@@ -1673,6 +1673,48 @@ void SIFT::operator()(const Mat& image, const Mat& mask,
}
}
}
}
void
release_features_data
(
CvSeq
*
featuresSeq
)
{
for
(
int
i
=
0
;
i
<
featuresSeq
->
total
;
i
++
)
{
feature
*
ft
=
CV_GET_SEQ_ELEM
(
feature
,
featuresSeq
,
i
);
free
(
ft
->
feature_data
);
}
}
// Calculate orientation of features.
// Note: calc_feature_oris() duplicates the points with several dominant orientations.
// So if keypoints was detected by Sift feature detector then some points will be
// duplicated twice.
void
recalculateAngles
(
vector
<
KeyPoint
>&
keypoints
,
IplImage
***
gauss_pyr
,
int
nOctaves
,
int
nOctaveLayers
)
{
CvMemStorage
*
storage
=
cvCreateMemStorage
(
0
);
CvSeq
*
featuresSeq
=
cvCreateSeq
(
0
,
sizeof
(
CvSeq
),
sizeof
(
struct
feature
),
storage
);
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
{
feature
ft
;
keyPointToFeature
(
keypoints
[
i
],
ft
,
SiftParams
(
nOctaves
,
nOctaveLayers
)
);
cvSeqPush
(
featuresSeq
,
&
ft
);
}
calc_feature_oris
(
featuresSeq
,
gauss_pyr
);
keypoints
.
resize
(
featuresSeq
->
total
);
for
(
int
i
=
0
;
i
<
featuresSeq
->
total
;
i
++
)
{
feature
*
ft
=
CV_GET_SEQ_ELEM
(
feature
,
featuresSeq
,
i
);
keypoints
[
i
]
=
featureToKeyPoint
(
*
ft
);
}
// Remove duplicated keypoints.
KeyPointsFilter
::
removeDuplicated
(
keypoints
);
release_features_data
(
featuresSeq
);
cvReleaseMemStorage
(
&
storage
);
}
// descriptors
// descriptors
void
SIFT
::
operator
()(
const
Mat
&
image
,
const
Mat
&
mask
,
void
SIFT
::
operator
()(
const
Mat
&
image
,
const
Mat
&
mask
,
vector
<
KeyPoint
>&
keypoints
,
vector
<
KeyPoint
>&
keypoints
,
...
@@ -1696,43 +1738,17 @@ void SIFT::operator()(const Mat& image, const Mat& mask,
...
@@ -1696,43 +1738,17 @@ void SIFT::operator()(const Mat& image, const Mat& mask,
IplImage
img
=
fimg
;
IplImage
img
=
fimg
;
ImagePyrData
pyrImages
(
&
img
,
commParams
.
nOctaves
,
commParams
.
nOctaveLayers
,
SIFT_SIGMA
,
SIFT_IMG_DBL
);
ImagePyrData
pyrImages
(
&
img
,
commParams
.
nOctaves
,
commParams
.
nOctaveLayers
,
SIFT_SIGMA
,
SIFT_IMG_DBL
);
// Calculate orientation of features.
// Note: calc_feature_oris() duplicates the points with several dominant orientations.
// So if keypoints was detected by Sift feature detector then some points will be
// duplicated twice.
CvMemStorage
*
storage
=
cvCreateMemStorage
(
0
);
CvSeq
*
featuresSeq
=
cvCreateSeq
(
0
,
sizeof
(
CvSeq
),
sizeof
(
struct
feature
),
storage
);
if
(
descriptorParams
.
recalculateAngles
)
if
(
descriptorParams
.
recalculateAngles
)
{
recalculateAngles
(
keypoints
,
pyrImages
.
gauss_pyr
,
commParams
.
nOctaves
,
commParams
.
nOctaveLayers
);
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
{
feature
*
ft
=
(
feature
*
)
calloc
(
1
,
sizeof
(
struct
feature
)
);
keyPointToFeature
(
keypoints
[
i
],
*
ft
,
SiftParams
(
commParams
.
nOctaves
,
commParams
.
nOctaveLayers
)
);
cvSeqPush
(
featuresSeq
,
ft
);
}
calc_feature_oris
(
featuresSeq
,
pyrImages
.
gauss_pyr
);
keypoints
.
resize
(
featuresSeq
->
total
);
for
(
int
i
=
0
;
i
<
featuresSeq
->
total
;
i
++
)
{
feature
*
ft
=
CV_GET_SEQ_ELEM
(
feature
,
featuresSeq
,
i
);
keypoints
[
i
]
=
featureToKeyPoint
(
*
ft
);
}
// Remove duplicated keypoints.
CvMemStorage
*
storage
=
cvCreateMemStorage
(
0
);
KeyPointsFilter
::
removeDuplicated
(
keypoints
);
CvSeq
*
featuresSeq
=
cvCreateSeq
(
0
,
sizeof
(
CvSeq
),
sizeof
(
struct
feature
),
storage
);
// Compute descriptors.
if
(
featuresSeq
->
total
>
0
)
cvSeqRemoveSlice
(
featuresSeq
,
cvSlice
(
0
,
featuresSeq
->
total
)
);
}
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
keypoints
.
size
();
i
++
)
{
{
feature
*
ft
=
(
feature
*
)
calloc
(
1
,
sizeof
(
struct
feature
)
)
;
feature
ft
;
keyPointToFeature
(
keypoints
[
i
],
*
ft
,
SiftParams
(
commParams
.
nOctaves
,
commParams
.
nOctaveLayers
)
);
keyPointToFeature
(
keypoints
[
i
],
ft
,
SiftParams
(
commParams
.
nOctaves
,
commParams
.
nOctaveLayers
)
);
cvSeqPush
(
featuresSeq
,
ft
);
cvSeqPush
(
featuresSeq
,
&
ft
);
}
}
compute_descriptors
(
featuresSeq
,
pyrImages
.
gauss_pyr
,
SIFT_DESCR_WIDTH
,
SIFT_DESCR_HIST_BINS
);
compute_descriptors
(
featuresSeq
,
pyrImages
.
gauss_pyr
,
SIFT_DESCR_WIDTH
,
SIFT_DESCR_HIST_BINS
);
CV_DbgAssert
(
(
int
)
keypoints
.
size
()
==
featuresSeq
->
total
);
CV_DbgAssert
(
(
int
)
keypoints
.
size
()
==
featuresSeq
->
total
);
...
@@ -1751,5 +1767,6 @@ void SIFT::operator()(const Mat& image, const Mat& mask,
...
@@ -1751,5 +1767,6 @@ void SIFT::operator()(const Mat& image, const Mat& mask,
}
}
}
}
release_features_data
(
featuresSeq
);
cvReleaseMemStorage
(
&
storage
);
cvReleaseMemStorage
(
&
storage
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录