| 1 |
################################################################### |
| 2 |
# # |
| 3 |
# PrimitiveShapes - software for extracting primitive shapes # |
| 4 |
# (planes, spheres, cylinders, cones, tori) # |
| 5 |
# from point-clouds via RANSAC # |
| 6 |
# Version 1.1 # |
| 7 |
# # |
| 8 |
# Ruwen Schnabel ([email protected]) # |
| 9 |
# Roland Wahl ([email protected]) # |
| 10 |
# 2006-2009 # |
| 11 |
# # |
| 12 |
################################################################### |
| 13 |
|
| 14 |
1. Introduction. |
| 15 |
|
| 16 |
Thank you for taking interest in our work and downloading this |
| 17 |
software. This library implements the algorithm described in the paper |
| 18 |
|
| 19 |
R. Schnabel, R. Wahl, R. Klein |
| 20 |
"Efficient RANSAC for Point-Cloud Shape Detection", |
| 21 |
in Computer Graphics Forum, Vol. 26, No. 2, pages 214-226, |
| 22 |
Blackwell Publishing, June 2007 |
| 23 |
|
| 24 |
If you use this software you should cite the aforementioned paper |
| 25 |
in any resulting publication. |
| 26 |
|
| 27 |
Please send questions, comments or bug reports to |
| 28 |
Ruwen Schnabel ([email protected]) |
| 29 |
|
| 30 |
The library has been tested using Visual Studio 2005 but it should |
| 31 |
work with gcc under Linux as well |
| 32 |
|
| 33 |
################################################################## |
| 34 |
|
| 35 |
2. License & disclaimer. |
| 36 |
|
| 37 |
Copyright 2009 Ruwen Schnabel ([email protected]), |
| 38 |
Roland Wahl ([email protected]). |
| 39 |
|
| 40 |
This software may be used for research purposes only. |
| 41 |
|
| 42 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 43 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 44 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 45 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 46 |
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 47 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 48 |
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 49 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 50 |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 51 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 52 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 53 |
|
| 54 |
################################################################## |
| 55 |
|
| 56 |
3. Example usage. |
| 57 |
|
| 58 |
This section shows how to use the library to detect the shapes in a point-cloud |
| 59 |
|
| 60 |
//////////////////////////////////////////////////////////////////////// |
| 61 |
#include <RansacShapeDetector.h> |
| 62 |
#include <PlanePrimitiveShapeConstructor.h> |
| 63 |
#include <CylinderPrimitiveShapeConstructor.h> |
| 64 |
#include <SpherePrimitiveShapeConstructor.h> |
| 65 |
#include <ConePrimitiveShapeConstructor.h> |
| 66 |
#include <TorusPrimitiveShapeConstructor.h> |
| 67 |
|
| 68 |
PointCloud pc; |
| 69 |
|
| 70 |
// fill or load point cloud from file |
| 71 |
// ... |
| 72 |
// don't forget to set the bbox in pc |
| 73 |
|
| 74 |
RansacShapeDetector::Options ransacOptions; |
| 75 |
ransacOptions.m_epsilon = .01f * pc.getScale(); // set distance threshold to .01f of bounding box width |
| 76 |
// NOTE: Internally the distance threshold is taken as 3 * ransacOptions.m_epsilon!!! |
| 77 |
ransacOptions.m_bitmapEpsilon = .02f * pc.getScale(); // set bitmap resolution to .02f of bounding box width |
| 78 |
// NOTE: This threshold is NOT multiplied internally! |
| 79 |
ransacOptions.m_normalThresh = .9f; // this is the cos of the maximal normal deviation |
| 80 |
ransacOptions.m_minSupport = 500; // this is the minimal numer of points required for a primitive |
| 81 |
ransacOptoins.m_probability = .001f; // this is the "probability" with which a primitive is overlooked |
| 82 |
|
| 83 |
RansacShapeDetector detector(ransacOptions); // the detector object |
| 84 |
|
| 85 |
// set which primitives are to be detected by adding the respective constructors |
| 86 |
detector.Add(new PlanePrimitiveShapeConstructor()); |
| 87 |
detector.Add(new SpherePrimitiveShapeConstructor()); |
| 88 |
detector.Add(new CylinderPrimitiveShapeConstructor()); |
| 89 |
detector.Add(new ConePrimitiveShapeConstructor()); |
| 90 |
detector.Add(new TorusPrimitiveShapeConstructor()); |
| 91 |
|
| 92 |
MiscLib::Vector< std::pair< MiscLib::RefCountPtr< PrimitiveShape >, size_t > > shapes; // stores the detected shapes |
| 93 |
size_t remaining = detector.Detect(pc, 0, pc.size(), &shapes); // run detection |
| 94 |
// returns number of unassigned points |
| 95 |
// the array shapes is filled with pointers to the detected shapes |
| 96 |
// the second element per shapes gives the number of points assigned to that primitive (the support) |
| 97 |
// the points belonging to the first shape (shapes[0]) have been sorted to the end of pc, |
| 98 |
// i.e. into the range [ pc.size() - shapes[0].second, pc.size() ) |
| 99 |
// the points of shape i are found in the range |
| 100 |
// [ pc.size() - \sum_{j=0..i} shapes[j].second, pc.size() - \sum_{j=0..i-1} shapes[j].second ) |