Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix addPointCloudNormals with view point information #1504

Merged
merged 1 commit into from
Aug 18, 2016
Merged

Fix addPointCloudNormals with view point information #1504

merged 1 commit into from
Aug 18, 2016

Conversation

VictorLamoine
Copy link
Contributor

Fixes #1475

Test code

#include <pcl/console/parse.h>
#include <pcl/point_types.h>
#include <pcl/io/vtk_lib_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/features/normal_3d.h>

typedef pcl::PointXYZ PointT;
typedef pcl::PointCloud<PointT> PointCloudT;

int main(int argc, char *argv[])
{
  std::vector<int> ply_file_indices = pcl::console::parse_file_extension_argument(argc, argv, ".ply");
  if (ply_file_indices.size() != 1)
  {
    PCL_ERROR("Wrong usage: %s input.ply\n", argv[0]);
  }

  // Load mesh
  pcl::PolygonMesh cad;
  if (pcl::io::loadPolygonFilePLY(argv[ply_file_indices[0]], cad) == 0)
  {
    PCL_ERROR("Failed to read PLY file %s\n", argv[ply_file_indices[0]]);
    return -1;
  }

  // Convert to point cloud
  PointCloudT::Ptr cloud (new PointCloudT);
  pcl::fromPCLPointCloud2(cad.cloud, *cloud);

  //TODO: Comment the two following lines to test WITHOUT cloud view point
  cloud->sensor_origin_ << 0.3, 0, 0.2, 0;
  cloud->sensor_orientation_ = Eigen::Quaternionf (0, 1, 0, 1); // Deforms the cloud!

  // Estimate normals
  pcl::NormalEstimation<PointT, pcl::Normal> ne;
  ne.setInputCloud (cloud);
  pcl::search::KdTree<PointT>::Ptr tree (new pcl::search::KdTree<PointT> ());
  ne.setSearchMethod (tree);
  pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
  ne.setRadiusSearch (0.08);
  ne.compute (*cloud_normals);

  // Display everything
  pcl::visualization::PCLVisualizer viewer;
  viewer.addCoordinateSystem(0.5);
  viewer.addPointCloud(cloud, "my_cloud");
  viewer.addPointCloudNormals<PointT,pcl::Normal>(cloud, cloud_normals);
  viewer.spin();
  return 0;
}

@athundt does it fix your issue? It does for me 😉

@VictorLamoine
Copy link
Contributor Author

Ping! 🌺
@athundt

@ahundt
Copy link

ahundt commented Mar 10, 2016

sorry lost track of this, I haven't been using this part of the code recently so I'm not set up to test it right now. Sorry!

@ahundt
Copy link

ahundt commented Mar 10, 2016

Looking at the change it does seem reasonable however!

@SergioRAgostinho SergioRAgostinho added this to the pcl-1.8.1 milestone Jul 14, 2016
@SergioRAgostinho SergioRAgostinho merged commit c9563f2 into PointCloudLibrary:master Aug 18, 2016
@VictorLamoine VictorLamoine deleted the addPointCloudNormals_fix branch August 22, 2016 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PCLVisualizer::addPointCloudNormals does not account for cloud pose
4 participants