ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

PCL error in moving least squares

asked 2014-11-03 08:21:07 -0500 gravatar image

updated 2014-11-03 08:54:06 -0500

paulbovbel gravatar image

I am using the Moving Least square code provided in pcl, here is my code exaclty:


int main(int argc, char **argv) {
    pcl::PointCloud <pcl::PointXYZ> cloud;
    pcl::io::loadPCDFile("KinectPointCloudChest2_filtered.pcd", cloud); // Create a KD-Tree
    pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree <pcl::PointXYZ>); 
    // Output has the PointNormal type in order to store the normals calculated by MLS
    pcl::PointCloud <pcl::PointNormal> mls_points; 
    // Init object (second point type is for the normals, even if unused)
    pcl::MovingLeastSquares <pcl::PointXYZ, pcl::PointNormal> mls;
    mls.setComputeNormals(true); // Set parameters
    mls.setSearchRadius(0.03); // Reconstruct
    pcl::PointCloud<pcl::PointXYZ>::Ptr mls_cloud(new pcl::PointCloud <pcl::PointXYZ>);
    for (size_t i = 0; i < mls_points.points.size(); ++i) {
        mls_cloud->points.x = mls_points.points.x; //error
        mls_cloud->points.y = mls_points.points.y;
        mls_cloud->points.z = mls_points.points.z;
    pcl::io::savePCDFile("KinectPointCloudChest2_mls.pcd", mls_points);
    return 0;

but I get an error throw pcl::IOException ("[pcl::PCDWriter::writeASCII] Input point cloud has no data!"); what to do in this case?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-11-03 09:08:04 -0500

paulbovbel gravatar image

Generally, you'll have more luck with PCL-specific guidance on the PCL boards/mailing list.

If you mean you're following this tutorial, everything looks good until you try to run the for loop, where you're not actually indexing into the points array, or even using the mls_cloud object for anything afterwards.

edit flag offensive delete link more


precisely.Do you already have a solution?

meng gravatar image meng  ( 2016-03-24 09:16:48 -0500 )edit

answered 2016-07-06 11:23:34 -0500

add #include <pcl/surface/impl/mls.hpp>

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-03 08:21:07 -0500

Seen: 1,464 times

Last updated: Jul 06 '16