C++ SIFT 特征点检测代码示例
这段代码是一个 C++ 程序的主函数,主要是使用 SIFT 算法在一张图像中找到关键点特征。程序接收命令行参数,并使用 cvLoadImage 函数加载一张图像。然后通过调用 _sift_features 函数计算图像中的 SIFT 特征点,并将结果存储在 features 数组中。
程序还提供了一些选项,如是否显示图像和是否将特征点保存到文件中。最后,程序将特征点绘制在图像上,并可以选择将结果保存到文件中。
int main( int argc, char** argv )
{
IplImage* img;
struct feature* features;
int n = 0;
//arg_parse( argc, argv );
fprintf( stderr, 'Finding SIFT features...
' );
img = cvLoadImage( 'beaver.png', 1 );
if( ! img )
fatal_error( 'unable to load image from %s', img_file_name );
n = _sift_features( img, &features, intvls, sigma, contr_thr, curv_thr,
img_dbl, descr_width, descr_hist_bins );
fprintf( stderr, 'Found %d features.
', n );
if( display )
{
draw_features( img, features, n );
//display_big_img( img, img_file_name );
//cvWaitKey( 0 );
}
if( out_file_name != NULL )
export_features( out_file_name, features, n );
if( out_img_name != NULL )
cvSaveImage( out_img_name, img, NULL );
return 0;
}
原文地址: https://www.cveoy.top/t/topic/nwge 著作权归作者所有。请勿转载和采集!