Einführung Einführung in Die Algorithmische Algorithmische Geometrie Geometrie Und Geometrische Modellierung Und Geometrische Modellierung
Total Page:16
File Type:pdf, Size:1020Kb
Einführung in die Algorithmische Geometrie und Geometrische Modellierung Scan Processing parts from Bastian Steder, Univ Freiburg Radu B. Rusu, Willow Garage Project Dr.-Ing. Christoph Fünfzig What are Point Clouds Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 2 What are Point Clouds Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 3 Scanning Techniques Passive Active Laser Scanning Techniques, http://home.arcor.de/laserscanner/ Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 4 Scan Technology LIDAR SLR Time-of-flight Phase interference/shift Triangulation (passive) Triangulation (active) Structured Light (active) Measurement Error/ Object Size Conoscopy Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 5 Scan Processing ICP Zippering, Ball Pivoting, Poisson Recon Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 6 Iterative Closest Point (ICP) input: points from two raw scans, initial estimate of transform. output: refined transform T(abg,xyz). While (squared distance d too large) { Compute nearest neighbor n(p) for each point p. Estimate rotation (3 dof) and translation (3 dof) using a mean square 2 cost function: d=minT(abg,xyz) Si (Tn(pi) – pi) Store transformation T(abg,xyz). } Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 7 Model Fitting Model Fitting Model Fitting: Find model (e.g., line) to noisy set of points. Linear Least Squares (use all points for fitting) Hough Transform (histogramming) RANSAC (randomized, max consensus set) Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 8 Random Sample Consensus Model Fitting (RANSAC) input: data: a set of observations n: the minimum number of data required to fit the model k: the number of iterations performed by the algorithm t: a threshold value for determining when a datum fits a model d: the number of close data values required to assert that a model fits well to data output: best_model: model parameters which best fit the data best_consensus_set: data points from which this model has been estimated best_error: the error of this model relative to the data iterations := 0; best_model := null; best_consensus_set := null; best_error := infinity; while iterations < k do maybe_inliers := n randomly selected values from data; maybe_model := model fitted to maybe_inliers; consensus_set := maybe_inliers; for every point in data not in maybe_inliers if point fits maybe_model with an error smaller than t then add point to consensus_set ; if the number of elements in consensus_set is > d then this_model := model parameters fitted to all points in consensus_set; this_error := a measure of how well this_model fits these points; if this_error < best_error then store this_model; Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 9 Point Cloud Library (PCL) http://www.ros.org/wiki/pcl Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 21 Data representation As previously presented: a point is represented as a tuple, e.g., a Point Cloud is represented as a collection of points : Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 22 Data representation In terms of data structures: an XYZ point can be represented as: float x float y float z a n-dimensional point can be represented as float[] point, which is nothing else but a std::vector<float> point Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 23 Data representation In terms of data structures: a point cloud is: Point[] points or: std::vector<Point> points in C++, where Point is the structure/data type representing a single point Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 24 PointCloud vs. PointCloud2 We distinguish between two data formats for the point clouds: PointCloud<PointType> with a specific data type (for actual usage in the code) PointCloud2 as a general representation containing a header defining the point cloud structure (for loading, saving or sending as a ROS message) Conversion between the two is easy: pcl::fromROSMsg and pcl::toROSMsg Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 25 PointCloud structure PointCloud class (templated over the point type): template <typename PointT> class PointCloud; Important members: std::vector<PointT> points; // the data uint32_t width, height; // scan structure Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 26 Point types Examples of PointT [pcl/include/pcl/point_types.h]: struct PointXYZ { float x; float y; float z; } or struct Normal { float normal[3]; float curvature; } Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 27 Range image class A range image is derived from PointCloud<PointWithRange> can be created from a normal point cloud given a viewpoint more convenient to work with: neighborhood accessible methods from vision usable encodes negative information is easy to visualize (have a look at pcl_visualization -> range_image_visualizer) Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 28 What is PCL? PCL is a fully templated modern C++ library for 3D point cloud processing uses SSE optimizations (Eigen backend) for fast computations on modern CPUs uses OpenMP and Intel TBB for parallelization passes data between modules (e.g., algorithms) using Boost shared pointers will be made independent from ROS in one of the next releases Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 29 Algorithms in PCL downsampling, outlier removal, indices extraction, normals and curvatures, boundary points, moment projections invariants, principal curvatures, Point Feature Histograms Iterative Closest Point (ICP), non linear optimizations cluster extraction, polygonal prism extraction meshing, convex hulls, Moving Least Squares Input/Output Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 30 PCL structure PCL is a collection of smaller, modular C++ libraries: libpcl_features: many 3D features (e.g., normals and curvatures, boundary points, moment invariants, principal curvatures, Point Feature Histograms (PFH), Fast PFH, ...) libpcl_surface: surface reconstruction techniques (e.g., meshing, convex hulls, Moving Least Squares, ...) libpcl_filters: point cloud data filters (e.g., downsampling, outlier removal, indices extraction, projections, ...) libpcl_io: I/O operations (e.g., writing to/reading from PCD (Point Cloud Data) and BAG files) libpcl_segmentation: segmentation operations (e.g.,cluster extraction, Sample Consensus model fitting, polygonal prism extraction, ...) libpcl_registration: point cloud registration methods (e.g., Iterative Closest Point (ICP), non linear optimizations, ...) libpcl_range_image: range image class with specialized methods It provides unit tests, examples, tutorials, … Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 31 Point Cloud file format Point clouds can be stored to disk as files, into the PCD format: # Point Cloud Data ( PCD ) file format v .5 FIELDS x y z rgba SIZE 4 4 4 4 TYPE F F F U WIDTH 307200 HEIGHT 1 POINTS 307200 DATA binary ... DATA can be either ascii or binary. If ascii, then DATA ascii 0.0054216 0.11349 0.040749 … Usage: pcl::io::loadPCDFile and pcl::io::savePCDFile Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 32 Architecture Inheritance simplifies development and testing: pcl::Feature<PointT> feat; feat = pcl::Normal<PointT> (input); feat = pcl::FPFH<PointT> (input); feat = pcl::BoundaryPoint<PointT> (input); ... feat.compute (&output); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 33 Basic Interface Filters, Features, Segmentation all use the same basic interface: create the object use setInputCloud to give the input set some parameters call compute to get the output Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 34 Filter example 1 pcl::PassThrough<T> p; // clamp to interval p.setInputCloud (data); p.FilterLimits (0.0, 0.5); p.SetFilterFieldName ("z"); filter_field_name = "x"; | filter_field_name = "xz"; Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 35 Filter example 2 pcl::VoxelGrid<T> p; p.setInputCloud (data); p.FilterLimits (0.0, 0.5); p.SetFilterFieldName ("z"); p.setLeafSize (0.01, 0.01, 0.01); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 36 Filter example 3 pcl::StatisticalOutlierRemoval<T> p; p.setInputCloud (data); m as as p.setMeanK (50); p.setStddevMulThresh (1.0); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 37 Features example 1 pcl::NormalEstimation<T> p; p.setInputCloud (data); p.SetRadiusSearch (0.01); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 38 Features example 2 pcl::BoundaryEstimation<T,N> p; p.setInputCloud (data); p.setInputNormals (normals); p.SetRadiusSearch (0.01); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 39 Segmentation example 1 pcl::SACSegmentation<T> p; p.setInputCloud (data); p.setModelType (pcl::SACMODEL_PLANE); p.setMethodType (pcl::SAC_RANSAC); p.setDistanceThreshold (0.01); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 41 Segmentation example 2 pcl::EuclideanClusterExtraction<T> p; p.setInputCloud (data); p.setClusterTolerance (0.05); p.setMinClusterSize (1); Geometrische Modellierung & Algorithmische Geometrie, WS 2013/2014 42 Segmentation example 3 pcl::SegmentDifferences<T> p; p.setInputCloud (source); p.setTargetCloud (target); p.setDistanceThreshold (0.001); Geometrische