简体   繁体   中英

Line detection in 2D point cloud

I am developing a larger system for navigation and positioning of automated guided vehicles and have stumbled upon a problem. When developing a map, the important part is finding the walls. The navigation is done using a LiDAR unit.

An example "image" of that the sensor sees is as follows: 在此处输入图片说明

And the wanted output is something like this: 在此处输入图片说明

I have looked alot at the Hough transform and the RANSAC algorithm but the Hough transform as from what I know is used on images which is not optimal for my case and the RANSAC is not great for finding multiple walls in sparse data.

The data that was used in this specific example can be found in this link: https://drive.google.com/file/d/1EnSOr2FYjIdqG1RdFgTkgsoEhVcG7Tl_/view?usp=sharing Where the two arrays in the file represent x and y coordinates where elemets correspond by index.

Im developing in python but I have no issue to write the algorithm myself if anyone knows a suitable one that is not available in a package or so.

Thanks in advance, Jakob

Probably a bit late for the original question, but I'm sure more people will want to solve the same problem.

Hough transform can very well be done on a point cloud, however I'm not aware of a ready to use library implementation.

Here is an excellent example with full explanation and source code: Processing LIDAR data using a Hough Transform

If you understand how Hough transform works and take a look at the code, you'll see how it iterates through the points and creates a 2-d histogram in the feature space. It's farly straightforward to implement something like this.

You could try mathematical morphology such as erosion/ dilatation https://docs.opencv.org/trunk/d9/d61/tutorial_py_morphological_ops.html

I tried on your image and it starts looking to a room :

源图像 侵蚀/扩张的图像 阈值

Here is an example of implementation in python using opencv:

import numpy as np
import scipy.stats
import cv2

inputImage = cv2.imread('input.jpg')

skernel = cv2.getStructuringElement(cv2.MORPH_RECT,(3,3))
cv2.imshow("test1",inputImage)

openImg =cv2.morphologyEx(inputImage, cv2.MORPH_OPEN, skernel, iterations =15)
cv2.imshow("test2",openImg)
img_gray = cv2.cvtColor(openImg, cv2.COLOR_BGR2GRAY)
ret,th3 = cv2.threshold(img_gray,200,255,cv2.THRESH_BINARY)

cv2.imshow("test3",th3)

Also I think that there is a missing keyword in your question since what you are looking for is a point cloud reconstruction algorithm. you may have a look here also https://hal.inria.fr/hal-01348404v2/document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM