資源簡介
基于SIFT算法的特征提取(VS2015+OpenCV2.4.13)
主要分為以下幾個步驟:
(1) 讀入兩張圖片并分別提取SIFT特征
(2) 利用k-d tree和BBF算法進行特征匹配查找
(3) 利用RANSAC算法篩選匹配點并計算變換矩陣
代碼片段和文件信息
/*
Functions?and?structures?for?dealing?with?image?features
Copyright?(C)?2006-2010??Rob?Hess?
@version?1.1.2-20100521
*/
#include?“utils.h“
#include?“imgfeatures.h“
#include?
#include?
static?int?import_oxfd_features(?char*?struct?feature**?);
static?int?export_oxfd_features(?char*?struct?feature*?int?);
static?void?draw_oxfd_features(?IplImage*?struct?feature*?int?);
static?void?draw_oxfd_feature(?IplImage*?struct?feature*?CvScalar?);
static?int?import_lowe_features(?char*?struct?feature**?);
static?int?export_lowe_features(?char*?struct?feature*?int?);
static?void?draw_lowe_features(?IplImage*?struct?feature*?int?);
static?void?draw_lowe_feature(?IplImage*?struct?feature*?CvScalar?);
/*
Reads?image?features?from?file.??The?file?should?be?formatted?as?from
the?code?provided?by?the?Visual?Geometry?Group?at?Oxford:
@param?filename?location?of?a?file?containing?image?features
@param?type?determines?how?features?are?input.??If?\a?type?is?FEATURE_OXFD
the?input?file?is?treated?as?if?it?is?from?the?code?provided?by?the?VGG
at?Oxford:
http://www.robots.ox.ac.uk:5000/~vgg/research/affine/index.html
If?\a?type?is?FEATURE_LOWE?the?input?file?is?treated?as?if?it?is?from
David?Lowe‘s?SIFT?code:
http://www.cs.ubc.ca/~lowe/keypoints??
@param?features?pointer?to?an?array?in?which?to?store?features
@return?Returns?the?number?of?features?imported?from?filename?or?-1?on?error
*/
int?import_features(?char*?filename?int?type?struct?feature**?feat?)
{
int?n;
switch(?type?)
{
case?FEATURE_OXFD:
n?=?import_oxfd_features(?filename?feat?);
break;
case?FEATURE_LOWE:
n?=?import_lowe_features(?filename?feat?);
break;
default:
fprintf(?stderr?“Warning:?import_features():?unrecognized?feature“?\
“type?%s?line?%d\n“?__FILE__?__LINE__?);
return?-1;
}
if(?n?==?-1?)
fprintf(?stderr?“Warning:?unable?to?import?features?from?%s“ \
“?%s?line?%d\n“?filename?__FILE__?__LINE__?);
return?n;
}
/*
Exports?a?feature?set?to?a?file?formatted?depending?on?the?type?of
features?as?specified?in?the?feature?struct‘s?type?field.
@param?filename?name?of?file?to?which?to?export?features
@param?feat?feature?array
@param?n?number?of?features?
@return?Returns?0?on?success?or?1?on?error
*/
int?export_features(?char*?filename?struct?feature*?feat?int?n?)
{
int?r?type;
if(?n?<=?0??||??!?feat?)
{
fprintf(?stderr?“Warning:?no?features?to?export?%s?line?%d\n“
__FILE__?__LINE__?);
return?1;
}
type?=?feat[0].type;
switch(?type?)
{
case?FEATURE_OXFD:
r?=?export_oxfd_features(?filename?feat?n?);
break;
case?FEATURE_LOWE:
r?=?export_lowe_features(?filename?feat?n?);
break;
default:
fprintf(?stderr?“Warning:?export_features():?unrecognized?feature“?\
“type?%s?line?%d\n“?__FILE__?__LINE__?);
return?-1;
}
if(?r?)
fprintf(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-18?14:52??sift_match\
?????目錄???????????0??2018-12-13?20:09??sift_match\.vs\
?????目錄???????????0??2018-12-13?20:09??sift_match\.vs\sift_process\
?????目錄???????????0??2018-12-13?20:09??sift_match\.vs\sift_process\v14\
?????文件???????49664??2018-12-18?14:52??sift_match\.vs\sift_process\v14\.suo
?????目錄???????????0??2018-12-13?20:11??sift_match\sift_process\
?????目錄???????????0??2018-12-18?14:52??sift_match\sift_process\match\
?????文件???????48824??2010-05-21?12:48??sift_match\sift_process\match\beaver.png
?????文件???????39513??2010-05-21?12:48??sift_match\sift_process\match\beaver_xform.png
?????文件???????14956??2010-05-21?14:50??sift_match\sift_process\match\imgfeatures.c
?????文件????????3861??2010-05-21?14:50??sift_match\sift_process\match\imgfeatures.h
?????文件???????15666??2010-05-21?14:50??sift_match\sift_process\match\kdtree.c
?????文件????????3681??2010-05-21?14:50??sift_match\sift_process\match\kdtree.h
?????文件????????3154??2018-12-13?19:33??sift_match\sift_process\match\match.c
?????文件????????5098??2010-05-21?14:50??sift_match\sift_process\match\minpq.c
?????文件????????2096??2010-05-21?14:50??sift_match\sift_process\match\minpq.h
?????文件???????36594??2010-05-21?14:50??sift_match\sift_process\match\sift.c
?????文件????????5093??2018-12-13?17:05??sift_match\sift_process\match\sift.h
?????文件????????7553??2018-12-13?19:30??sift_match\sift_process\match\utils.c
?????文件????????5802??2018-12-13?17:03??sift_match\sift_process\match\utils.h
?????文件???????18260??2010-05-21?14:50??sift_match\sift_process\match\xform.c
?????文件????????6596??2010-05-21?14:50??sift_match\sift_process\match\xform.h
?????目錄???????????0??2018-12-13?20:12??sift_match\sift_process\Release\
?????文件??????137114??2018-12-13?20:27??sift_match\sift_process\Release\imgfeatures.obj
?????文件??????132122??2018-12-13?20:27??sift_match\sift_process\Release\kdtree.obj
?????文件??????122830??2018-12-13?20:27??sift_match\sift_process\Release\match.obj
?????文件??????120300??2018-12-13?20:27??sift_match\sift_process\Release\minpq.obj
?????文件??????160458??2018-12-13?20:27??sift_match\sift_process\Release\sift.obj
?????文件????????2109??2018-12-13?20:27??sift_match\sift_process\Release\sift_process.log
?????目錄???????????0??2018-12-13?20:27??sift_match\sift_process\Release\sift_process.tlog\
?????文件???????11278??2018-12-13?20:27??sift_match\sift_process\Release\sift_process.tlog\CL.command.1.tlog
............此處省略15個文件信息
評論
共有 條評論