Segmentation Fault when trying to optimizeModelCoefficients

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Segmentation Fault when trying to optimizeModelCoefficients

MHamad
This post was updated on .
This code runs perfect and gives me some what accurate results, however when
adding the last line of code
(model_s->optimizeModelCoefficients(*inliers,coeff,coeff_refined);) the
program gives me segmentation fault. No idea why. Any help would be
appreciated.

boost::shared_ptr<std::vector&lt;int> > inliers (new std::vector<int>);

    pcl::SampleConsensusModelSphere<pcl::PointXYZRGB>::Ptr
            model_s(new pcl::SampleConsensusModelSphere<pcl::PointXYZRGB>
(cloud_sphere));

    model_s->setRadiusLimits(0.24875, 0.25125);
    pcl::RandomSampleConsensus<pcl::PointXYZRGB> ransac (model_s,0.1);

    bool result = ransac.computeModel();
    ransac.getInliers(*inliers);
    Eigen::VectorXf coeff;
    ransac.getModelCoefficients (coeff);
    Eigen::VectorXf coeff_refined;

This function is responsible of segmentation fault:
   model_s->optimizeModelCoefficients(*inliers,coeff,coeff_refined);



--
Sent from: http://www.pcl-users.org/
_______________________________________________
PCL-users@pointclouds.org / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Segmentation Fault when trying to optimizeModelCoefficients

Hilarius
Hi,

I can't explain the problem, but tell you that I faced similar problems.
I used a plane model for my Ransac and PCL offered a flag to indicate to
produce optimized coefficients following a tutorial.
(http://pointclouds.org/documentation/tutorials/planar_segmentation.php#planar-segmentation).
I get complete useless results with the optimization and plausible
values without it.

Even worse, but only specific to my use case, optimization was enabled
by default even though setting it in the tutorial implied its default
value would be off.

Regards
Felix



> This code runs perfect and gives me some what accurate results, however when
> adding the last line of code
> (model_s->optimizeModelCoefficients(*inliers,coeff,coeff_refined);) the
> program gives me segmentation fault. No idea why. Any help would be
> appreciated.
>
> boost::shared_ptr<std::vector&lt;int> > inliers (new std::vector<int>);
>
>      pcl::SampleConsensusModelSphere<pcl::PointXYZRGB>::Ptr
>              model_s(new pcl::SampleConsensusModelSphere<pcl::PointXYZRGB>
> (cloud_sphere));
>
>      model_s->setRadiusLimits(0.24875, 0.25125);
>      pcl::RandomSampleConsensus<pcl::PointXYZRGB> ransac (model_s,0.1);
>
>      bool result = ransac.computeModel();
>      ransac.getInliers(*inliers);
>      Eigen::VectorXf coeff;
>      ransac.getModelCoefficients (coeff);
>      Eigen::VectorXf coeff_refined;
>
> This function is responsible to segmentation fault:
>     model_s->optimizeModelCoefficients(*inliers,coeff,coeff_refined);
>
>
>
> --
> Sent from: http://www.pcl-users.org/
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users