Point Cloud Library PCL learning --Harris key points

This section demonstrates how to detect 3DHarris corner point cloud.

Harris operator is a common feature detection operator, may be extracted corner edge point may be extracted. 2DHarris point detection principle different angles, 3DHarris corner detection information vector using the cloud point method.

First, tell us about the Harris operator used in class:

HarrisKeyPoint2D类
pcl::HarrisKeypoint2D< PointInT, PointOutT, IntensityT >

HarrisKeypoint2D (ResponseMethod method= HARRIS, int window_width =3 , int window_height=3, int min_distance=S, float threshold= 0. 0)

  Reconstruction function. method provided that need critical point detection method, there HARRIS, NOBLE, LOWE, TOMASI four methods, defaults The ARRIS H; window_width, window_height for the detection window width and height, MIN_DISTANCE to allow a minimum between two key points distance, threshold for judging whether the level of interest Ko key value, the value is less than the width of the point is ignored, that is greater than the critical point.
void setMethod (ResponseMethod type)
  Detection Settings
void

setWindowWidth (int window width)

setWindowHeight (int window_height)

  Provided detection window width, height
void setSkippedPixels (int  skipped_pixels)
  Detecting the number of pixels disposed at each skipped 
void setMinimalDistance (int min_distance)
  Setting a minimum distance between the candidate keypoints
void setThreshold ( float threshold)
  Setting interest threshold
void setNonMaxSupression ( bool= false)
  Set whether the point is less than the threshold value of interest is removed, the culling if true, to optimize the results, if each point is false is returned, regardless of interest is above or below the threshold value of interest.
void setRefine (booldo refine)
  The resulting critical point is set to recalculate the results of the optimization
void setNumberOfThreads (Intnl threads)
  Set the number of threads that the algorithm if OpenMP parallelism can be created
void compute (PointCloudOut &output)
  Computing access to key points, it is stored in the output.
HarrisKeypoint3D类
pcl::HarrisKeypoint3D< PointInT, PointOutT, NormalT >

HarrisKeypoint3D ( ResponseMethod method = HARRIS, float radius =0. 0lf, float threshold = 0. 0f)

  Reconstruction function, method which requires setting the key point detection method is used, there HARRIS, NOBLE, LOWE, TOMASI, CURVATURE five methods, default HARRIS, radius is normal to estimate the search radius, but also the support of regional interest calculated values , threshold determination for the degree of interest is a critical point threshold value, the point is less than the threshold are ignored, that is greater than the critical point 
                                                                     类 HarrisKeypoint6D
类 HarrisKeypoint6D 与 HarrisK eypoint2D 类似, 只是利用了欧氏空间域 XYZ或者强度域来确定候选关键点,或者前两者的交集,即同时满足 XYZ 域和强度域的关键点为候选关键点。
pcl::HarrisKeypoint6D< PointInT, PointOutT, NormalT >

HarrisKeypoint6D (float radius =O. 01, float threshold = 0. 0)

  重构函数,注意此处并没有方法选择的参数,通过源代码可以看出其只采用 Tomasi 提出的方法实现关键点检测, radius 为法线估计的搜索半径,同时也是计算兴趣值的支持区域, threshold 为判断是否为关键点的感兴趣程度的阈值,小于该阈值的点被忽略,大于的则认为是关键点。
#pragma warning(disable:4996)
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <iostream>
#include <pcl\io\pcd_io.h>
#include <pcl/point_cloud.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/io.h>
#include <pcl/keypoints/harris_3D.h>//harris特征点估计类头文件声明
#include <cstdlib>
#include <vector>
#include <pcl/console/parse.h>
using namespace std;

int main(int argc, char *argv[])
{
	pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud(new pcl::PointCloud<pcl::PointXYZ>);
	pcl::io::loadPCDFile("F:\\C++project\\roorm.pcd", *input_cloud);
	pcl::PCDWriter writer;
	float r_normal;
	float r_keypoint;

	r_normal = 0.1;
	r_keypoint = 0.1;

	typedef pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> ColorHandlerT3;

	pcl::PointCloud<pcl::PointXYZI>::Ptr Harris_keypoints(new pcl::PointCloud<pcl::PointXYZI>());
	pcl::HarrisKeypoint3D<pcl::PointXYZ, pcl::PointXYZI, pcl::Normal>* harris_detector = new pcl::HarrisKeypoint3D<pcl::PointXYZ, pcl::PointXYZI, pcl::Normal>;

	//harris_detector->setNonMaxSupression(true);
	harris_detector->setRadius(r_normal);         //设置法向量估算的半径
	harris_detector->setRadiusSearch(r_keypoint); //设置关键点估计的近邻搜索半径
	harris_detector->setInputCloud(input_cloud);
	//harris_detector->setNormals(normal_source);
	//harris_detector->setMethod(pcl::HarrisKeypoint3D<pcl::PointXYZRGB,pcl::PointXYZI>::LOWE);
	harris_detector->compute(*Harris_keypoints);
	cout << "Harris_keypoints的大小是" << Harris_keypoints->size() << endl;
	writer.write<pcl::PointXYZI>("Harris_keypoints.pcd", *Harris_keypoints, false);

	pcl::visualization::PCLVisualizer visu3("clouds");
	visu3.setBackgroundColor(255, 255, 255);
	visu3.addPointCloud(Harris_keypoints, ColorHandlerT3(Harris_keypoints, 0.0, 0.0, 255.0), "Harris_keypoints");
	visu3.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 8, "Harris_keypoints");
	visu3.addPointCloud(input_cloud, "input_cloud");
	visu3.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 0, 0, 0, "input_cloud");
	visu3.spin();
}

Guess you like

Origin blog.csdn.net/zzh_AI/article/details/92973574