StatisticalOutlierRemoval - Vector subscript out of range

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

StatisticalOutlierRemoval - Vector subscript out of range

kerrermanisNL
Hi,

This is my first post to the mailing list, so if I do anything wrong be sure to tell me :)

I've been trying to use StatisticalOutlierRemoval working on a point cloud of mine, but I keep receiving this error:

Debug Assertion Failed!

Program: ...ation\planar_segmentation\build\Debug\planar_segmentation.exe
File: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector
Line: 916

Expression: vector subscript out of range

I've been using the default PCL tutorial for this, and don't think I'm doing anything wrong. I'm not too well versed in C++ or PCL, but I've tried looking around a little but couldn't find where to problem specifically lies. Looking around the web I found that it usually has to do with some faulty indices, but since I don't use any I have a feeling it must be PCL code related. Wondering if this is a bug, or if I'm just giving wrong values? Just for reference I'm using a Point Cloud with data in it (so it's not empty or anything), it has quite a lot of points (200,000/300,000 usually).

Here's my code, let me know if something's wrong here:

cout << "\nLoading point cloud data...\n";
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PolygonMesh triangles;
pcl::io::loadPolygonFileSTL(model_path + filename, triangles);
pcl::fromROSMsg(triangles.cloud, *cloud);
cout << "\nPoint clound data loaded.";

cout << "\nRemoving outliers...";
pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB> statistical_outlier_removal;
statistical_outlier_removal.setInputCloud(cloud);
statistical_outlier_removal.setMeanK(50);
statistical_outlier_removal.setStddevMulThresh(1.0);
statistical_outlier_removal.filter(*cloud); //Fails here
cout << "\nOutliers removed.";
Reply | Threaded
Open this post in threaded view
|

Re: StatisticalOutlierRemoval - Vector subscript out of range

__Jan__
Create a new cloud:
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud2 = new PointCloud2();

then:
statistical_outlier_removal.filter(*cloud2);

You are using the same cloud for input and output, I guess here is the error.

And welcome to the list.


On 15/06/15 07:17, kerrermanisNL wrote:
Hi,

This is my first post to the mailing list, so if I do anything wrong be sure
to tell me :)

I've been trying to use StatisticalOutlierRemoval working on a point cloud
of mine, but I keep receiving this error:

Debug Assertion Failed!

Program: ...ation\planar_segmentation\build\Debug\planar_segmentation.exe
File: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector
Line: 916

Expression: vector subscript out of range

I've been using the  default PCL tutorial
<http://pointclouds.org/documentation/tutorials/statistical_outlier.php>  
for this, and don't /think/ I'm doing anything wrong. I'm not too well
versed in C++ or PCL, but I've tried looking around a little but couldn't
find where to problem specifically lies. Looking around the web I found that
it usually has to do with some faulty indices, but since I don't use any I
have a feeling it must be PCL code related. Wondering if this is a bug, or
if I'm just giving wrong values? Just for reference I'm using a Point Cloud
with data in it (so it's not empty or anything), it has quite a lot of
points (200,000/300,000 usually).

Here's my code, let me know if something's wrong here:

cout << "\nLoading point cloud data...\n";
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new
pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PolygonMesh triangles;
pcl::io::loadPolygonFileSTL(model_path + filename, triangles);
pcl::fromROSMsg(triangles.cloud, *cloud);
cout << "\nPoint clound data loaded.";

cout << "\nRemoving outliers...";
pcl::StatisticalOutlierRemoval<pcl::PointXYZRGB>
statistical_outlier_removal;
statistical_outlier_removal.setInputCloud(cloud);
statistical_outlier_removal.setMeanK(50);
statistical_outlier_removal.setStddevMulThresh(1.0);
statistical_outlier_removal.filter(*cloud); //Fails here
cout << "\nOutliers removed.";



--
View this message in context: http://www.pcl-users.org/StatisticalOutlierRemoval-Vector-subscript-out-of-range-tp4038593.html
Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: StatisticalOutlierRemoval - Vector subscript out of range

kerrermanisNL
Ah well... That worked.

Just out of curiosity why can't you just put the filtered cloud back in the original cloud? It works for things such as ConditionalRemoval etc.

Anyway, thanks for the tip. I would have tried that myself if I hadn't thought that was supposed to be okay! :D
Reply | Threaded
Open this post in threaded view
|

Re: StatisticalOutlierRemoval - Vector subscript out of range

__Jan__
What do you mean by

Just out of curiosity why can't you just put the filtered cloud back in the
original cloud? It works for things such as ConditionalRemoval etc.


Conditional Removal works with the same cloud as input and output? Could
you check please again on this.

If yes that would be new to me and totally unexpected.




On 15/06/15 09:05, kerrermanisNL wrote:

> Ah well... That worked.
>
> Just out of curiosity why can't you just put the filtered cloud back in the
> original cloud? It works for things such as ConditionalRemoval etc.
>
> Anyway, thanks for the tip. I would have tried that myself if I hadn't
> thought that was supposed to be okay! :D
>
>
>
> --
> View this message in context: http://www.pcl-users.org/StatisticalOutlierRemoval-Vector-subscript-out-of-range-tp4038593p4038595.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: StatisticalOutlierRemoval - Vector subscript out of range

kerrermanisNL
This post was updated on .
Yeah it works with the same cloud as input and output. For example, I use this code and that works fine:

//Filter object
pcl::ConditionalRemoval<pcl::PointXYZRGB> filter;
filter.setCondition(condition);
filter.setInputCloud(cloud);//input cloud (same as the cloud that receives the filter)
filter.filter(*cloud); //Filter the cloud back in the original input cloud.

I left out the condition creation part etc. if you want that as well just let me know!
Reply | Threaded
Open this post in threaded view
|

Re: StatisticalOutlierRemoval - Vector subscript out of range

andersgb1
As far as I'm aware, some classes have recently been "fixed" to also work in-place, e.g. VoxelGrid. This is not the case for all filters, however, including StatisticalOutlierRemovel.

On Mon, Jun 15, 2015 at 9:43 AM, kerrermanisNL <[hidden email]> wrote:
Yeah it works with the same cloud as input and output. For example, I use
this code and that works fine:

pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);

pcl::SACSegmentation<pcl::PointXYZRGB> seg;
seg.setOptimizeCoefficients (true);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setModelType (pcl::SACMODEL_PERPENDICULAR_PLANE);
seg.setAxis(Eigen::Vector3f(0, 1, 0)); //xyz
seg.setDistanceThreshold (distance_threshold);
seg.setEpsAngle(pcl::deg2rad(maximum_angle_threshold));
seg.setInputCloud(cloud); //input cloud (same as the cloud that eventually
receives the filter)
seg.setMaxIterations(1000);
seg.segment(*inliers, *coefficients);

for (size_t i = 0; i < inliers->indices.size (); ++i){
        cloud->points[inliers->indices[i]].r = 255;
        cloud->points[inliers->indices[i]].g = 255;
        cloud->points[inliers->indices[i]].b = 255;
}

//Create filtering codition. Points not marked (rgb 0) will be filtered out.
Marking was done during segmentation.
pcl::ConditionAnd<pcl::PointXYZRGB>::Ptr condition(new
pcl::ConditionAnd<pcl::PointXYZRGB>);
condition->addComparison(pcl::PackedRGBComparison<pcl::PointXYZRGB>::ConstPtr(new
pcl::PackedRGBComparison<pcl::PointXYZRGB>("r", pcl::ComparisonOps::EQ,
0)));
condition->addComparison(pcl::PackedRGBComparison<pcl::PointXYZRGB>::ConstPtr(new
pcl::PackedRGBComparison<pcl::PointXYZRGB>("g", pcl::ComparisonOps::EQ,
0)));
condition->addComparison(pcl::PackedRGBComparison<pcl::PointXYZRGB>::ConstPtr(new
pcl::PackedRGBComparison<pcl::PointXYZRGB>("b", pcl::ComparisonOps::EQ,
0)));

//Filter object
pcl::ConditionalRemoval<pcl::PointXYZRGB> filter;
filter.setCondition(condition);
filter.setInputCloud(cloud);
filter.filter(*cloud); //Filter the cloud back in the original.



--
View this message in context: http://www.pcl-users.org/StatisticalOutlierRemoval-Vector-subscript-out-of-range-tp4038593p4038598.html
Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


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