segmentation???

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

segmentation???

liquidmonkey
just curious if there is a way to define at what range along a given axis that you want RANSAC to search for the best plane?
ie, perform ransac perpendicular to the z-axis but within the range of -5 to 5 on the z-axis

i could use a pcl pass through filter but just curious.


i see that setAxis can be used to set the search area perpendicular to a axis.

and is there any difference between setAxis and SACMODEL_PERPENDICULAR_PLANE? if i understand correctly, they both do the same thing, ie, saying find a plane that is perpendicular to this axis, or?


thanks!


Reply | Threaded
Open this post in threaded view
|

Re: segmentation???

Radu B. Rusu
Administrator

On 03/21/2012 05:17 AM, liquidmonkey wrote:
> just curious if there is a way to define at what range along a given axis
> that you want RANSAC to search for the best plane?
> ie, perform ransac perpendicular to the z-axis but within the range of -5 to
> 5 on the z-axis
>
> i could use a pcl pass through filter but just curious.

I'm not sure if that level of detail is possible. I believe the models just accept an axis and an epsilon/threshold for
the angle.

> i see that setAxis can be used to set the search area perpendicular to a
> axis.
>
> and is there any difference between setAxis and
> SACMODEL_PERPENDICULAR_PLANE? if i understand correctly, they both do the
> same thing, ie, saying find a plane that is perpendicular to this axis, or?

Which models are you referring to? I didn't fully understand your question.

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

Re: segmentation???

liquidmonkey
i'll try and explain with my code...

pcl::SACSegmentation<pcl::PointXYZ> seg;
seg.setModelType (pcl::SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setMaxIterations (1000);
seg.setDistanceThreshold (0.05);          // 5cm 0.05
seg.setAxis(Eigen::Vector3f (0, 0, 1));   // best plane should be perpendicular to z-axis
seg.setEpsAngle (0.01);                   // 0.5 degrees
   

what i'm seeing with the above is that ransac is NOT choosing a plane that is perpendicular to the z-plane (giving me a x-y plane) as the plane is sometimes tilted (much more than 0.5 degrees which also means that my setEpsAngle is not working either).

so must i use SACMODEL_PERPENDICULAR_PLANE in order to use setAxis and/or setEpsAngle?
Reply | Threaded
Open this post in threaded view
|

Re: segmentation???

saurabh
Hey,

Sorry for bringing up an old thread... I am also stuck with the same thing.. I am trying to segment just the ground plane but neither "SACMODEL_PERPENDICULAR_PLANE" or using setAxis seem to work.

Here's a snippet from my code
 
  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
  pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
  pcl::SACSegmentation<pcl::PointXYZRGB> seg;
  seg.setOptimizeCoefficients (true);
  seg.setModelType (pcl::SACMODEL_PLANE);
  const Eigen::Vector3f z(0,0,1);
  seg.setAxis(z);
  seg.setEpsAngle(0.1);
  seg.setMethodType (pcl::SAC_RANSAC);
  seg.setDistanceThreshold (0.01);

I am using PCL-1.5 bound with ROS Fuerte with a kinect mounted on a turtlebot.
Thanks
Saurabh
Reply | Threaded
Open this post in threaded view
|

Re: segmentation???

Sergey
Administrator
Hi Saurabh,

Please note that if you want to define a plane by its normal, you have to use

seg.setModelType(pcl::SACMODEL_PERPENDICULAR_PLANE);

Also note that EpsAngle is in radians.

Finally, the normal for a horizontal plane won't necessarily be (0,0,1), because it is relative to your sensor (Kinect), not the world. In fact, I would suggest that you work this out in the opposite direction. First detect the plane that you want without imposing any restrictions, look at the resultant normal, and hard-code it in your algorithm.

Cheers,
Sergey

Reply | Threaded
Open this post in threaded view
|

Re: segmentation???

saurabh
Hi Sergey,

taketwo wrote
Hi Saurabh,

Please note that if you want to define a plane by its normal, you have to use

seg.setModelType(pcl::SACMODEL_PERPENDICULAR_PLANE);

Also note that EpsAngle is in radians.

Finally, the normal for a horizontal plane won't necessarily be (0,0,1), because it is relative to your sensor (Kinect), not the world. In fact, I would suggest that you work this out in the opposite direction. First detect the plane that you want without imposing any restrictions, look at the resultant normal, and hard-code it in your algorithm.
Voila that worked... I should have figured out what the model coefficients mean earlier..
Cheers,
Sergey
Thanks for the reply
Saurabh