/*
Functions for detecting SIFT image features.
For more information, refer to:
Lowe, D. Distinctive image features from scale-invariant keypoints.
<EM>International Journal of Computer Vision, 60</EM>, 2 (2004),
pp.91--110.
Copyright (C) 2006 Rob Hess <hess@eecs.oregonstate.edu>
Note: The SIFT algorithm is patented in the United States and cannot be
used in commercial products without a license from the University of
British Columbia. For more information, refer to the file LICENSE.ubc
that accompanied this distribution.
@version 1.1.1-20070330
*/
#include "sift.h"
#include "imgfeatures.h"
#include "utils.h"
#include <cxcore.h>
#include <cv.h>
/************************* Local Function Prototypes *************************/
IplImage* create_init_img( IplImage*, int, double );
IplImage* convert_to_gray32( IplImage* );
IplImage*** build_gauss_pyr( IplImage*, int, int, double );
IplImage* downsample( IplImage* );
IplImage*** build_dog_pyr( IplImage***, int, int );
CvSeq* scale_space_extrema( IplImage***, int, int, double, int, CvMemStorage*);
int is_extremum( IplImage***, int, int, int, int );
struct feature* interp_extremum( IplImage***, int, int, int, int, int, double);
void interp_step( IplImage***, int, int, int, int, double*, double*, double* );
CvMat* deriv_3D( IplImage***, int, int, int, int );
CvMat* hessian_3D( IplImage***, int, int, int, int );
double interp_contr( IplImage***, int, int, int, int, double, double, double );
struct feature* new_feature( void );
int is_too_edge_like( IplImage*, int, int, int );
void calc_feature_scales( CvSeq*, double, int );
void adjust_for_img_dbl( CvSeq* );
void calc_feature_oris( CvSeq*, IplImage*** );
double* ori_hist( IplImage*, int, int, int, int, double );
int calc_grad_mag_ori( IplImage*, int, int, double*, double* );
void smooth_ori_hist( double*, int );
double dominant_ori( double*, int );
void add_good_ori_features( CvSeq*, double*, int, double, struct feature* );
struct feature* clone_feature( struct feature* );
void compute_descriptors( CvSeq*, IplImage***, int, int );
double*** descr_hist( IplImage*, int, int, double, double, int, int );
void interp_hist_entry( double***, double, double, double, double, int, int);
void hist_to_descr( double***, int, int, struct feature* );
void normalize_descr( struct feature* );
int feature_cmp( void*, void*, void* );
void release_descr_hist( double****, int );
void release_pyr( IplImage****, int, int );
/*********************** Functions prototyped in sift.h **********************/
/**
Finds SIFT features in an image using default parameter values. All
detected features are stored in the array pointed to by \a feat.
@param img the image in which to detect features
@param feat a pointer to an array in which to store detected features
@return Returns the number of features stored in \a feat or -1 on failure
@see _sift_features()
*/
int sift_features( IplImage* img, struct feature** feat )
{
return _sift_features( img, feat, SIFT_INTVLS, SIFT_SIGMA, SIFT_CONTR_THR,
SIFT_CURV_THR, SIFT_IMG_DBL, SIFT_DESCR_WIDTH,
SIFT_DESCR_HIST_BINS );
}
/**
Finds SIFT features in an image using user-specified parameter values. All
detected features are stored in the array pointed to by \a feat.
@param img the image in which to detect features
@param fea a pointer to an array in which to store detected features
@param intvls the number of intervals sampled per octave of scale space
@param sigma the amount of Gaussian smoothing applied to each image level
before building the scale space representation for an octave
@param cont_thr a threshold on the value of the scale space function
\f$\left|D(\hat{x})\right|\f$, where \f$\hat{x}\f$ is a vector specifying
feature location and scale, used to reject unstable features; assumes
pixel values in the range [0, 1]
@param curv_thr threshold on a feature's ratio of principle curvatures
used to reject features that are too edge-like
@param img_dbl should be 1 if image doubling prior to scale space
construction is desired or 0 if not
@param descr_width the width, \f$n\f$, of the \f$n \times n\f$ array of
orientation histograms used to compute a feature's descriptor
@param descr_hist_bins the number of orientations in each of the
histograms in the array used to compute a feature's descriptor
@return Returns the number of keypoints stored in \a feat or -1 on failure
@see sift_keypoints()
*/
int _sift_features( IplImage* img, struct feature** feat, int intvls,
double sigma, double contr_thr, int curv_thr,
int img_dbl, int descr_width, int descr_hist_bins )
{
IplImage* init_img;
IplImage*** gauss_pyr, *** dog_pyr;
CvMemStorage* storage;
CvSeq* features;
int octvs, i, n = 0;
/* check arguments */
if( ! img )
fatal_error( "NULL pointer error, %s, line %d", __FILE__, __LINE__ );
if( ! feat )
fatal_error( "NULL pointer error, %s, line %d", __FILE__, __LINE__ );
/* build scale space pyramid; smallest dimension of top level is ~4 pixels */
init_img = create_init_img( img, img_dbl, sigma );
octvs = log( MIN( init_img->width, init_img->height ) ) / log(2) - 2;
gauss_pyr = build_gauss_pyr( init_img, octvs, intvls, sigma );
dog_pyr = build_dog_pyr( gauss_pyr, octvs, intvls );
storage = cvCreateMemStorage( 0 );
features = scale_space_extrema( dog_pyr, octvs, intvls, contr_thr,
curv_thr, storage );
calc_feature_scales( features, sigma, intvls );
if( img_dbl )
adjust_for_img_dbl( features );
calc_feature_oris( features, gauss_pyr );
compute_descriptors( features, gauss_pyr, descr_width, descr_hist_bins );
/* sort features by decreasing scale and move from CvSeq to array */
cvSeqSort( features, (CvCmpFunc)feature_cmp, NULL );
n = features->total;
*feat = calloc( n, sizeof(struct feature) );
*feat = cvCvtSeqToArray( features, *feat, CV_WHOLE_SEQ );
for( i = 0; i < n; i++ )
{
free( (*feat)[i].feature_data );
(*feat)[i].feature_data = NULL;
}
cvReleaseMemStorage( &storage );
cvReleaseImage( &init_img );
release_pyr( &gauss_pyr, octvs, intvls + 3 );
release_pyr( &dog_pyr, octvs, intvls + 2 );
return n;
}
/************************ Functions prototyped here **************************/
/*
Converts an image to 8-bit grayscale and Gaussian-smooths it. The image is
optionally doubled in size prior to smoothing.
@param img input image
@param img_dbl if true, image is doubled in size prior to smoothing
@param sigma total std of Gaussian smoothing
*/
IplImage* create_init_img( IplImage* img, int img_dbl, double sigma )
{
IplImage* gray, * dbl;
float sig_diff;
gray = convert_to_gray32( img );
if( img_dbl )
{
sig_diff = sqrt( sigma * sigma - SIFT_INIT_SIGMA * SIFT_INIT_SIGMA * 4 );
dbl = cvCreateImage( cvSize( img->width*2, img->height*2 ),
IPL_DEPTH_32F, 1 );
cvResize( gray, dbl, CV_INTER_CUBIC );
cvSmooth( dbl, dbl, CV_GAUSSIAN, 0, 0, sig_diff, sig_diff );
cvReleaseImage( &gray );
return dbl;
}
else
{
sig_diff = sqrt( sigma * sigma - SIFT_INIT_SIGMA * SIFT_INIT_SIGMA );
cvSmooth( gray, gray, CV_GAUSSIAN, 0, 0, sig_diff, sig_diff );
return gray;
}
}
/*
Converts an image to 32-bit grayscale
@param img a 3-channel 8-bit color (BGR) or 8-bit gray image
@return Returns a 32-bit grayscale image
*/
IplImage* convert_to_gray32( IplImage* img )
{
IplImage* gray8, * gray32;
int r, c;
gray8 = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 1 );
gray32 = cvCreateImage( cvGetSize(img), IPL_DEPTH_32F, 1 );
if( img->nChannels == 1 )
gray8 = cvClone( img );
else
cvCvtColor( img, gray8, CV_RGB2GRAY );
cvConvertScale( gray8, gray32, 1.0 / 255.0, 0 );
cvReleaseImage( &gray8 );
return gray32;
}
/*
Builds Gaussian scale space pyramid from an image
@param base base image of the pyramid
@param octvs number o
没有合适的资源?快使用搜索试试~ 我知道了~
快速SIFT匹配,双目测距
共69个文件
jpg:9个
c:9个
dll:7个
4星 · 超过85%的资源 需积分: 42 219 下载量 42 浏览量
2010-03-29
19:06:15
上传
评论 11
收藏 10.75MB RAR 举报
温馨提示
适用于双目测距,图像匹配,障碍物识别等。基于SIFT算法,快速匹配,得到各匹配点的偏移量,经过筛选后,精确度较高,因而也能得到物体与摄像头之间的距离。 匹配率很高。
资源推荐
资源详情
资源评论
收起资源包目录
SIFT_VC.rar (69个子文件)
SIFT_VC
sift.c 35KB
Release
match.c 7KB
xform.c 16KB
SIFT_VC.sln 878B
kdtree.h 3KB
sift.h 5KB
beaver_xform.png 52KB
beaver.png 41KB
match.cpp 6KB
SIFT_VC.suo 36KB
minpq.c 5KB
cvaux200d.dll 2.07MB
beaver.jpg 12KB
gray-s-l.bmp 674KB
SIFT_VC.ncb 15.84MB
cv200d.dll 3.16MB
l.jpg 22KB
dspfeat.c 984B
downimg_matched_points.xml 1KB
siftfeat.c 2KB
ml200d.dll 900KB
gray-s-r.bmp 506KB
00008.bmp 9KB
imgfeatures.c 15KB
tu
l.jpg 22KB
r.jpg 18KB
Debug
match.obj 34KB
utils.obj 35KB
SIFT_VC.exe.embed.manifest 146B
vc80.idb 267KB
SIFT_VC.ilk 1.37MB
mt.dep 67B
beaver.jpg 12KB
SIFT_VC.pdb 2.39MB
imgfeatures.obj 40KB
xform.obj 35KB
beaver_xform.jpg 22KB
SIFT_VC.exe 740KB
minpq.obj 16KB
BuildLog.htm 7KB
SIFT_VC.exe.intermediate.manifest 145B
SIFT_VC.exe.embed.manifest.res 212B
sift.obj 64KB
kdtree.obj 28KB
vc80.pdb 92KB
beaver .jpg 223KB
beaver_xform.jpg 30KB
xform.h 6KB
SIFT_VC.exe 396KB
right.bmp 798KB
00007.bmp 8KB
utils.h 6KB
kdtree.c 15KB
opencv_ffmpeg200d.dll 6.31MB
cxcore200d.dll 3.43MB
minpq.h 2KB
imgfeatures.h 4KB
upimg_matched_points.xml 1KB
SIFT_VC.dsp 5KB
SIFT_VC.vcproj.JSJ26.Administrator.user 1KB
SIFT_VC.vcproj 8KB
left.bmp 798KB
highgui200d.dll 1.55MB
utils.c 7KB
cxts200d.dll 428KB
cxcore.h 85KB
SIFT_VC.dsw 537B
Thumbs.db 6KB
r.jpg 18KB
共 69 条
- 1
luoling8825
- 粉丝: 26
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于jsp+mysql的JSP个人日记本源码.zip
- 基于jsp+mysql+servlet的JSP图书馆图书管理系统源码.zip
- 【2024win11软件启动速度反应慢解决方法附工具】
- 3.1_将字符串颠倒输出 .cpp
- 基于MATLAB实现的数字信号处理课后仿真代码,共十四章
- mysql-8.0(windows+mac版本).zip
- Screenshot_2024-05-14-17-26-40-479_com.tencent.mobileqq.jpg
- 749783406737663csgk_schedule.zip
- 基于html+css+js(jquery)开发的网易云商城+源码+音乐+商品详情+商城界面+商城购物车+网易云首页(高分优秀项目
- 信息论课程设计基于Python实现的霍夫曼、费诺、香农编码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页