This code implements the algorithm described in (cited as "IPOL paper" below):
C. Dalitz, T. Schramke, M. Jeltsch: "Iterative Hough Transform for Line Detection in 3D Point Clouds." IPOL, 2017 http://www.ipol.im/pub/art/2017/208/
hough3dlines.cpp Main program that implements Algotirhm 1 (Iterative Hough Transform) of the IPOL paper
hough.[h|cpp] Class implementing Algorithm 2 (Hough Transform) of the IPOL paper
sphere.[h|cpp] Class implementating the direction discretization as described in section 2.2 of the IPOL paper
vector3d.[h|cpp] Class for a 3D point with common math operations
pointcloud.[h|cpp] Class for a set of 3D points
The source code is written in C++ and thus requires a C++ compiler. Moreover, it needs the external library libeigen 3.x, available from http://eigen.tuxfamily.org/.
For compilation with the provided Makefile, three adaptions to your environment might be necessary:
- set CC to your C++ compiler
- set LIBEIGEN to the path to your libeigen headers
- define WEBDEMO for the online-demo version
The last option is only meant for the IPOL online demo and is not recommended for production use because it will stop the program when the Hough space becomes too large or when the input point cloud has more than 10^6 points.
To compile the program, simply type "make". To test it on the test data, type "make test".
hough3dlines without any or with an unknown option (e.g. "-?") will print the following usage message:
Usage: hough3dlines [options] Options (defaults in brackets): -o write results to [stdout] -dx step width in x'y'-plane [0] when =0, it is set to 1/64 of total width -nlines maximum number of lines returned [0] when =0, all lines are returned -minvotes only lines with at least points are returned [0] -gnuplot print result as a gnuplot command -raw print plot data in easily machine-parsable format -v be verbose and print Hough space size to stdout -vv be even more verbose and print Hough lines (before LSQ)
The input format is described in section 5 of the IPOL paper. The input file must contain the point coordinates, one point per line with x,y, and z separated by commas. Lines starting with a hash (#) are ignored. Example:
41.7201,138.2140,-648.0000 0.0001,-138.2140,-440.0000 2.4543,-136.8650,-436.8000
The output is printed to stdout unless it is redirected to a file with the option "-o". The standard output format is described in section 5 of the IPOL paper. It lists the detected lines one per line with the number of points and the parameters a and b, as in the following example:
npoints=58, a=(2.5682,-123.8986,0.3456), b=(0.0000,0.7071,0.7071) npoints=32, a=(-2.4576,34.8665,0.0000), b=(0.7071,0.0000,0.7071) npoints=3, a=(7.0056,-12.7867,8.5634), b=(0.5773,0.5773,0.5773)
There are two other optional output formats that can be useful for visualization of teh result:
-
The option "-gnuplot" can be used to immediately visualize the result by piping the program output to gnuplot, as in the following example:
hough3dlines testdata.dat -dx 0.4 -gnuplot | gnuplot -persist
-
The option "-raw" prints the plot data in an easily machine-readable format as space separated values that can be used to automatically construct a plotting comand. The numbers have the following meaning:
minX maxX minY maxY minZ maxZ paramMin paramMax aX aY aZ bX bY bZ npoints
where the first line specifies the point cloud bounding box, the second line the range of t values in the line parametrization a + t*b, and the following lines list the line parameters with one line per line.
Christoph Dalitz, Tilman Schramke, Manuel Jeltsch, 2017 Institute for Pattern Recognition Niederrehin University of Applied Sciences Krefeld, Germany
This code is provided under a BSD-style license. See the file LICENSE-BSD2 for details.