How to use octrees

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

How to use octrees

Yellaine
Hello everybody,

I'm trying to use the octree structures for my project, and I've read the tree tutorials on the subjects, but that didn't answered all my questions; it shows very particular use of octrees but I don't manage to expand from there.

Using also the documentation ( http://docs.pointclouds.org/trunk/classpcl_1_1octree_1_1_octree_point_cloud.html#a87cad20428de876fcf789e674a39f503 ),
I want to create a simple octree (in order to then go through all the leaves).


void filter_octree (sensor_msgs::PointCloud2::Ptr cloud, sensor_msgs::PointCloud2::Ptr cloud_filtered) {
       
        double resolution = 1.0;
        pcl::octree::OctreePointCloud<sensor_msgs::PointCloud2> octree (resolution);
        octree.setInputCloud(cloud,0);

}


Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: How to use octrees

aichim
Administrator
Hi,

You have two very convenient structures that you can use LeafNodeIterator and ConstLeafNodeIterator. They were in the documentation :-)

Cheers,
Alex
---
http://www.alexichim.com
http://www.openperception.org




On May 20, 2013, at 12:20 PM, Yellaine <[hidden email]> wrote:

> Hello everybody,
>
> I'm trying to use the octree structures for my project, and I've read the
> tree tutorials on the subjects, but that didn't answered all my questions;
> it shows very particular use of octrees but I don't manage to expand from
> there.
>
> Using also the documentation (
> http://docs.pointclouds.org/trunk/classpcl_1_1octree_1_1_octree_point_cloud.html#a87cad20428de876fcf789e674a39f503
> ),
> I want to create a simple octree (in order to then go through all the
> leaves).
>
>
> void filter_octree (sensor_msgs::PointCloud2::Ptr cloud,
> sensor_msgs::PointCloud2::Ptr cloud_filtered) {
>
> double resolution = 1.0;
> pcl::octree::OctreePointCloud<sensor_msgs::PointCloud2> octree
> (resolution);
> octree.setInputCloud(cloud,0);
>
> }
>
>
> Thanks in advance.
>
>
>
> --
> View this message in context: http://www.pcl-users.org/How-to-use-octrees-tp4027908.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: How to use octrees

Yellaine
aichim wrote
Hi,

You have two very convenient structures that you can use LeafNodeIterator and ConstLeafNodeIterator. They were in the documentation :-)

Cheers,
Alex
Hi, thanks for your answer but that wasn't exactly my question (though it's useful as well)
Let me rephrase my issue: I would like to use octrees with sensor_msgs::PointCloud2 clouds, so that I can use generic clouds and not just, for exemple XYZ clouds, in the same way as I did for voxel grids:

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
pcl::PCDReader reader;
reader.read (path_in, *cloud);
pcl::VoxelGrid<sensor_msgs::PointCloud2> grid;
grid.setInputCloud (cloud);


But when I do

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
pcl::PCDReader reader;
reader.read (path_in, *cloud);
pcl::octree::OctreePointCloud<sensor_msgs::PointCloud2> octree (1.0);
octree.setInputCloud(cloud);


I get a conflict of types:
cannot convert parameter 1 from 'sensor_msgs::PointCloud2::Ptr' to 'const boost::shared_ptr<T> &'
Reply | Threaded
Open this post in threaded view
|

Re: How to use octrees

andersgb1
That's very likely because OctreePointCloud doesn't have an implementation for PointCloud2. I don't think you can get around that with either 1) providing an implementation class for the PointCloud2 type or 2) converting to a PointCloud type for processing.


On 21 May 2013 10:19, Yellaine <[hidden email]> wrote:
aichim wrote
> Hi,
>
> You have two very convenient structures that you can use LeafNodeIterator
> and ConstLeafNodeIterator. They were in the documentation :-)
>
> Cheers,
> Alex

Hi, thanks for your answer but that wasn't exactly my question (though it's
useful as well)
Let me rephrase my issue: I would like to use octrees with
sensor_msgs::PointCloud2 clouds, so that I can use generic clouds and not
just, for exemple XYZ clouds, in the same way as I did for voxel grids:

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
pcl::PCDReader reader;
reader.read (path_in, *cloud);
pcl::VoxelGrid<sensor_msgs::PointCloud2> grid;
grid.setInputCloud (cloud);


But when I do

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
pcl::PCDReader reader;
reader.read (path_in, *cloud);
pcl::octree::OctreePointCloud<sensor_msgs::PointCloud2> octree (1.0);
octree.setInputCloud(cloud);


I get a conflict of types:
/cannot convert parameter 1 from 'sensor_msgs::PointCloud2::Ptr' to 'const
boost::shared_ptr<T> &'/



--
View this message in context: http://www.pcl-users.org/How-to-use-octrees-tp4027908p4027919.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: How to use octrees

andersgb1
*with=without


On 21 May 2013 11:19, Anders Glent Buch <[hidden email]> wrote:
That's very likely because OctreePointCloud doesn't have an implementation for PointCloud2. I don't think you can get around that with either 1) providing an implementation class for the PointCloud2 type or 2) converting to a PointCloud type for processing.


On 21 May 2013 10:19, Yellaine <[hidden email]> wrote:
aichim wrote
> Hi,
>
> You have two very convenient structures that you can use LeafNodeIterator
> and ConstLeafNodeIterator. They were in the documentation :-)
>
> Cheers,
> Alex

Hi, thanks for your answer but that wasn't exactly my question (though it's
useful as well)
Let me rephrase my issue: I would like to use octrees with
sensor_msgs::PointCloud2 clouds, so that I can use generic clouds and not
just, for exemple XYZ clouds, in the same way as I did for voxel grids:

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
pcl::PCDReader reader;
reader.read (path_in, *cloud);
pcl::VoxelGrid<sensor_msgs::PointCloud2> grid;
grid.setInputCloud (cloud);


But when I do

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
pcl::PCDReader reader;
reader.read (path_in, *cloud);
pcl::octree::OctreePointCloud<sensor_msgs::PointCloud2> octree (1.0);
octree.setInputCloud(cloud);


I get a conflict of types:
/cannot convert parameter 1 from 'sensor_msgs::PointCloud2::Ptr' to 'const
boost::shared_ptr<T> &'/



--
View this message in context: http://www.pcl-users.org/How-to-use-octrees-tp4027908p4027919.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: How to use octrees

Yellaine
In reply to this post by aichim
aichim wrote
You have two very convenient structures that you can use LeafNodeIterator and ConstLeafNodeIterator.
So I'm now trying to use them. As I said, my goal is to go through each leaves in order to decimate them. Here is the relevant part of the code:

        octree::OctreePointCloud<PointXYZ> octree (leafSize);
        octree.setInputCloud(cloud);
        octree.addPointsFromInputCloud();

        octree::OctreePointCloudPointVector<PointXYZ>::LeafNodeIterator iter(octree);
        vector<int> data;
        vector<PointXYZ> points;

        for (size_t i=0; i < octree.getLeafCount() ; i++) {
                if (iter.isLeafNode()) {
                        data.clear();
                        points.clear();
                        iter.getData(data);
                        for (size_t j=0; j < data.size() ; j++) {
                                points.push_back(octree.getPointByIndex(data[j]));
                        }
                }
                iter++;
        }


It doesn't work since getPointByIndex is a protected member. Am not using it right? Am I not using the right  function?
Reply | Threaded
Open this post in threaded view
|

Re: How to use octrees

Julius Kammerl
You don't need to call the protected octree->getPointByIndex method since you have the pointcloud structure available. Looking up points by index works like this: cloud->points[index]


On Wed, May 22, 2013 at 8:44 AM, Yellaine <[hidden email]> wrote:
aichim wrote
> You have two very convenient structures that you can use LeafNodeIterator
> and ConstLeafNodeIterator.

So I'm now trying to use them. As I said, my goal is to go through each
leaves in order to decimate them. Here is the relevant part of the code:

*       octree::OctreePointCloud<PointXYZ> octree (leafSize);
        octree.setInputCloud(cloud);
        octree.addPointsFromInputCloud();

        octree::OctreePointCloudPointVector<PointXYZ>::LeafNodeIterator
iter(octree);
        vector<int> data;
        vector<PointXYZ> points;

        for (size_t i=0; i < octree.getLeafCount() ; i++) {
                if (iter.isLeafNode()) {
                        data.clear();
                        points.clear();
                        iter.getData(data);
                        for (size_t j=0; j < data.size() ; j++) {
                                points.push_back(octree.getPointByIndex(data[j]));
                        }
                }
                iter++;
        }*

It doesn't work since getPointByIndex is a protected member. Am not using it
right? Am I not using the right  function?



--
View this message in context: http://www.pcl-users.org/How-to-use-octrees-tp4027908p4027940.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