Line Segment Detection Using Transformers Without Edges

Yifan Xu, Weijian Xu, David Cheung, Zhuowen Tu

Abstract

In this paper, we present a joint end-to-end line segment detection algorithm using Transformers that is post-processing and heuristics-guided intermediate processing (edge/junction/region detection) free. Our method, named LinE segment TRansformers (LETR), takes advantages of having integrated tokenized queries, a self-attention mechanism, and encoding-decoding strategy within Transformers by skipping standard heuristic designs for the edge element detection and perceptual grouping processes. We equip Transformers with a multi-scale encoder/decoder strategy to perform fine-grained line segment detection under a direct endpoint distance loss. This loss term is particularly suitable for detecting geometric structures such as line segments that are not conveniently represented by the standard bounding box representations. The Transformers learn to gradually refine line segments through layers of self-attention. In our experiments, we show state-of-the-art results on Wireframe and YorkUrban benchmarks.

Introduction

Line segment detection (LSD) is a fundamental task for 3D reconstruction and scene understanding. Historically, this has been a multi-stage, heuristic-heavy process. Traditional methods rely on complex pipelines: first detecting edge pixels, then identifying intersections (junctions), and finally using hand-crafted grouping rules to form lines. These stages are often fragile, difficult to tune, and cannot be optimized end-to-end.

Comparison between traditional multi-stage pipelines (a) and the streamlined LETR architecture (b).

While deep learning has improved LSD, many recent models still rely on intermediate representations like "attraction field maps." Furthermore, standard object detection tools like Faster R-CNN struggle with lines because lines are thin and often diagonal; axis-aligned bounding boxes are a poor fit for long, skinny segments, leading to ambiguity during training.

The LETR Architecture

The authors introduce LETR, which adapts the DETR (DEtection TRansformer) architecture specifically for geometric structures. By treating line segments as "entities" and leveraging a multi-scale Transformer architecture, LETR achieves state-of-the-art results without explicitly detecting edges or junctions.

Multi-Scale Coarse-to-Fine Strategy

To handle both long structural lines and tiny details, LETR employs a two-stage approach. A "Coarse" decoder analyzes low-resolution features (from a ResNet backbone's C5 layer) to establish the global layout. This is followed by a "Fine" decoder that refines these initial predictions using higher-resolution features (C4 layer).

The multi-scale coarse-to-fine Transformer architecture of LETR.

Key Components

  1. Transformer Backbone: A standard CNN (ResNet) extracts image features, which are fed into a Transformer encoder to capture global context.
  2. Line Entities as Queries: Instead of pixel-wise detection, the model learns a set of "line entities" (queries). These queries interact with image features through the Transformer decoder to "probe" for line segments.
  3. Direct Endpoint Loss: Since bounding boxes are ineffective for lines, LETR uses a simple L1 distance loss between predicted endpoints and ground truth. A "Bipartite Matching" strategy (Hungarian algorithm) uniquely assigns predicted lines to ground truth during training.

Key Insights

  • Lines as Objects: Line detection is reframed from a bottom-up pixel-grouping problem to a top-down "set prediction" problem.
  • Attention Resolves Ambiguity: Self-attention allows "line entities" to consider the entire image, helping the model "see" through occlusions or cluttered backgrounds where local edge information is noisy.
  • Heuristic-Free Design: By removing junction detection and post-processing (like Non-Maximum Suppression), the model is simpler and more robust across diverse scene types.

Experimental Results

LETR achieved state-of-the-art (SOTA) performance on the ShanghaiTech Wireframe and YorkUrban benchmarks.

  • Accuracy: On the YorkUrban dataset, it outperformed previous leaders (like HAWP) across nearly all metrics, including a 1.5-point lead in heatmap-based $AP^H$.
  • Qualitative Performance: Visual results demonstrate that LETR is particularly effective at identifying long, clean structural lines defining room or building geometry, even when partially obscured by furniture or shadows.
  • Efficiency: The model runs at approximately 5.04 FPS on a Tesla V100. While slower than some heuristic methods (e.g., LSD at 49 FPS), it remains competitive with other high-performing deep learning models.

Limitations and Future Work

Despite its success, LETR shows slightly lower precision at low recall compared to some competitors, likely due to "over-confident" false positives in complex areas. The Transformer architecture is also computationally intensive; future iterations might utilize more efficient variants like Deformable DETR. Additionally, the model's performance is significantly boosted by pre-training on the COCO dataset, suggesting that general object recognition knowledge facilitates geometric learning.

Summary updated

BibTeX
@inproceedings{xu2021line,
  author = {Yifan Xu and Weijian Xu and David Cheung and Zhuowen Tu},
  title = {{Line Segment Detection Using Transformers Without Edges}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  url = {https://openreview.net/forum?id=l2iCVOkd0RL},
}
Figure