ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

PCL error in moving least squares

asked 2014-11-03 08:21:07 -0600

sarah.ali.1@ulaval.ca gravatar image

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

paulbovbel gravatar image

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

<iostream>
<pcl/point_types.h>
<pcl/point_cloud.h>
<pcl/io/pcd_io.h>
<pcl/visualization/pcl_visualizer.h>
<pcl/kdtree/kdtree_flann.h>
<pcl/surface/mls.h>

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.setInputCloud(cloud.makeShared());
    mls.setPolynomialFit(true);
    mls.setPolynomialOrder(2);
    mls.setSearchMethod(tree);
    mls.setSearchRadius(0.03); // Reconstruct
    mls.process(mls_points);
    pcl::PointCloud<pcl::PointXYZ>::Ptr mls_cloud(new pcl::PointCloud <pcl::PointXYZ>);
    mls_cloud->resize(mls_points.size());
    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;
        //error
        mls_cloud->points.z = mls_points.points.z;
        //error
    }
    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
0

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

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

Comments

precisely.Do you already have a solution?

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

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

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 1,601 times

Last updated: Jul 06 '16