Using AreaPickingEvent in pcl visualization

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

Using AreaPickingEvent in pcl visualization

FELIPE IGNACIO INOSTROZA

Hello everyone,

I am displaying a single pointCloud in a pcl::visualization::PCLVisualizer class and I want to get a selection of points using an AreaPickingEvent.
I am able to register to those events and I get the events with no problems.

The events gives me a vector of Indices but I have no idea what those indices mean. How can I get the 3D coordinates of the points?

Also any tips on an easy way of making those points change colour?


Thanks for your help

Felipe

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

Re: Using AreaPickingEvent in pcl visualization

aichim
Administrator
Hi,

Those values represent the indices of the points you have selected from the point cloud that you are visualising.

You can access the coordinates via (*cloud)[indices[i]].getVector3fMap ().

Cheers,
Alex


On Sep 12, 2013, at 5:09 PM, FELIPE IGNACIO INOSTROZA <[hidden email]> wrote:

>
> Hello everyone,
>
> I am displaying a single pointCloud in a pcl::visualization::PCLVisualizer class and I want to get a selection of points using an AreaPickingEvent.
> I am able to register to those events and I get the events with no problems.
>
> The events gives me a vector of Indices but I have no idea what those indices mean. How can I get the 3D coordinates of the points?
>
> Also any tips on an easy way of making those points change colour?
>
>
> Thanks for your help
>
> Felipe
> _______________________________________________
> [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: Using AreaPickingEvent in pcl visualization

FELIPE IGNACIO INOSTROZA
Hi,
Thanks for the quick answer.

That doesn't seem to be the case.

I was getting segfaults before by just using some pcl functions on the cloud using those indices.

I just tried to remove the points from the cloud to confirm what happens and the points that get removed are random.

Cheers,

Felipe




2013/9/12 Alexandru Ichim <[hidden email]>
Hi,

Those values represent the indices of the points you have selected from the point cloud that you are visualising.

You can access the coordinates via (*cloud)[indices[i]].getVector3fMap ().

Cheers,
Alex


On Sep 12, 2013, at 5:09 PM, FELIPE IGNACIO INOSTROZA <[hidden email]> wrote:

>
> Hello everyone,
>
> I am displaying a single pointCloud in a pcl::visualization::PCLVisualizer class and I want to get a selection of points using an AreaPickingEvent.
> I am able to register to those events and I get the events with no problems.
>
> The events gives me a vector of Indices but I have no idea what those indices mean. How can I get the 3D coordinates of the points?
>
> Also any tips on an easy way of making those points change colour?
>
>
> Thanks for your help
>
> Felipe
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[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: Using AreaPickingEvent in pcl visualization

aichim
Administrator
Hi,

This sounds rather peculiar. Could you post an issue on github with the code you are using (compilable please), along with a test cloud, so we can have a look?

Cheers,
Alex

On Sep 12, 2013, at 5:38 PM, FELIPE IGNACIO INOSTROZA <[hidden email]> wrote:

Hi,
Thanks for the quick answer.

That doesn't seem to be the case.

I was getting segfaults before by just using some pcl functions on the cloud using those indices.

I just tried to remove the points from the cloud to confirm what happens and the points that get removed are random.

Cheers,

Felipe




2013/9/12 Alexandru Ichim <[hidden email]>
Hi,

Those values represent the indices of the points you have selected from the point cloud that you are visualising.

You can access the coordinates via (*cloud)[indices[i]].getVector3fMap ().

Cheers,
Alex


On Sep 12, 2013, at 5:09 PM, FELIPE IGNACIO INOSTROZA <[hidden email]> wrote:

>
> Hello everyone,
>
> I am displaying a single pointCloud in a pcl::visualization::PCLVisualizer class and I want to get a selection of points using an AreaPickingEvent.
> I am able to register to those events and I get the events with no problems.
>
> The events gives me a vector of Indices but I have no idea what those indices mean. How can I get the 3D coordinates of the points?
>
> Also any tips on an easy way of making those points change colour?
>
>
> Thanks for your help
>
> Felipe
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

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

_______________________________________________
[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: Using AreaPickingEvent in pcl visualization

martyvona
We had a similar issue recently.

What seemed to be happening in our case is that we were adding a point cloud to the visualizer that contained some NaN points, i.e. I think in the PCL terminology it was not a "dense" point cloud.

The visualizer seems to remove such invalid points internally.  The indices that are reported for picks (I think this applies to both single point and area picks) refer to the point cloud after this mutation.

We are working around the issue with code like this (this is a generalization of our actual code that I did not test):

vector<int> &indices; //picked indices from visualizer

sort(indices.begin(), indices.end());
 
const int m = indices.size(), n = cloud.points.size();
 
//i is index in original cloud
//j is index in virtual sparse cloud
//k is index in indices
for (int i = 0, j = 0, k = 0; (i < n) && (k < m); i++) {
  if (isFinite(cloud.points[i])) {
    while ((k < m) && (indices[k] == j)) indices[k++] = i;
      j++;
  }
}

Best,
Marty
 
Reply | Threaded
Open this post in threaded view
|

Re: Using AreaPickingEvent in pcl visualization

aichim
Administrator
Hi,

Interesting, definitely looks like a bug on our side. Could you please create an issue on github about it, pointing to this discussion?
Thanks!

Cheers,
Alex

On Sep 12, 2013, at 5:53 PM, martyvona <[hidden email]> wrote:

> We had a similar issue recently.
>
> What seemed to be happening in our case is that we were adding a point cloud
> to the visualizer that contained some NaN points, i.e. I think in the PCL
> terminology it was not a "dense" point cloud.
>
> The visualizer seems to remove such invalid points internally.  The indices
> that are reported for picks (I think this applies to both single point and
> area picks) refer to the point cloud after this mutation.
>
> We are working around the issue with code like this (this is a
> generalization of our actual code that I did not test):
>
> vector<int> &indices; //picked indices from visualizer
>
> sort(indices.begin(), indices.end());
>
> const int m = indices.size(), n = cloud.points.size();
>
> //i is index in original cloud
> //j is index in virtual sparse cloud
> //k is index in indices
> for (int i = 0, j = 0, k = 0; (i < n) && (k < m); i++) {
>  if (isFinite(cloud.points[i])) {
>    while ((k < m) && (indices[k] == j)) indices[k++] = i;
>      j++;
>  }
> }
>
> Best,
> Marty
>
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Using-AreaPickingEvent-in-pcl-visualization-tp4029635p4029639.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: Using AreaPickingEvent in pcl visualization

martyvona
done
Reply | Threaded
Open this post in threaded view
|

Re: Using AreaPickingEvent in pcl visualization

FELIPE IGNACIO INOSTROZA
Hi,

I was actually using a dense pointcloud but was making a basic c++ mistake.
For dense clouds the area selection works fine. Although sometimes the points in the axis drawing get selected instead of the points in the pointcloud. That was causing a segfault in my previous code.

Thanks forĀ  all the help


2013/9/12 martyvona <[hidden email]>
done



--
View this message in context: http://www.pcl-users.org/Using-AreaPickingEvent-in-pcl-visualization-tp4029635p4029643.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: Using AreaPickingEvent in pcl visualization

Christian Monterroso
In reply to this post by aichim
But how do I get access to cloud inside the callback function?

I have a class that contains my point clouds being displayed in PCLVisualizer.
The callback function has no way to access a specific instance of my class.