Official implementation of paper "TP-LSD: Tri-points based line segment detector".
This demo uses TP-LSD to detect line segments in an image. The repo contains two core files: (1) PyTorch weight files and (2) The Network used in TP-LSD.
Full paper PDF: TP-LSD: Tri-Points Based Line Segment Detector
Presentation PDF: Poster at ECCV 2020
Authors: Siyu Huang, Fangbo Qin, Pengfei Xiong, Ning Ding, Yijia He, Xiao Liu
Here are the line detection and tracking results running on the ICL-NUIM dataset.
- DCNV2: See modeling/DCNv2/README.md
- lbdmod: See lbdmod/README.md
- pytorch ≥ 1.0
- opencv-python
This demo will run the TP-LSD network on an image sequence and extract line segments from the images.
The tracks are formed by the LineTracker
class which finds sequential pair-wise nearest neighbors using two-way matching of the lines' descriptors.
The demo script uses a helper class called VideoStreamer
which can process inputs from three different input streams:
- A directory of images, such as .png or .jpg
- A video file, such as .mp4 or .avi
- A USB Webcam
- Use
--method
to specify the method of line segments detection (default: lsd, option: lsd, edlines, tplsd). - Use
--model
to specify choose the model to use (default: tp320, option: tp320, tplite, tp512, hg). - Use
--skip
to skip the first few images if the input is movie or directory (default: 1). - Use
--img_glob
to change the image file extension (default: *.png). - Press the
q
key to quit.
python demo_line.py imgdir_path --method=tplsd
python demo_line.py xx.mp4 --method=tplsd
python demo_line.py camera --camid=1 --method=tplsd
Prepare a directory of consequent images, such as .png or .jpg
The basic configuration files for testing are saved in the config/test_config.py
.
The pretrained models for TP-LSD-Res34(320), TP-LSD-Res34(512), TP-LSD-Lite(320), TP-LSD-HG(512) can be downloaded from this link. Please place the weights into <TP_LSD_root>/pretraineds
.
-
For testing, please run the following commad, you could modify the model used and the path of test images in
config/test_config.yaml
. -
python test.py
LAP metrics is proposed based on line matching score (LMS), which measure the matching degree of line segments from a camera model perspective. See README.md in Metrics/LAP.
The pixel based metric is to compare the detected line segment with the ground truth in a pixel-wise manner. See README.md in Metrics/PixelBased.
sAP metrics uses the sum of squared error (LMS) between the predicted end-points and their ground truths as evaluation metric. See README.md in Metrics/SAP.