Skip to content

xchwang1998/tree_semantic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EN CN

🌳 A online tree_semantic module for LiDAR SLAM

πŸ’‘ Introduction

This is an additional moudle for LiDAR SLAM, employed for individual tree segmentation and tree atrributie calculation (Position, DBH, and Stem Curve), named TreeSemantic.

Two modes included in this repository.

  • The first is processing LiDAR single frame faster than 10 Hz. This mode segmented points to indivadul trees, and get their position and bounding-box.

  • The second is processing the key frame from any SLAM system, and calculating servel tree traits (Position, DBH, and Stem curve). After that, the usful products, such as DEM, marteloscopes, and tree traits table, are outputed to file. This mode is running at 1 Hz. I have tested with servel popular SLAM systems, including LIO-SAM, Fast-LIO2, Faster-LIO, and Point-LIO.

πŸš€Demo

Indvidual Tree Segmentation (Single Frame, >10 Hz)

The mission on single frame mode is indvidual tree segmentation. As shown in the video (click followin figure), different trees are segmented and uniqully colored in real-time. The ground points are colored by brown. The total informations, i.e., total number of trees, area of each scan, are displayed on top-left. The bounding-box is simultaneously shown with extracted tree. Additionally, ID and height with coarse precision are also shown along with the bounding-box.

Demo Video

Tree Segmentation and Attributes Calculation (Key Frame, 1 Hz)

The mission on key frames mode includes the tree segmentation, attribute extraction (DBH and stem curve), and products generation (DEM, Marteloscopes).

As shown in the video (click followin figure), top is terminals to launch TreeSemantic, Fast-LIO2, and play ROS bag data. Left shows online results of TreeSemantic processing, right shows the results of Fast-LIO2. In left, different trees have unique colors and the ground points are colored in brown. The white cube represents bounding-box, the black circle represents DBH, white points discribe the stem curve. Additionally, total information, such as tree's number, scaning area, are displayed in the top left. The DBH, height, and tree position are displayed along with bounding-box.

Demo Video

πŸ“‚ Output Products

Ground

The ground points are filtered in the real-time. After this module ends, the ground points are saved to file and employed to generate Digital Elevation Models (DEMs). It is usful for slope, aspect, and visibility analysis.

alt ground points in city scene Ground points

alt DEM in city scene DEM

Tree

Tree points also saved to a file and segmented into individual instants. Here is the example of extracted ground and individual trees. The ground points are colored in yellow, tree points are colored randomly.

Alt Extracted tree points

The stem curve points are also calculated. In this study, multiple profiles along with the stem are selected and then fitted as a circle. The center points of circle are regarded the stem curve.

Alt Tree points with stem curve

Marteloscopes

As show cases, and use for field visits, a figure of representing tree's characteristic in forest stand are intantly generated after program ends, named Marteloscopes. alt Marteloscopes in city scene

Tree Characteristics

All tree characteristics descripted above, such tree positions, DBH, stem curve, are saved into a CSV file.

alt Tree attributes

Hence, whole procedure of forest inventory is performed at real time, the raw data and production are obtained at the same time.


πŸ‘‰πŸ‘‰πŸ‘‰ : If you are interested to tested them with our module, here is a manual for quick start.

πŸ“¦ Prerequisites

The code have been tested on Ubuntu 18.04. The third-party library are listed as follows:

PCL >=1.8.1

Eigen >=3.3.4

OpenCV >=3.3.1

CSF (Cloth Simulation Filter)

Patchworkpp

small_gicp

Boost >=1.7.5 # Needed by CGAL library

CGAL 5.6

Install PCL Library

If you use ubuntu 18.04, You can install pcl using a simple way.

sudo apt update
sudo apt-get install libpcl-dev

Or you can compile through the source code: https://github.com/PointCloudLibrary/pcl

Install the Eigen Library

Similarly, you can install the eigen library through apt way.

sudo apt update
sudo apt-get install libeigen3-dev

Or you can just download and extract Eigen's source code: https://eigen.tuxfamily.org/index.php?title=Main_Page

Install OpenCV 3.3.1

You can install the OpenCV library through apt way.

sudo apt update
sudo apt install libopencv-dev python3-opencv
# check opencv version 
pkg-config --modversion opencv

Install CSF (Cloth Simulation Filter)

CSF (Cloth Simulation Filter) is an algorithm for LiDAR ground filtering. It usually employed to the Airborne Lidar data, but also shown good performance on the Terrastrial-, Mobile-, and even Spaceborne- Lidar. In this program, CSF is ultilized to re-fine the ground points in the final phase.

You can follow the instruction of CSF.

mkdir build #or other name
cd build
cmake ..
make
sudo make install

Related papers: W. Zhang, J. Qi*, P. Wan, H. Wang, D. Xie, X. Wang, and G. Yan, β€œAn Easy-to-Use Airborne LiDAR Data Filtering Method Based on Cloth Simulation,” Remote Sens., vol. 8, no. 6, p. 501, 2016.

Install Patchwork++

Patchwork++, an extension of Patchwork, is a fast, robust, and self-adaptive ground segmentation algorithm on 3D point cloud.

In this program, Patchwork++ is ultilized to identify the ground points in real-time. Although its precision is low, its high efficiency is needed for us. The influence of False Negtative (FN) and False Positive (FP) ground points can be ingnored in this project.

You can install Patchwork++ through following commands.

# download patchwork++
git clone https://github.com/url-kaist/patchwork-plusplus.git
# in patchwork-plusplus directory
cd cpp && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j 16
# install to your system
sudo make instal

Or you can refer this Link: https://github.com/url-kaist/patchwork-plusplus/tree/master/cpp The Python version and ROS Node based on ROS1 and ROS2 also can be tested, as decripted in link: https://github.com/url-kaist/patchwork-plusplus.

Install small_gicp

small_gicp is a header-only C++ library providing efficient and parallelized algorithms for fine point cloud registration (ICP, Point-to-Plane ICP, GICP, VGICP, etc.). The C++ version of small_gicp can be installed by following commands.

sudo apt-get install libeigen3-dev libomp-dev

cd small_gicp
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && make -j
sudo make install

In this program, small_gicp is employed to re-fined the key-frame pose calculated from SLAM algorithm.

Install Teaser++ (Optional)

Teaser++ also is a fast and certifiable 3D registration algorithm and can be used to re-fine the key-frame pose. However, Teaser++ is often employed to transform the point cloud at object-level, and not adopted in this project. If you are interested to Teaser++, you can install this alogrithm through following commands:

sudo apt install cmake libeigen3-dev libboost-all-dev
git clone https://github.com/MIT-SPARK/TEASER-plusplus.git
cd TEASER-plusplus && mkdir build && cd build
cmake .. && make
sudo make install

The reference link is https://github.com/MIT-SPARK/TEASER-plusplus.

Install and Use Boost 1.75

Boost is a foundamental library for various applications. Unfortunatly, different projects commonly need different boost versions. In this program, the CGAL 5.6 need Boost β‰₯1.75.

# download
wget https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz
tar -xzf boost_1_75_0.tar.gz
cd boost_1_75_0

# install depend modules
sudo apt update
sudo apt install build-essential g++ python3-dev libicu-dev libbz2-dev zlib1g-dev

# define local path
./bootstrap.sh --prefix=/usr/local/boost_1_75

# install boost 1.75
sudo ./b2 --prefix=/usr/local/boost_1_75 install

# verify boost
ls /usr/local/boost_1_75
# it should output "include  lib"

# check the version of boost
cat /usr/local/boost_1_75/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
# it should output //  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_75"

After that, the Boost 1.75 has been installed to /usr/local/boost_1_75. Then, Boost's path need to be pre-defined in our CMakeLists.txt, such as the BOOST_ROOT, BOOST_INCLUDEDIR, and BOOST_LIBRARYDIR.

set(BOOST_ROOT "/usr/local/boost_1_75")
set(BOOST_INCLUDEDIR "${BOOST_ROOT}/include")
set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib")
find_package(Boost 1.75.0 REQUIRED)

Install CGAL Library

CGAL is an open source software project that provides easy access to efficient and reliable geometric algorithms in the form of a C++ library. It can be installed through following commands. You can use these commoands, if your operation system is later than Ubuntu 20.04.

sudo apt update
sudo apt-get install libcgal-dev

But, CGAL 4.11 is corresponding to Ubuntu 18.04 system, which is too old for this program. You can install CGAL 5.6 through source code. Download the release version, then compile and install to the "/usr/local/include".

cd CGAL-5.6
mkdir build && cd build
cmake ..
make install

https://doc.cgal.org/5.6.2/Manual/usage.html#section_headeronly

Notic: The Boost library in ubuntu 18.04 is 1.65.1 version, but CGAL 5.6 need Boost later thanγ€€1.75. So, you should install another Boost in different location. It shoud be mentionded that you shouldn't remove the original version. Another programs still need Boost 1.65.1.

Similarly to our program, the local path of boost package should set in CMakeLists.txt.

set(BOOST_ROOT "/usr/local/boost_1_75")
set(Boost_INCLUDE_DIR "${BOOST_ROOT}/include")
set(Boost_LIBRARY_DIR "${BOOST_ROOT}/lib")
# set local path before find Boost package
find_package(Boost REQUIRED)

βš™οΈ Build TreeSemantic

Clone the repository and catkin_make:

cd ~ && mkdir TreeSemantic_ws && cd TreeSemantic_ws
mkdir src && cd src
git clone https://github.com/xchwang1998/tree_semantic.git
cd ..
catkin_make
source devel/setup.bash

πŸƒ Launch TreeSemantic

TreeSemantic has two modes, the single-frame segmentation and the key-frame process, include segmentation, attribute calculation, and outputing products.

For Single-Frame

If you only want run the single-frame processing module, you can launch the run_single_frame.launch file.

roslaunch tree_semantic_pkg run_single_frame.launch

For Key-Frames

Otherwise, if you want run whole process to extract the tree attributes in real-time and output the produtions instantlly. You can launch run.launch file.

roslaunch tree_semantic_pkg run.launch

Then, you also need launch a SLAM algorithm to publish key_frame_info. Such as the popular SLAM algorithms:

# lio-sam
roslaunch lio_sam run.launch
# fast-lio 2
roslaunch fast_lio mapping_ouster128.launch
# faster-lio
roslaunch faster_lio mapping_ouster128.launch
# point-lio
roslaunch point_lio mapping_ouster128.launch

The structure of key_frame_info is shown as follow:

# Cloud Info
Header header 

# cloud messages
sensor_msgs/PointCloud2 key_frame_cloud_ori
sensor_msgs/PointCloud2 key_frame_cloud_transed
sensor_msgs/PointCloud2 key_frame_poses

key_frame_cloud_ori is the original point cloud, key_frame_cloud_transed is the point cloud transed into world coordinate of SLAM, key_frame_poses is all poses of key frames.

Above popular SLAM algorithms should be revised to publish key_frame_info message. Here are four revised repositories for you.

LIO-SAM: https://github.com/xchwang1998/LIO-SAM-Forest-Inventory

Fast-LIO2: https://github.com/xchwang1998/FastLIO_Forest_Inventory

Faster-LIO: https://github.com/xchwang1998/Faster_LIO_Forest_Inventory

Point-LIO: https://github.com/xchwang1998/PointLIO_Forest_Inventory

If you are interested to the detail of revise part, you can refer this CSDN blog.

Notice: Since TreeSemantic module and SLAM algorithm may confilict in sometimes, the computation source can be distributed before launch them. The launch commands are subsquentlly revised as:

# launch LIO-SAM, use core 0,1,2,3
taskset -c 0-3 roslaunch lio_sam run.launch
# launch TreeSemantic, use core 4,5,6,7
taskset -c 4-7 roslaunch tree_semantic_pkg run.launch

πŸ’½ Datasets

  1. We used the hand-held personal laser scanning device to obtain data from Wuhan University, China.

  2. We test TreeSemantic on the public dataset, TreeScope.

πŸ… Evoluation

To evoluate the results of extracted tree attributes, such as DBH, height, and stem curve, an open-source software is employed. This software is developed by MSpace-WHU, named ParameterEvaluation. You can visit this project for more detail.

πŸ› Some Issues

There are some issues should be noted.

The OusterPointXYZIRT data format is designed for Ouster point cloud. ring attribute format is uint8_t in order version of Ouster_ROS driver, and are revised to uint16_t in new version, such as TreeScope. Hence, we should use correct format for different rosbag file.

// use
uint16_t ring;
// or use
uint8_t ring;

πŸ“ Citation

If you use this repository, please cite our paper.

If you use ParameterEvaluation software, please cite this DOI: https://zenodo.org/records/15245849

πŸ“« Contact Information

If you have any questions, please do not hesitate to contact me: xchwang@whu.edu.cn

🚩 Todo List

  • Support more SLAM algorithms
  • Support more tree attributes calculation
  • Expand vertical FoV of laser scanning, to obtain the canopy information of forest
  • Combined with deep learning algorithm to recongnize tree attributes in real-time

About

find the stem clusters from forest

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published