This repository contains code and examples for integrating Polylidar3D with an Intel RealSense camera. The example presented is for flat surface/obstacle detection with representation as polygons. To learn more about Polylidar3D and its use cases for concave polygons extraction see it's repository.
Using RealSense D435i
Using RealSense L515 (New!)
The main components of the code are as follows:
- Using
pyrealsense2
to interface with the a D4XX sensor. - Apply filtering to generated depth images (spatial,temporal, etc.).
- Use Polylidar3D to extract Polygons.
- Perform polygon filtering and buffering.
- Project polygons onto image for display and verification
Please see disclaimers below before using Polylidar3D
with an Intel RealSense camera for your application.
Please begin with first installing a python virtual environment.
- Install conda - Why?
conda create --name realsense python=3.6 && source activate realsense
- Create new virtual python environment
There are three main dependencies which must be installed. Please git clone
each of these repositories in separate directories in your workspace. You will need CMake to build each of these repositories. Please note each repo's installation section about building and installing python
bindings. Please be sure that you have activated your newly created virtual environment when building these repositories (realsense
).
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 (surfacedetector
).
The demo code is in capture.py
and be called as so python -m surfacedetector.capture
. All parameters used to configure the module can be found in surfacedetector/config/default.yaml
. You can specify alternate configuration profiles as a command line parameter.
(ppb) ➜ polylidar-realsense git:(polylidar3d) ✗ python -m surfacedetector.capture --help
usage: capture.py [-h] [-c CONFIG] [-v VIDEO]
Captures ground plane and obstacles as polygons
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
Configuration file
-v VIDEO, --video VIDEO
Video file save path
You can download two (2) bag files that were recorded inside my residence with a D435i. Playback can be enabled through the default.yaml
file. The first bag file is of my basement, while the second bag file is of my main floor. Please note that the lighting is controlled in these environments leading to less noise for an Intel RealSense Camera. When these camera's are used outside....lets just say the depth maps are "very poor". This in turn leads to degraded results for Polylidar3D as well. LiDAR always works better : ) .
Here are the bag files (each one is about 1 GB!): basement bag file, main floor bag file
Here are the generated videos in their entirety: basement video, main floor video
Here is an issue that discussed some ways to help improve polygon extraciton: Issue
The Intel D435 is very noisy with dense point clouds. The only way to make it usable for Polylidar3D
(as it is currently implemented) is to use heavy filtering, including temporal filtering. Also the points are downsampled in order to:
- Increase runtime speed. Less points = faster polylidar performance.
- Create more gaps between points which increases triangle average size. The true planarity (normal) of a triangle is more apparent the larger the triangle is in relation to sensor noise.
Imagine a ground triangle with 1cm edge lengths with a height noise of 1 cm. The noise dominates the triangle and makes the normal of the triangle not planar. Now image 5 cm edge lengths with same 1cm height noise. The noise makes less of a difference and it appears to be more flat.
Uses solid state lidar technology.
- Does not work in sunlight!
- Very precise (low noise) and accurate in indoor areas with no sunlight.
- Does not work well on matte black items.
- Brand new sensor with a few bugs and issues.
- Does not work well on angled surfaces. In other words it works best on flat surface directly in front of it.