Processing math: 0%

Autonomous Driving/2. LiDAR Perception

Ch01. LiDAR Data Processing - 3) Open3d, CloudeCompare, LiDAR 레이블링 툴

Dogun Kim 2024. 9. 5. 19:38

Ch01.  LiDAR Data Processing

 

<목차>

0. Introduction: 컴퓨터 비전 vs 3차원 비전

1-1. LiDAR 센서의 종류 및 데이터 취득 방식

1-2. 포인트 클라우드의 특징

 

1-3. 테스트를 위한 ROS 환경구성

1-4. 자율주행 실습을 위한 오픈라이다 데이터셋소개

 

1-5. 포인트 클라우드 처리 방법 구현을 위한 Open3D사용법

1-6. 포인트 클라우드 시각화 및 편집툴CloudCompare 사용법

1-7. LiDAR 데이터 학습을 위한 레이블링 툴 소개

 


1-5. 포인트클라우드처리방법구현을위한Open3D사용법

 

https://www.open3d.org/docs/0.17.0/tutorial/geometry/pointcloud.html

 

Point cloud — Open3D 0.17.0 documentation

This tutorial demonstrates basic usage of a point cloud. Paint point cloud print"Paint chair" chair.paint_uniform_color[1, 0.706, 0] o3d.visualization.draw_geometries([chair], zoom=0.7, front=[0.5439, -0.2333, -0.8060], lookat=[2.4615, 2.1331, 1.338],

www.open3d.org

위 예시를 보면서 공부를 해보겠다..

 

우선 open3d를 사용하기 위해 자신의 환경에 맞는 open3d를 우분투 환경에 설치하자.

 

파이썬을 활용해서  open3d의 간단한 실습을 진행할 것이다. 먼저 그래픽 개체를 저장하는 3d 파일 형식인 ply 파일을 불러오고, 이를 시각화 하며, voxel 단위로 downsampling을 진행한 후 마지막으로 normal vector를 추출해보겠다.

import open3d as o3d
import numpy as np

# open3d 모듈에서 기본적으로 제공하는 ply 가져오기
print("Load a ply point cloud, print it, and render it")
ply_point_cloud = o3d.data.PLYPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.path)

print(pcd)
print(np.asarray(pcd.points))

# 1) 시각화
o3d.visualization.draw_geometries([pcd],
                                  zoom=0.3412,
                                  front=[0.4257, -0.2125, -0.8795],
                                  lookat=[2.6172, 2.0475, 1.532],
                                  up=[-0.0694, -0.9768, 0.2024])


# 2) downsampling
print("downsamling")
downcd = pcd.voxel_down_sample(voxel_size = 0.05)
o3d.visualization.draw_geometries([downcd],
                                  zoom=0.3412,
                                  front=[0.4257, -0.2125, -0.8795],
                                  lookat=[2.6172, 2.0475, 1.532],
                                  up=[-0.0694, -0.9768, 0.2024])

# 3) 법선 벡터(normal vectors) 뽑아내기
print("Recompute the normal of the downsampled point cloud")
downcd.estimate_normals(
    search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.1, max_nn=30))
o3d.visualization.draw_geometries([downcd],
                                  zoom=0.3412,
                                  front=[0.4257, -0.2125, -0.8795],
                                  lookat=[2.6172, 2.0475, 1.532],
                                  up=[-0.0694, -0.9768, 0.2024],
                                  point_show_normal=True)

 

PLYpointCloud 함수를 통해 open3d에서 기본적으로 제공하는 데이터를 불러왔다.

open3d에서 ply 파일을 불러올 때는 o3d.io.read_point_cloudply 파일 경로 함수를 사용하게 된다.

 

numpy를 통해 불러온 데이터의 좌표들을 확인하기 위해 numpy를 활용했다. 좌표를 행렬을 통해 표현할 것이다.

 

1) 시각화 o3d.visualization.draw_geometries

가져온 3d 객체를 시각화 해보겠다.

이를 위해 다음과 같은 함수를 사용한다.

o3d.visualization.draw_geometries(
	[불러올 객체], [불러올 객체], [불러올 객체] ...,
    zoom=0.3412,
    front=[0.4257, -0.2125, -0.8795],
    lookat=[2.6172, 2.0475, 1.532],
    up=[-0.0694, -0.9768, 0.2024])

3d 객체를 불러와 시각화 하였다.

2) downsampling 객체.vexel_down_samplevoxel_size = xx

엄청나게 무거운 point cloud를 가져오면 연산에 너무 시간이 오래 걸릴 수 있다. 적당한 타협의 down sampling를 통해 계산 속도를 높혀 성능을 좋게 만들 수 있다.

downcd = pcd.voxel_down_sample(voxel_size = 0.05)

# 다시 한 번 시각화
o3d.visualization.draw_geometries(
	[downcd],
    ... )

 

3) 법선 벡터 추정하기 객체.estimate_normal..

downcd.estimate_normals(
    search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.1, max_nn=30))

o3d.visualization.draw_geometries([downcd],
                                  zoom=0.3412,
                                  front=[0.4257, -0.2125, -0.8795],
                                  lookat=[2.6172, 2.0475, 1.532],
                                  up=[-0.0694, -0.9768, 0.2024],
                                  point_show_normal=True # 법선 벡터를 보이도록 설정해야한다.
                                  )

 

사실 위 코드에서 esimate_normal 함수를 주석처리하고 법선 벡터를 시각화해도 법선 벡터가 잘 출력된다.

위 함수는 normal 정보가 없을 때 사용하는 함수이다.

만약 객체가 법선 벡터을 갖고 있는지 확인하기 위해서는 다음과 같은 코드를 사용하면 된다. 

if downpcd.has_normal():
	print("True")
    
else:
	print("False")

 


 

1-6. 포인트클라우드시각화및편집툴CloudCompare사용법

 

https://www.danielgm.net/cc/

 

CloudCompare - Open Source project

 

www.danielgm.net

Point cloud의 뷰어의 목적이지만, 변환 segmetation 등.. 다양한 편집 기능을 제공하기에 확장성이 높은 툴이다.

  • 여러 포맷의 포인트 클라우드 및 메쉬 파일을 시각화 가능
  • 포인트 클라우드의 crop, transformation 등의 조작이 가능
  • 두 포인트 클라우드 간 fine registration 기능 제공
  • Annotation 목적의 segment labeling 활용 가능

저장된 위 예시 ply 파일을 시각화 해보겠다.

그냥 끌어다가 바로 넣어주면 된다. 

오..

Edit > segment 기능 등을 사용.. ply를 편집해서 다시 저장할 수 있다.


 

1-7. LiDAR 데이터 학습을 위한 레이블링 툴 소개

 

object detection 등.. 작업을 하기 위해 레이블링이 필요하다. 이를 위한 레이블링 툴을 알아보자.

Semantic segmentation editor

https://github.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor

 

GitHub - Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor: Web labeling tool for bitmap images and point clouds

Web labeling tool for bitmap images and point clouds - Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor

github.com

 

  • 3D point cloud segmentation annotation
  • 2D bitmap segmentation annotation

Point cloud annotation tool

https://github.com/springzfx/point-cloud-annotation-tool

 

GitHub - springzfx/point-cloud-annotation-tool

Contribute to springzfx/point-cloud-annotation-tool development by creating an account on GitHub.

github.com

 

  • 3D bounding box annotation tool

RViz Cloud annotation tool

https://github.com/RMonica/rviz_cloud_annotation

 

GitHub - RMonica/rviz_cloud_annotation: Point cloud annotation tool based on RViz

Point cloud annotation tool based on RViz. Contribute to RMonica/rviz_cloud_annotation development by creating an account on GitHub.

github.com

 

  • ROS-based multi-label point cloud annotation

LabelCloud

https://github.com/ch-sa/labelCloud

labelCloud

 

labelCloud

Introduction to labelCloud labelCloud is a lightweight tool for labeling 3D bounding boxes in point clouds. It is written in Python and can be installed via pip see Setup. Labeling labelCloud supports two different ways of labeling picking & spanning a

ch-sa.github.io

 

PointAtMe

https://github.com/florianwirth/PointAtMe

 

GitHub - florianwirth/PointAtMe: An annotation tool to annotate 3D data in 3D

An annotation tool to annotate 3D data in 3D. Contribute to florianwirth/PointAtMe development by creating an account on GitHub.

github.com

 

  • 3D point cloud annotation using VR

L-CAS 3D point cloud annotation tool

https://github.com/yzrobot/cloud_annotation_tool

 

GitHub - yzrobot/cloud_annotation_tool: L-CAS 3D Point Cloud Annotation Tool

L-CAS 3D Point Cloud Annotation Tool. Contribute to yzrobot/cloud_annotation_tool development by creating an account on GitHub.

github.com

 

  • Semi-auto point cloud annotation

3D BAT - 3D bounding box annotation tool

https://github.com/walzimmer/3d-bat

 

GitHub - walzimmer/3d-bat: 3D Bounding Box Annotation Tool 3D-BAT Point cloud and Image Labeling

3D Bounding Box Annotation Tool 3D-BAT Point cloud and Image Labeling - walzimmer/3d-bat

github.com

 

  • 3D point cloud annotation
  • 2D image pseudo 3D annotation