Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem in SACMODEL_NORMAL_PARALLEL_PLANE #918

Closed
ClaireXie opened this issue Sep 19, 2014 · 9 comments · Fixed by #3301
Closed

problem in SACMODEL_NORMAL_PARALLEL_PLANE #918

ClaireXie opened this issue Sep 19, 2014 · 9 comments · Fixed by #3301

Comments

@ClaireXie
Copy link

I tried to detect two perpendicular planes in which the normal of the first plane is parallel to the second plane. So I set the normal of the first plane as the axis in SACMODEL_NORMAL_PARALLEL_PLANE and use SACSegmentationFromNormals. However, after it, I find the two detected planes are almost parallel to each other, instead of perpendicular. When I dig into the code, in sample_consensus/impl/sac_model_normal_parallel_plane.hpp, in function isModelValid(), you are checking

if (fabs (axis_.dot (coeff)) < cos_angle_)
      return  (false);

which, I feel strange.
I thought it should be (consistent with 'sac_model_parallel_plane'):

if (fabs (axis.dot (coeff)) > sin_angle_)
      return  (false);
@VictorLamoine
Copy link
Contributor

I tried to detect two perpendicular planes in which the normal of the first plane is parallel to the second plane

If the two planes are perpendicular; they can't be parralel. The inverse is also true.

I find the two detected planes are almost parallel to each other, instead of perpendicular

This seems pretty normal when you use a SACMODEL_PARALLEL_PLANE

Two planes cannot be both parallel and perpendicular.

@ClaireXie
Copy link
Author

I tried to detect two perpendicular planes in which the normal of the first plane is parallel to the second plane

If the two planes are perpendicular; they can't be parralel. The inverse is also true.

SACMODEL_NORMAL_PARALLEL_PLANE should constrain the plane parallel to a specified AXIS. If one plane is parallel to the other plane's normal, it means that these two planes are perpendicular. So that's why I use SACMODEL_NORMAL_PARALLEL_PLANE to detect two perpendicular planes.

@VictorLamoine
Copy link
Contributor

If one plane is parallel to the other plane's normal, it means that these two planes are perpendicular

Or in a simpler way; the dot product between the 2 planes normals is null.
Why don't you use SACMODEL_PERPENDICULAR_PLANE ?

@ClaireXie
Copy link
Author

Or in a simpler way; the dot product between the 2 planes normals is null.
Why don't you use SACMODEL_PERPENDICULAR_PLANE ?

Sorry for the confusion. I am trying to fit two perpendicular planes. In other words, I am trying to estimate the two planes' coefficients.

@VictorLamoine
Copy link
Contributor

This is the point of SACMODEL_PERPENDICULAR_PLANE.

seg.setModelType (pcl::SACMODEL_PERPENDICULAR_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setMaxIterations(1000);
seg.setDistanceThreshold (0.05);
seg.setAxis(Eigen::Vector3f(0,0,1));
seg.setEpsAngle (0);

In setAxis, put the normal of your first plane. (the first 3 coefficients in the plane coefficients).

@ClaireXie
Copy link
Author

In setAxis, put the normal of your first plane. (the first 3 coefficients in the plane coefficients).

I did that exactly as you mentioned above. But the problem that I found in the PCL implemntation has been stated in my first post. (as the a result, the fitted two planes are parallel instead of being perpendicular.)

@VictorLamoine
Copy link
Contributor

I took a look at whats going on here; first I don't get why there is both

SACMODEL_PERPENDICULAR_PLANE
SACMODEL_NORMAL_PARALLEL_PLANE

I might be wrong but to me being parallel to the normal of a plane is strictly equivalent to being perpendicular to a plane.

Second thing that bugs me: in the isModelValid function there are two possibilities:
if (eps_angle_ > 0.0)
Then the dot product will be computed to check wether we fit the axis or nor (with sin_angle_ as a threshold)

If eps_angle_ < 0.0 then the model returned is always valid, it is not checked whether is fits the axis or not ?! (This means that if you don't specify an eps_angle_ the model will always be valid whatever the plane is)

Have you had any success with SACMODEL_PARALLEL_PLANE ? I can't get it working properly

@VictorLamoine
Copy link
Contributor

Calling setAxis () alone is not enough, the axis is ignored until the user sets the epsilon angle:
A first fix would be to add setEpsAngle (std::min) when calling setAxis (), this would enable the axis check to the lowest possible tolerance.

Now here is a question: When you are looking for a parallel plane giving the axis, do you want:

  • The normal of the first plane to be parallel with the axis
  • The axis to fit into the plane (in that case the plane and the axis are parallel)

I don't know the answer to that question.
http://www.pcl-users.org/Ransac-Planes-tp2085912p2086759.html

@mvieth
Copy link
Member

mvieth commented Aug 21, 2019

This thread is rather old so maybe no one is interested any more, but for what it is worth:
SACMODEL_NORMAL_PARALLEL_PLANE is like SACMODEL_PERPENDICULAR_PLANE, but the points are only counted as inliers if they are close to the plane and their normals are close to the normal of the estimated plane. See also SACMODEL_NORMAL_PLANE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants