Quantcast

extracting indices tutorial vector subscript error

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

extracting indices tutorial vector subscript error

Kasia Robnett
Hi List,

I've done some searching for this but not found anything, which could mean user error somewhere... I have used the 1.0.0 release and trunk code (r1277).

When I try the "Extracting indices from a PointCloud tutorial (copied first from the site, then tried doc/tutorials/content/sources/extract_indices), it crashes in the while loop at

extract.filter (*cloud_filtered);

with a "vector subscript out of range" error.  I think this is because the extract instance's input_ cloud is also the output, so when the applyFilter() function resizes the output for the copying, it resizes the internal input as well, and then tries to access indices from the input which are now out of range.  I was able to work-around this by filtering to a temporary cloud, then copying it back to cloud_filtered.

Thank you for all the great docs and tutorials - it has been very easy to get started with this library :)

Kasia


_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

Sven Albrecht
Hi Kasia,

can you perhaps provide us with a bit more info? Which OS are you using,  
32 or 64 bit version? I just tried the source code provided on the  
tutorial page (which is exactly the same as in  
doc/tutorials/content/sources/extract_indices.cpp) and was able to run it  
without any problems on Ubuntu 10.10, 64bit, r1281.
However looking at the code of extract_indices.hpp I agree with your  
explanation of the error. Can someone else confirm reproduce this error?

Cheers,
Sven

On Wed, 15 Jun 2011 04:01:14 +1200, Kasia Robnett  
<[hidden email]> wrote:

> Hi List,
>
> I've done some searching for this but not found anything, which could  
> mean
> user error somewhere... I have used the 1.0.0 release and trunk code
> (r1277).
>
> When I try the "Extracting indices from a PointCloud tutorial (copied  
> first
> from the site, then tried  
> doc/tutorials/content/sources/extract_indices), it
> crashes in the while loop at
>
> extract.filter (*cloud_filtered);
>
> with a "vector subscript out of range" error.  I think this is because  
> the
> extract instance's input_ cloud is also the output, so when the
> applyFilter() function resizes the output for the copying, it resizes the
> internal input as well, and then tries to access indices from the input
> which are now out of range.  I was able to work-around this by filtering  
> to
> a temporary cloud, then copying it back to cloud_filtered.
>
> Thank you for all the great docs and tutorials - it has been very easy to
> get started with this library :)
>
> Kasia


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

Kasia Robnett
In reply to this post by Kasia Robnett
Hi Sven,

I am using Windows XP, 32-bit, compiled using Visual Studio Express C++ 2008.  I am inexperienced with Windows, so please let me know if there is any other pertinent info.

Best Regards,
Kasia
 
Hi Kasia,

can you perhaps provide us with a bit more info? Which OS are you using,
32 or 64 bit version? I just tried the source code provided on the
tutorial page (which is exactly the same as in
doc/tutorials/content/sources/extract_indices.cpp) and was able to run it
without any problems on Ubuntu 10.10, 64bit, r1281.
However looking at the code of extract_indices.hpp I agree with your
explanation of the error. Can someone else confirm reproduce this error?

Cheers,
Sven

On Wed, 15 Jun 2011 04:01:14 +1200, Kasia Robnett
<[hidden email]> wrote:

> Hi List,
>
> I've done some searching for this but not found anything, which could
> mean
> user error somewhere... I have used the 1.0.0 release and trunk code
> (r1277).
>
> When I try the "Extracting indices from a PointCloud tutorial (copied
> first
> from the site, then tried
> doc/tutorials/content/sources/extract_indices), it
> crashes in the while loop at
>
> extract.filter (*cloud_filtered);
>
> with a "vector subscript out of range" error.  I think this is because
> the
> extract instance's input_ cloud is also the output, so when the
> applyFilter() function resizes the output for the copying, it resizes the
> internal input as well, and then tries to access indices from the input
> which are now out of range.  I was able to work-around this by filtering
> to
> a temporary cloud, then copying it back to cloud_filtered.
>
> Thank you for all the great docs and tutorials - it has been very easy to
> get started with this library :)
>
> Kasia


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


------------------------------

Message: 5
Date: Tue, 14 Jun 2011 17:28:42 -0700
From: "Radu B. Rusu" <[hidden email]>
Subject: Re: [PCL-users] Problem with pcl::copyPointCloud
To: "Point Cloud Library (PCL) mailing list" <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Carlos,

I just implemented this feature in trunk/pcl-1.x branch (r1285).

Cheers,
Radu.
--
Point Cloud Library (PCL) - http://pointclouds.org

On 06/14/2011 02:45 PM, Carlos Orrego wrote:
> Dear people, I'm trying to use copyPointCloud to copy from a PointXYZRGB cloud into a PointXYZ cloud, using the
> following code:
>
> PointCloud<PointXYZRGB>::Ptr cloud_rgb (new PointCloud<PointXYZRGB> ());
> PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ> ());
> // load data into cloud_rgb
> // (...)
> copyPointCloud<PointXYZRGB,PointXYZ>(*cloud_rgb, *cloud);
>
> However, i'm getting the following error:
> Error10error C2499: 'pcl::traits::datatype<PointT,Tag>' : a class cannot be its own base classc:\program files
> (x86)\pcl\include\pcl-1.0\pcl\ros\point_traits.h
> Error11error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed
> ************(__thiscall pcl::traits::datatype<PointT,Tag>::POINT_TYPE_NOT_PROPERLY_REGISTERED::* ***********)(PointT)'
> to 'boost::mpl::assert<false>::type'c:\program files (x86)\pcl\include\pcl-1.0\pcl\ros\point_traits.h
> among others.
>
> I don't understand what I'm doing wrong here. Thank you very much!
>
>
> --
> Carlos Orrego Sep?lveda
> Ingeniero Civil Inform?tico, UTFSM
> MS in Computer Science Student, Stony Brook University
> Founding Partner, Trigensoft Ltda.
>
>
>
> _______________________________________________
> [hidden email] / http://pointclouds.org
> https://code.ros.org/mailman/listinfo/pcl-users


------------------------------

Message: 6
Date: Wed, 15 Jun 2011 16:40:45 +0200
From: Agnieszka Gardecka <[hidden email]>
Subject: Re: [PCL-users] problem with vtk
To: "Point Cloud Library (PCL) mailing list" <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

W dniu 2011-06-14 23:06, Mourad Boufarguine pisze:
> Ok, all seems ok but the directory where you built PCL. Can you avoid
> C:/Program Files/PCL ? this folder is where pcl will get installed.
> I suggest you build PCL in, say, C:/PCL/build . Remove
> completely C:/Program Files/PCL folder. Build PCL in debug and
> release, and then build the INSTALL project in both debug and release.
> After that, PCL headers, libs and dlls will get copied to C:/Program
> Files/PCL .
>
> After that, in your own projects, you should use that PCL folder.

I did as you wrote. Everything built without any errors. But problem
with dll's (from PCL/bin) and debug mode is the same..
I think i have to resign from using debug.

> I suggest you use cmake to configure your own project. There are
> samples for CMakeLists files in the tutorials (look int
> C:/PCL/doc/tutorials/content/sources/cloud_viewer for example)

I don't know yet how, but i'll try it.

Greetings,
Agnieszka


------------------------------

Message: 7
Date: Wed, 15 Jun 2011 17:01:35 +0200
From: Mourad Boufarguine <[hidden email]>
Subject: Re: [PCL-users] problem with vtk
To: "Point Cloud Library (PCL) mailing list" <[hidden email]>
Message-ID: <BANLkTi=[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

On Wed, Jun 15, 2011 at 4:40 PM, Agnieszka Gardecka <
[hidden email]> wrote:

> W dniu 2011-06-14 23:06, Mourad Boufarguine pisze:
> > Ok, all seems ok but the directory where you built PCL. Can you avoid
> > C:/Program Files/PCL ? this folder is where pcl will get installed.
> > I suggest you build PCL in, say, C:/PCL/build . Remove
> > completely C:/Program Files/PCL folder. Build PCL in debug and
> > release, and then build the INSTALL project in both debug and release.
> > After that, PCL headers, libs and dlls will get copied to C:/Program
> > Files/PCL .
> >
> > After that, in your own projects, you should use that PCL folder.
>
> I did as you wrote. Everything built without any errors.


Great!


> But problem
> with dll's (from PCL/bin)


mmm, this is weird. What kind of problem ? dll not found ?


> and debug mode is the same..
> I think i have to resign from using debug.
>
> > I suggest you use cmake to configure your own project. There are
> > samples for CMakeLists files in the tutorials (look int
> > C:/PCL/doc/tutorials/content/sources/cloud_viewer for example)
>
> I don't know yet how, but i'll try it.
>

Yeah, this can solve your problem.


>
> Greetings,
> Agnieszka
>

Cheers,
Mourad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /lurker/list/pcl-users.html/attachments/20110615/0466e3a9/attachment.htm

------------------------------

_______________________________________________
[hidden email] / http://pcl.ros.org
https://code.ros.org/mailman/listinfo/pcl-users


End of PCL-users Digest, Vol 10, Issue 94
*****************************************


_______________________________________________
[hidden email] / http://pointclouds.org
https://code.ros.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

harry52
In reply to this post by Kasia Robnett
Hello,

I am confronting the same problem with Kasia's

Does anyone have a solution for this?

Thanks,
Harry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

Mourad


On Tue, Feb 14, 2012 at 1:14 PM, harry52 <[hidden email]> wrote:
Hello,

I am confronting the same problem with Kasia's

Does anyone have a solution for this?

Thanks,
Harry



Hi,

It will go into the 1.5.0 release.

Cheers,
Mourad


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

Re: extracting indices tutorial vector subscript error

harry52
I have replaced file "extract_indices.cpp" downloaded from http://svn.pointclouds.org/pcl/branches/pcl-1.x/doc/tutorials/content/sources/extract_indices/  to the older one.

And,
my code was already:

...
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>), cloud_p (new pcl::PointCloud<pcl::PointXYZ>), cloud_f (new pcl::PointCloud<pcl::PointXYZ>);


...
   extract.filter (*cloud_f);
   cloud_filtered = cloud_f;

But the exception is the same before. Did I do something wrong?

Regards,
Harry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

harry52
In reply to this post by Mourad
I found a same problem when I was trying to create a new point cloud (inliersCloud) to store inliers after applied "Plane model segmentation".

pcl::PointCloud<pcl::PointXYZ>::Ptr inliersCloud (new pcl::PointCloud<pcl::PointXYZ>);

Then I initialized like this:

                inliersCloud->width = inliers->indices.size ();
                inliersCloud->height = 1;
                inliersCloud->is_dense = false;
                inliersCloud->points.resize(inliersCloud->width * inliersCloud->height);

And the exception disapears. I think my previous problem can solve by this way too, I am checking on it.

----------------------

By the way, I am confusing that: there are 2 ways to define a point cloud, for example:

The first method:
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

Or

The second method:
pcl::PointCloud<pcl::PointXYZ> cloud;

To display this cloud by ShowCloud, is it possible to display only the second definition method?

   pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
   //... populate cloud
   pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer");
   viewer.showCloud (cloud);
   while (!viewer.wasStopped ())
   {
   }


Regards,
Harry



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

Mourad
Harry,

On Tue, Feb 14, 2012 at 4:25 PM, harry52 <[hidden email]> wrote:
I found a same problem when I was trying to create a new point cloud
(inliersCloud) to store inliers after applied "Plane model segmentation".

pcl::PointCloud<pcl::PointXYZ>::Ptr inliersCloud (new
pcl::PointCloud<pcl::PointXYZ>);

Then I initialized like this:

               inliersCloud->width = inliers->indices.size ();
               inliersCloud->height = 1;
               inliersCloud->is_dense = false;
               inliersCloud->points.resize(inliersCloud->width * inliersCloud->height);

And the exception disapears. I think my previous problem can solve by this
way too, I am checking on it.


You're right, the problem wasn't fixed. Now it's fixed in trunk r4468 ( http://dev.pointclouds.org/projects/pcl/repository/diff/trunk/doc?rev=4468&rev_to=4460 ).
 

----------------------

By the way, I am confusing that: there are 2 ways to define a point cloud,
for example:

The first method:
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new
pcl::PointCloud<pcl::PointXYZ>);



Here you're declaring a (boost shared) pointer to a pcl::PointCloud<pcl::PointXYZ> object.
 
Or

The second method:
pcl::PointCloud<pcl::PointXYZ> cloud;


Here, you're declaring a pcl::PointCloud<pcl::PointXYZ> object.
 
To display this cloud by ShowCloud, is it possible to display only the
second definition method?

  pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
  //... populate cloud
  pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer");
  viewer.showCloud (cloud);
  while (!viewer.wasStopped ())
  {
  }


Regards,
Harry



pcl::visualization::CloudViewer::showCloud needs a shared pointer to a Pointcloud object, so you'll need  a  pcl::PointCloud<pcl::PointXYZRGB>::Ptr pointer.
It's preferable to initialize the pointer upon declaration .

 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);

It's possible to draw a shared pointer from an object, but this will create a new object and trigger a deep copy of your PointCloud object.

pcl::PointCloud<pcl::PointXYZRGB> cloud;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr p_cloud = cloud.makeShared ();

So, it's more convenient to always use a shared ptr.

Cheers,
Mourad

Cheers,
Mourad

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

Re: extracting indices tutorial vector subscript error

harry52
Now it works fine, thanks Mourad :)

Regards,
Harry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

JLSS

harry52 wrote
>
> Now it works fine, thanks Mourad :)
>
> Regards,
> Harry
>

Hi Harry,

I am still stuck on this error where I'm crashing at:

                extract.filter (*cloud_plane);
                std::cout << "PointCloud representing the planar component: " <<
cloud_plane->points.size () << " data points." << std::endl;
                cloud_f->width = inliers->indices.size ();
                cloud_f->height = 1;
                cloud_f->is_dense = false;
                cloud_f->points.resize(cloud_f->width * cloud_f->height);
                // Remove the planar inliers, extract the rest
                extract.setNegative (true);
                extract.filter (*cloud_f);
                cloud_filtered = cloud_f;

Would you be able to help me find out why I'm not working?

Thanks!
JL


--
View this message in context: http://www.pcl-users.org/extracting-indices-tutorial-vector-subscript-error-tp3063598p3887915.html
Sent from the Point Cloud Library (PCL) Users mailing list archive at Nabble.com.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

lovegood
after I tried this:

extract.filter (*cloud_f);
*cloud_filtered = *cloud_f;

it worked fine
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: extracting indices tutorial vector subscript error

harry52
In reply to this post by JLSS
Hi JLSS,

I just came back from my vacation. Sorry, now I could be able to reply to you.
Have you already solved your problem?

If not, could you please try replacing this:
cloud_filtered = cloud_f;

by
cloud_filtered.swap (cloud_f);

and see whether it works.


Greetings,
Harry
Loading...