pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

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

pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

Silex
Hi all,

I was trying to draw a plane respect to my plane coefficients, which are obtained by my RANSAC plane fitting results.

There is two way to add a plane to the viewer, through pcl if I understand it correctly.
1. addPlane (const pcl::ModelCoefficients &coefficients, const std::string &id="plane", int viewport=0)
2. addPlane (const pcl::ModelCoefficients &coefficients, double x, double y, double z, const std::string &id="plane", int viewport=0)
Link to the documentation.

If I use the first one, then the plane is added to my viewer nicely filled within its boundaries, but I can't control its position.
However if I choose the second method, I can specify the position of the plane, but it gets drawn with only the boundaries.

Here is a picture for better understanding what I mean:


Am I misunderstanding something here?

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

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

Silex

Nobody had this issue?

On Jan 21, 2015 9:43 PM, "Silex" <[hidden email]> wrote:
Hi all,

I was trying to draw a plane respect to my plane coefficients, which are
obtained by my RANSAC plane fitting results.

There is two way to add a plane to the viewer, through pcl if I understand
it correctly.
1. addPlane (const pcl::ModelCoefficients &coefficients, const std::string
&id="plane", int viewport=0)
2. addPlane (const pcl::ModelCoefficients &coefficients, double x, double y,
double z, const std::string &id="plane", int viewport=0)
Link
<http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_p_c_l_visualizer.html#a7995ea4e636debb36f79050c70e09d58>
to the documentation.

If I use the first one, then the plane is added to my viewer nicely filled
within its boundaries, but I can't control its position.
However if I choose the second method, I can specify the position of the
plane, but it gets drawn with only the boundaries.

Here is a picture for better understanding what I mean:
<http://www.pcl-users.org/file/n4036992/plane_bug.png>

Am I misunderstanding something here?

Thanks in advance!




--
View this message in context: http://www.pcl-users.org/pcl-visualization-PCLVisualizer-addPlane-function-draws-only-boundary-of-the-plane-tp4036992.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: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

Silex
Sorry for writing here again, but don't want to make a new topic with the same issue, since it is against the rules.

Drawing out a plane at a specified position would greatly help my experiments instead of only drawing out the frame of the plane.
Reply | Threaded
Open this post in threaded view
|

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

Silex
I looked into the source code of pcl_visualizer.cpp and I found that in the following function:

bool pcl::visualization::PCLVisualizer::addPlane (const pcl::ModelCoefficients &coefficients, const std::string &id, int viewport)

the line:

actor->GetProperty ()->SetRepresentationToWireframe ();

is commented out and in the following function it is not:

bool pcl::visualization::PCLVisualizer::addPlane (const pcl::ModelCoefficients &coefficients, double x, double y, double z, const std::string &id, int viewport)

This is the reason why it draws a wire frame only, when I use the second function.

I don't know if this is only by accident or it is on purpose, but I thought I write it down if anybody would run into this.

Reply | Threaded
Open this post in threaded view
|

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

VictorLamoine
Administrator
This post was updated on .
Sorry for the lack of feedback.

Did you get addPlane working like you want?
From what I see in the API it is not possible to determine the boundaries of the plane, the parameters only take the plane equations. It's drawn at a "random" place in space.

If you want to be able to draw a plane at a specific place, with a specific size, you'll have to tweak the code in PCL (using VTK) that draws the plane.

Here's a VTK example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Plane
(in this example the size is not changed, you also have to check how to do that).
Study this example, learn how it works, then modify addPlane (or whatever it calls in PCL) accordingly.

It would be nice then to share your modifications on GitHub with a pull request.

As for the actor->GetProperty ()->SetRepresentationToWireframe (); it's not a problem but it should be uniform; I'll fix that in PCL trunk!
See https://github.com/PointCloudLibrary/pcl/pull/1132

Bye





EDIT:

It is possible to choose the plane center with the first function you pointed out! (http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_p_c_l_visualizer.html#a7995ea4e636debb36f79050c70e09d58)
But not the size of the plane.

In fact your problem boils down to call setRepresentationToSurfaceForAllActors after you added your shapes.
Pressing "S" in the visualizer should also work. (Press "H" for the help)
Reply | Threaded
Open this post in threaded view
|

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

Silex
Hi VictorL,

Thanks for your feedback. I understand if there is no time to help and answer all the questions in the mailing list. That's why I wrote that I found a "fix" for my problem.

It wasn't a problem, that I couldn't control the boundaries of the plane, since I just use it to see how good is my plane guess, but I wanted to translate it to a specific location and then it was just drawing the wire frame.
Since I built pcl from source I just commented out that line, which was responsible for this, so I can see the whole plane, then I built it again. Now it works perfectly.

My only modification was that line, which you mentioned. If I ever make a plane with boundary modification capabilities, then I will share it.

Regards,
David

2015-02-05 11:26 GMT-05:00 VictorL <[hidden email]>:
Sorry for the lack of feedback.

Did you get addPlane working like you want?
From what I see in the API it is not possible to determine the boundaries of
the plane, the parameters only take the plane equations. It's drawn at a
"random" place in space.

If you want to be able to draw a plane at a specific place, with a specific
size, you'll have to tweak the code in PCL (using VTK) that draws the plane.

Here's a VTK example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Plane
(in this example the size is not changed, you also have to check how to do
that).
Study this example, learn how it works, then modify addPlane (or whatever it
calls in PCL) accordingly.

It would be nice then to share your modifications on GitHub with a pull
request.

As for the actor->GetProperty ()->SetRepresentationToWireframe (); it's not
a problem but it should be uniform; I'll fix that in PCL trunk!

Bye




--
View this message in context: http://www.pcl-users.org/pcl-visualization-PCLVisualizer-addPlane-function-draws-only-boundary-of-the-plane-tp4036992p4037215.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: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

samer
Hello David and VictorL,

I am trying to draw the planes that fit clusters after RG segmentation but I could not although I tried several ways:

Firstly for addPlane case I wrote in my code the following:

   pcl::ModelCoefficients plane_coeff;
  plane_coeff.values.resize (4);  
  plane_coeff.values[0] = coefficients->values[0];
  plane_coeff.values[1] = coefficients->values[1];
  plane_coeff.values[2] = coefficients->values[2];
  plane_coeff.values[3] = coefficients->values[3];
  const std::string& id="";
  int viewport;
  pcl::visualization::PCLVisualizer::addPlane(plane_coeff, id="plane",0);

The error is :
error: passing ‘const string {aka const std::basic_string<char>}’ as ‘this’ argument of ‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>, std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>]’ discards qualifiers [-fpermissive]
:421:72: error: cannot call member function ‘bool pcl::visualization::PCLVisualizer::addPlane(const pcl::ModelCoefficients&, const string&, int)’ without object
make[2]: *** [CMakeFiles/dev_segmentation.dir/dev_segmentation.cpp.o] Error 1

Please tell me where is the problem?


Also I tried to use the function which you put it here: http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Plane
But when I call it during loop it draw every plane in different viewer-window but I need all of them in one window!

Generally:
My goal in general to draw planes on same viewer window over point cloud so How can I achieve that in C++ using PCL libraries , I mean like useing hold on in Matlab

Kind Regards,
Samer
Reply | Threaded
Open this post in threaded view
|

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

stefanbuettner
> Please tell me where is the problem?
That's a C++ problem and not really an PCL related issue. In you code
you're trying to assign a new value to a constant string ([...]
plane_coeff, id="plane, [...]). Try addPlane(plane_coeff, "plane");
> Generally:
> My goal in general to draw planes on same viewer window over point cloud so
> How can I achieve that in C++ using PCL libraries , I mean like useing hold
> on in Matlab

The above code should do the trick. If you need multiple planes, use
different IDs.

And concerning the topic title:
When you run the visualizer, press h for help, w for a wireframe
representation of meshes and s for a solid representation. You might
also look for setShapeRenderingProperties in case you want to change
that programatically.

Best,
Stefan

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

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

samer
Dear Stefan, Thanks for your answer.

The problem that I can not display planes in one viewer and even I can not draw plane over point cloud which fit it.

For more explanation : I have 3 groups of points and for each group I estimate plane which fit in loop and I want draw this plane on that points but when I run the code it open three windows and in each window the points are so far than the plane which should be fit.

This is the code inside my loop after I compute the plane coefficients:

  pcl::visualization::PCLVisualizer viewer2 ("PCL visualizer");
       pcl::ModelCoefficients plane_coeff;
         plane_coeff.values.resize (4);    // We need 4 values
         plane_coeff.values[0] = coefficients->values[0];
         plane_coeff.values[1] = coefficients->values[1];
         plane_coeff.values[2] = coefficients->values[2];
         plane_coeff.values[3] = coefficients->values[3];
         viewer2.addPlane(plane_coeff, "plane",0);
        viewer2.addPointCloud(cloud2);
        while (!viewer2.wasStopped ())
                         {
                           viewer2.spinOnce ();
                         }
                   k++;
          }

You can also look to the photos for more understanding to the issue.


Hope it is clear now and you can help.

Thanks a lot
best regards,
Samer
Reply | Threaded
Open this post in threaded view
|

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

stefanbuettner
Dear Samer,

so you have 3 planes and 3 point clouds and 1 viewer. What happens if
you just do sth like this:

PCLVisualizer viewer;
PointCloud<PointXYZ>::Ptr cloud1 = [...];
PointCloud<PointXYZ>::Ptr cloud2 = [...];
ModelCoefficients plane1;
ModelCoefficients plane2;
// Fill cloud1, cloud2, plane1 and plane2 with the appropriate information
viewer.addPlane(plane1, "p1");
viewer.addPlane(plane2, "p2");
viewer.addPointCloud(cloud1, "c1");
viewer.addPointCloud(cloud2, "c2");

Are you still using the VTK methods? Because I think there should be no
need.

Best,
Stefan

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

Re: pcl::visualization::PCLVisualizer::addPlane function draws only boundary of the plane

saad
In reply to this post by Silex
Hi guys,

1. Has anyone been able to set the size (length and breadth) of the plane
using the addPlane function or by any other means?
2. If not, then can somebody please give me some pointers on how I can
modify the addPlane function so I can set the size? Where do I need to make
the changes?

Regards,
Saad



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