Search
 
SCRIPT & CODE EXAMPLE
 

CPP

PCL normal specific point

#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp>
#include <pcl/features/normal_3d_omp.h>
using namespace std;
int main()
{
    
	//--------------------- Load point cloud data ----------------------
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	if (pcl::io::loadPCDFile<pcl::PointXYZ>(" Car point cloud .pcd", *cloud) == -1)
	{
    
		PCL_ERROR("Could not read file
");
	}
	//-------------- Calculate the front of the cloud 10% The point normal of -----------------------
	vector<int> point_indices(floor(cloud->points.size() / 10));
	for (size_t i = 0; i < point_indices.size(); ++i) {
    
		point_indices[i] = i;	
	}
	//------------------- Pass index ----------------------------
	pcl::IndicesPtr indices(new vector <int>(point_indices));
	//------------------- Calculating normals ----------------------------
	pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> n;//OMP Speed up 
	n.setInputCloud(cloud);
	n.setIndices(indices);
	//  Create a kd Trees , Easy to search ; And pass it to the normal estimation class object created above 
	pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());
	n.setSearchMethod(tree);
	n.setRadiusSearch(0.01);
	pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
	//---------------- Estimate characteristics ---------------
	n.compute(*normals);
	//------------- For convenience of visualization , Before the 10% Point cloud puts forward -------------------------------
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1(new pcl::PointCloud<pcl::PointXYZ>);
	pcl::copyPointCloud(*cloud, point_indices, *cloud1);
	//------------------ visualization -----------------------
	boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("Normal viewer"));
	// Set the background color 
	viewer->setBackgroundColor(0.3, 0.3, 0.3);
	viewer->addText("faxian", 10, 10, "text");
	// Set the point cloud color 
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> single_color1(cloud1, 0, 225, 0);
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> single_color(cloud, 255, 0, 0);
	// Add coordinate system 
	//viewer->addCoordinateSystem(0.1);
	viewer->addPointCloud<pcl::PointXYZ>(cloud, single_color, "sample cloud");
	viewer->addPointCloud<pcl::PointXYZ>(cloud1, single_color1, "sample cloud1");
	viewer->addPointCloudNormals<pcl::PointXYZ, pcl::Normal>(cloud1, normals, 20, 0.02, "normals");
	// Set the point cloud size 
	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "sample cloud1");
	while (!viewer->wasStopped())
	{
    
		viewer->spinOnce(100);
		boost::this_thread::sleep(boost::posix_time::microseconds(100000));
	}

	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ to c code converter online 
Cpp :: start google 
Cpp :: sfml time set 
Cpp :: Hash Sort in C++ 
Cpp :: how to block the screen c++ 
Cpp :: facade pattern C++ code 
Cpp :: c++ scanf always expects double and not float 
Cpp :: Your age doubled is: xx where x is the users age doubled. (print answer with no decimal places) 
Cpp :: c++ correct upto 3 decimal places 
Cpp :: c++ bind what are placeholders 
Cpp :: assign array to array 
Cpp :: ubuntu dotnet create blazorserver linux 
Cpp :: flowchart to display factors of a number 
Cpp :: For auto map C 
Cpp :: c++ Unable to get CMake Tutorial example to compile 
Cpp :: Accepting multiple inputs on the SAME LINE C++ 
Cpp :: c++ string to vector using delimiter 
Cpp :: c++ map access 
Cpp :: 271533778232847 
Cpp :: c++ to c converter online 
Cpp :: fibonacci search algorithm c++ 
Cpp :: python pour débutant 
Cpp :: https://www.geeksforgeeks.org/a-program-to-check-if-strings-are-rotations-of-each-other/ 
Cpp :: changing key bindings in visual code not working 
Cpp :: Chef and IPC Certificates codechef solution in c++ 
Cpp :: how to store array of string with spaces in c++ stl 
Cpp :: 976. Largest Perimeter Triangle leetcode solution in c++ 
Cpp :: pointeur cpp 
Cpp :: how to declare a function in c++ header file 
Cpp :: converter c++ to c 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =