Skip to content

phygitalism/cgal-plane-detector

Repository files navigation

CGAL plane detection

master branch

Description

CGAL region growing algorithm for plane detection.

example

Requirements

  1. CGAL 5.0 or higher.
  2. Boost: math, filesystem, program options. Project was tested with Boost 1.71.
  3. CMake 3.20 or higher.
  4. Optional. VTK. It need only for visualization.
  5. Compiler with support C++14.
  6. Ninja (for Linux).
  7. Visual Studio 16 (for Windows).

How to run

Linux

See GitHub Action for compilation from source

cmake --preset linux-ninja
cmake --build ./build --config Release

Windows

See GitHub Action for compilation from source

Download CGAL (CGAL-*-library.zip) and GMP (GMP and MPFR libraries, for Windows 64bits) from release page

Unzip GMP and MPFR libraries. Set env variable GMP_DIR, MPFR_DIR to the <a path to GMP from archive>/auxiliary

Run CMake (PowerShell):

$env:GMP_DIR = "<a path to GMP from archive>/auxiliary"
$env:MPFR_DIR = "<a path to GMP from archive>/auxiliary"
cmake --preset windows-vc16 -DCGAL_DIR:PATH="<a path to CGAL directory from archive/lib/cmake/CGAL"
cmake --build ./build --config Release

Find executable (for Windows):

.\cgal-plane-detection.exe -i input_mes.obj -o segmented.ply -c

Results are three files:

  1. Segmented mesh segmented.ply.
  2. Bounding planes in the segmented-planes.ply as mesh.
  3. Coordinates of bounding planes in the segmented-planes.txt.

You can download example from Sketchfab.

See --help for additional parameters

Some parameters are described here

Argument -d allow to see results (if you compile with VTK).

Remarks

For best result you need axis aligned model.