Open mnobrecastro opened 2 years ago
Thank you! This is really interesting. Regarding your research project (out of interest): since you have 4 scans in 45 degree turns, why did you decide to segment 3d ellipses instead of a cylinder? My intuition would be that working with a cylinder directly might be more stable?
I noticed some '#include' changes
Yes, we are deprecating and removing pcl/sample_consensus/eigen.h
and similar headers. The files that used them should include the headers from Eigen directly. So including the NonLinearOptimization
header looks like the right solution here.
pcl::SACMODEL_ELLIPSE2D. Please let me know if this is something of your interest. I can spend some more time trying to finish them
Ultimately, you will have to decide whether you want to spend the time of course :slightly_smiling_face: I would say, let's first work on the 3D ellipse, then decide how we want to continue.
I will have a look at your PR soon!
Dear @mvieth, thank you very much for your quick reply!
We have done that already - feel free to have a look at it, it's OA (https://www.frontiersin.org/articles/10.3389/fnbot.2022.814973/full). The challenge here was precisely to use less data and have similar performance. So those rendered 3D cylinders you see at the bottom of the figure, were estimated solely based on a simple algorithm which uses those 4 scans, namely the models of four fitted Ellipse3D or two Ellipse3D + one Circle3D + one Line.
Regarding the Ellipse2D, of course I would not mind working on it! But has you suggested, let's take it one step at a time.
Best regards, Miguel
Dear @mvieth, thank you for accepting and merging my PR. I will update you with another PR regarding the 2D version, asap.
Dear @mvieth, thank you for accepting and merging my PR. I will update you with another PR regarding the 2D version, asap.
I thought a bit about whether to add a 2D version or not. So on the one hand, it would be nice to have such a model of course, but on the other hand, it would mean more code to maintain and adding a bit of compilation time. Additionally, we can't estimate yet whether such a 2D ellipse would be used (especially since the 3D ellipse has just been merged). Can you say whether the 3D ellipse model can also be used in the 2D case (when all points are in one plane)? Would there be drawbacks to this? (accuracy, speed) Which parts of the 3D ellipse model would have to be adapted and how difficult would this be?
Dear @mvieth, thank you for accepting and merging my PR. I will update you with another PR regarding the 2D version, asap.
I thought a bit about whether to add a 2D version or not. So on the one hand, it would be nice to have such a model of course, but on the other hand, it would mean more code to maintain and adding a bit of compilation time. Additionally, we can't estimate yet whether such a 2D ellipse would be used (especially since the 3D ellipse has just been merged). Can you say whether the 3D ellipse model can also be used in the 2D case (when all points are in one plane)? Would there be drawbacks to this? (accuracy, speed) Which parts of the 3D ellipse model would have to be adapted and how difficult would this be?
You made a good point. A 2D ellipse fitting can be accomplished using the existing 3D ellipse (in the end it would be just a matter of adding a z=0 coordinate to the 2D points, thus converting it to a 3D problem). There won't be much overhead in terms of computation beyond the simple calculation of the plane normal. If you recall, the 3D ellipse fitting procedure works at the level of local coordinates of the points w.r.t. to the plane that was found. So, the 3D problem is actually solved as a 2D problem once the points are converted to local coordinates (and only x_local and y_local coordinates are used).
In sum, adapting the 3D ellipse model to its 2D counterpart will be very simple and straight forward, but if you have concerns about the compilation time, that is something to take in consideration (especially after changing all Eigen
functions to const
).
Feature description
Good afternoon everyone!
Here is a proposal for an Ellipse3D sac_model for the
sample_consensus
module that I wrote more than a year ago for a paper (soon to be submitted).The proposed model is inspired on the
pcl::SACMODEL_CIRCLE3D
model that is available, which scripts were used as template. The idea behind thepcl::SACMODEL_ELLIPSE3D
is to generalize the former, allowingPCL
users to fit ellipses to 3D data. The model could be used, for example, to fit the elliptical data of a laser scanner "cutting" obliquely through a cylindrical object - more details below.Context
The research project where this code was developed aimed at simulating multiple laser scans from an Intel Realsense camera, to minimize the amount of data points required to reconstruct objects that can be approximated by know 3D geometric primitives such as cylinders, spheres or cuboids. This was applied to a robotic hand prosthesis for amputees such that it helped automate the control of the prosthesis and ease the "work" done by the user. In the case of cylindrical objects, as it is illustrated in the figure below, an oblique laser scan "cut" through an upright cylindrical object (e.g., a can) produces elliptical contours. To that end, having a 3D ellipse model enables to run RANSAC fitting of those data points.
The steps required for computing an ellipse from the data points are described in mnobrecastro/pcl-ellipse-fitting (still needs an update soon!), which are based on a research paper . The authors propose a method that solves a generalized eigenvalue problem of the type Av=λBv that allows to retrieve the conic parameters of an ellipse. To solve that system, the
GeneralizedEigenSolver
of theEigen
is used, and some conflicts betweenEigen
andPCL
were resolved before (issue #4734, PR #4742). At each RANSAC iteration, six data points are used to solve this system of equations.There maybe certainly more efficient ways to solve this ellipse fitting problem, but I am sure that this
pcl::SACMODEL_ELLIPSE3D
model will help the community to have something to work on! I appreciate your understanding. A PR #5430 has been sent.Solution usage and behavior
pcl::SACMODEL_ELLIPSE3D
is used to determine 3D ellipses in a plane. The ellipse's eleven coefficients are given by its center, semi-minor/major axis lengths along its local u- and v-axis (two radii), normal and global coordinates of its local u-axis as: [center.x, center.y, center.z, semi_minor_major.u, semi_minor_major.v, normal.x, normal.y, normal.z, u.x, u.y, u.z]. 'sample_consensus/include/pcl/sample_consensus/model_types.h'.It's usage follow the same kind of segmentation object declaration as in
pcl::SACMODEL_CIRCLE3D
where thesetRadiusLimits(rmin, rmax)
method constrains simultaneously both semi-minor/major axes length (radii) of the ellipse:A unit-test was added to 'pcl/test/sample_consensus/test_sample_consensus_quadric_models.cpp' as proposed below.
Environment:
Additional info
As I was pulling today the up-to-date remote, before merging my code, I noticed that something has changed since the last
PCL 1.11.1
version. The following error appeared:Upon inspection of the newer 'pcl/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle3d.hpp' file
PCL 1.12.1
, I noticed some '#include' changes as presented below and changed my 'sac_model_ellipse3d.hpp'. Even though the code built smoothly and passed the tests, I would appreciate if someone double checks these changes.Further developments
Before merging my comments, I removed the files corresponding to the unfinished 2D version of this,
pcl::SACMODEL_ELLIPSE2D
. Please let me know if this is something of your interest. I can spend some more time trying to finish them. Lastly, I have not managed to find time to render the these 3D ellipses usingVTK
, but for anyone interested, this can be achieved using an EllipticalCylinder with minimal height.That's all from me, please let me know if this issue needs further improvement. Thank you for your time!