这篇博文主要介绍SIFT算法在提取点云图像关键点时的具体用法。

尺度不变特征转换(Scale-invariant feature transform,SIFT)是David Lowe在1999年发表,2004年总结完善。其应用范围包括物体辨识,机器人地图感知与导航、3D模型建立、手势辨识、影像追踪和动作对比。此算法已经申请专利,专利拥有者属于英属哥伦比亚大学。SIFT算法在3D数据上的应用由Flint等在2007年实现。这里所讲的提取点云关键点的算法便是由Flint等人实现的SIFT3D算法。

其实现代如下:

 // STL
#include <iostream> // PCL
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/common/io.h>
#include <pcl/keypoints/sift_keypoint.h>
#include <pcl/features/normal_3d.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/console/time.h> /* This examples shows how to estimate the SIFT points based on the
* z gradient of the 3D points than using the Intensity gradient as
* usually used for SIFT keypoint estimation.
*/ namespace pcl
{
template<>
struct SIFTKeypointFieldSelector<PointXYZ>
{
inline float
operator () (const PointXYZ &p) const
{
return p.z;
}
};
} int
main(int, char** argv)
{
std::string filename = argv[];
std::cout << "Reading " << filename << std::endl;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz (new pcl::PointCloud<pcl::PointXYZ>);
if(pcl::io::loadPCDFile<pcl::PointXYZ> (filename, *cloud_xyz) == -) // load the file
{
PCL_ERROR ("Couldn't read file");
return -;
}
std::cout << "points: " << cloud_xyz->points.size () <<std::endl; // Parameters for sift computation
const float min_scale = 0.005f; //the standard deviation of the smallest scale in the scale space
const int n_octaves = ;//the number of octaves (i.e. doublings of scale) to compute
const int n_scales_per_octave = ;//the number of scales to compute within each octave
const float min_contrast = 0.005f;//the minimum contrast required for detection pcl::console::TicToc time;
time.tic();
// Estimate the sift interest points using z values from xyz as the Intensity variants
pcl::SIFTKeypoint<pcl::PointXYZ, pcl::PointWithScale> sift;
pcl::PointCloud<pcl::PointWithScale> result;
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ> ());
sift.setSearchMethod(tree);
sift.setScales(min_scale, n_octaves, n_scales_per_octave);
sift.setMinimumContrast(min_contrast);
sift.setInputCloud(cloud_xyz);
sift.compute(result);
std::cout<<"Computing the SIFT points takes "<<time.toc()/<<"seconds"<<std::endl;
std::cout << "No of SIFT points in the result are " << result.points.size () << std::endl; // Copying the pointwithscale to pointxyz so as visualize the cloud
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_temp (new pcl::PointCloud<pcl::PointXYZ>);
copyPointCloud(result, *cloud_temp);
std::cout << "SIFT points in the result are " << cloud_temp->points.size () << std::endl;
// Visualization of keypoints along with the original cloud
pcl::visualization::PCLVisualizer viewer("PCL Viewer");
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> keypoints_color_handler (cloud_temp, , , );
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> cloud_color_handler (cloud_xyz, , , );
viewer.setBackgroundColor( 0.0, 0.0, 0.0 );
viewer.addPointCloud(cloud_xyz, cloud_color_handler, "cloud");//add point cloud
viewer.addPointCloud(cloud_temp, keypoints_color_handler, "keypoints");//add the keypoints
viewer.setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, , "keypoints"); while(!viewer.wasStopped ())
{
viewer.spinOnce ();
} return ; }

运行结果如下图所示:

最新文章

  1. c#向数据库插入较大数据(SqlBulkCopy)
  2. Perl--学习记录(实时更新)
  3. MySQL如何发型不乱的应对半年数十TB数据增量
  4. react native windows开发环境搭建(一)
  5. PHP学习笔记:利用gd库给图片打图片水印
  6. Set Linux starts in multi-user mode as default.
  7. 简单的Dao设计模式
  8. one plus 1(一加1)刷 kali nethunter 教程
  9. iOS中 读取相册,调用系统相机 技术分享
  10. Linux系统中安装Oracle数据库
  11. Jenkins- job之间传参
  12. 几个jdbc小技巧
  13. 7.mongo python 库 pymongo的安装
  14. 移动前端框架,require.js压缩
  15. 02-第一个JavaScript代码
  16. js生成条形码插件
  17. linux 的常用命令---------第六阶段
  18. 编写一个读写倾斜测量数据.s3c文件格式的OSG插件osgdb_s3c
  19. python模拟登陆豆瓣——简单方法
  20. swiper 导航有多个,被点击的项居中显示。

热门文章

  1. vps上运行serv-u的问题
  2. POJ——T 1469 COURSES
  3. java用freemarker实现导出word----包含图片
  4. JVM分代通俗解释
  5. invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
  6. pyspark import 可以通过 --py-files
  7. MinGW - 安装和配置 / MinGW - Howto Install And Configure
  8. [codeforces 618 F] Double Knapsack (抽屉原理)
  9. [JSOI2008] [BZOJ1567] Blue Mary的战役地图 解题报告 (hash)
  10. PostgreSQL Replication之第六章 监控您的设置(2)