This repository contains code and examples for using Polylidar3D on the KITTI dataset to extract ground planes from point clouds. The example presented is for ground/obstacle detection with representation as polygons. In this example the LiDAR is treated as an unorganized point cloud input to Polylidar3D. To learn more about Polylidar3D and its use cases for concave polygons extraction see it's repository.
The main components of the code are as follows:
- Using
pykitti
to get camera and Velodyne LiDAR data. - Apply appropriate transformations of the pont cloud between vehicle body frame, Velodyne Frame, and Camera frame. This allows projecting the point cloud and polygons into the camera frame.
- Use
Polylidar3D
to extract flat ground level surfaces and obstacles on said surfaces as polygons. - Perform polygon filtering, buffering (expansion/contraction), and simplification. This is done using Shapely/GEOS.
- 2D Viewer - Project polygons onto camera image for display and verification.
- 3D Viewer - Display 3D point clouds and polygons.
Please see disclaimers below before using Polylidar3D.
Download the data from here. I personally have only tested all drives that took place on 09/26/2011. These are quite large pieces of data.
After everything is extracted this is the format that I am expecting it to be in:
(base) ➜ data git:(polylidar3d) ✗ tree data -d
.
data
├── 2011_09_26
│ ├── 2011_09_26_drive_0001_sync
│ │ ├── image_00
│ │ │ └── data
│ │ ├── image_01
│ │ │ └── data
│ │ ├── image_02
│ │ │ └── data
│ │ ├── image_03
│ │ │ └── data
│ │ ├── oxts
│ │ │ └── data
│ │ └── velodyne_points
│ │ └── data
│ ├── 2011_09_26_drive_0002_sync
│ │ ├── image_00
│ │ │ └── data
│ │ ├── image_01
│ │ │ └── data
│ │ ├── image_02
│ │ │ └── data
│ │ ├── image_03
│ │ │ └── data
│ │ ├── oxts
│ │ │ └── data
│ │ └── velodyne_points
│ │ └── data
.
.
.
Please begin with first installing a python virtual environment.
- Install conda - Why?
conda create --name polylidar3d python=3.6 && source activate polylidar3d
- Create new virtual python environment
There is one main dependencies which must be installed. Please git clone
this repository in a separate directory in your workspace. You will need CMake to build this repository. Please note the installation section in the repo about building and installing python
bindings. Please be sure that you have activated your newly created virtual environment when building this repository (polylidar3d
).
Once that is all done just install any dependencies needed in this repo.
conda install -c conda-forge opencv shapely
- These packages give the most issue for binary dependencies for Windows users, hence why conda should handle them.pip install -e .
- Install any dependencies for this repository (polylidar-kitti
).
A command line application should be installed after the pip install
. Run as so:
$ kittiground run --help
Usage: kittiground run [OPTIONS] [INPUT]
Run ground detector on KITTI Dataset.
input is a file path to a yaml configuration file,
Default=config/default.yaml
Options:
--help Show this message and exit.
$ kittiground run
The default.yaml
contains all settings to run examples. Comments should be on every parameter.
The videos of all drives can be found here. Please download the videos. Google Drive is for some reason caching old videos during playback in the browser.
Polylidar3D (for unorganized point cloud inputs) extracts all "flat" surfaces in the normal direction provided which must be aligned with the XY plane. The surfaces are represented as polygons. However nothing is truly flat and sensor measurements are noisy. Parameters guide polylidar in how "flat" a surface is. However these same parameters that allow some noise and non-flatness also allow false-positives (e.g. the road connects into an elevated sidewalk). This code uses a lot of filtering outside of Polylidar3D to help reduce these false positives and make simpler polygons.
A small amount of (naive) pointcloud outlier filtering is performed before the point cloud is sent to Polylidar3D. For speed up please install Cython
-> pip install Cython
.