Paper deep dive
MiLSD: A Micro Line-Segment Detector for Resource-Constrained Devices
Parsa Hassani Shariat Panahi, Amir Hossein Jalilvand, M. Hassan Najafi
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 94%
Last extracted: 7/9/2026, 3:48:12 AM
Summary
This paper introduces MiLSD, a micro line-segment detector optimized for resource-constrained microcontroller devices. It systematically evaluates three output representations, quantization strategies (8-bit vs 4-bit), and inference enhancements to achieve high accuracy within a 1 MB activation memory budget. The proposed F-Clip representation combined with 8-bit quantization and post-processing techniques improves sAP10 on the ShanghaiTech Wireframe dataset from 10.6 to 24.1, demonstrating that meaningful wireframe detection is feasible on MCU-scale hardware without GPU dependencies.
Entities (8)
Relation Signals (6)
MiLSD → evaluatedon → ShanghaiTech Wireframe
confidence 97% · improves sAP10 on ShanghaiTech Wireframe from 10.6 to 24.1
MiLSD → achievesmetric → sAP10
confidence 96% · MiLSD improves sAP10 on ShanghaiTech Wireframe from 10.6 to 24.1
MiLSD → uses → F-Clip
confidence 95% · proposed F-Clip center-with-length-and-angle formulation
MiLSD → deployedon → STM32F746
confidence 94% · STM32F746 provides only 320 KB of SRAM and 1 MB of flash... On such devices, the bottleneck is peak activation memory
MiLSD → usestechnique → Quantization-aware training
confidence 93% · quantization-aware training recovering only part of the loss
F-Clip → outperforms → Heatmap
confidence 92% · F-Clip center-with-length-and-angle formulation learns most effectively at small model sizes
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Line segment detection is a key building block in visual SLAM, 3D reconstruction, and industrial inspection. Recent deep learning methods have greatly improved accuracy, yet even the smallest models require several megabytes of memory, exceeding low-cost MCU capacity. This work investigates the maximum achievable accuracy under a sub-megabyte budget. We propose MiLSD, a detector tailored for MCU-level constraints, and systematically compare three output representations within a compact fully-convolutional backbone. Our study shows that the proposed F-Clip center-with-length-and-angle formulation learns most effectively at small model sizes. We find that 8-bit quantization preserves full-precision performance, while 4-bit quantization causes significant degradation, particularly in angle regression, with quantization-aware training recovering only part of the loss. With a one-megabyte activation budget and inference enhancements including sub-pixel decoding, test-time augmentation, and a lightweight verifier, MiLSD improves sAP10 on ShanghaiTech Wireframe from 10.6 (25k parameters, 0.25 MB) to 24.1 within 1 MB. Rather than competing with GPU-scale parsers, we map the accuracy memory trade-off across representations, bit-widths, capacities, and post-processing strategies for embedded vision systems.
Tags
Links
- Source: https://arxiv.org/abs/2607.06600v1
- Canonical: https://arxiv.org/abs/2607.06600v1
Trouble viewing inline? Open PDF directly →
Full Text
49,914 characters extracted from source content.
Expand or collapse full text
MiLSD: A Micro Line-Segment Detector for Resource-Constrained Devices Parsa Hassani Shariat Panahiπ , Amir Hossein Jalilvandπ , and M. Hassan Najafi+ πSchool of Computer Engineering, Iran University of Science and Technology, Tehran, Iran +Electrical, Computer, and Systems Engineering Department, Case Western Reserve University, OH, USA Abstract Line segment detection is a key building block in visual SLAM, 3D reconstruction, and industrial inspection. Recent deep learning methods have greatly improved accuracy, yet even the smallest models require several megabytes of memory, exceeding low-cost MCU capacity. This work investigates the maximum achievable accuracy under a sub-megabyte budget. We propose MiLSD, a detector tailored for MCU-level constraints, and systematically compare three output representations within a compact fully-convolutional backbone. Our study shows that the proposed F-Clip center-with-length-and-angle formulation learns most effectively at small model sizes. We find that 8-bit quantization preserves full-precision performance, while 4-bit quantization causes significant degradation, particularly in angle regression, with quantization-aware training recovering only part of the loss. With a one-megabyte activation budget and inference enhancements including sub-pixel decoding, test-time augmentation, and a lightweight verifier, MiLSD improves sAP10sAP^10 on ShanghaiTech Wireframe from 10.610.6 (25k parameters, 0.250.25 MB) to 24.124.1 within 11 MB. Rather than competing with GPU-scale parsers, we map the accuracy–memory trade-off across representations, bit-widths, capacities, and post-processing strategies for embedded vision systems. I Introduction Line segments are a primitive structural feature in computer vision: the straight edges of walls, doors, buildings, and machined parts [27]. They support SLAM, structure-from-motion, vanishing-point estimation, lane and power-line detection, and industrial inspection. While much recent progress has targeted GPU- or cloud-based platforms, this work focuses on detection under the tight memory and compute constraints of real-time embedded hardware. Classical detectors such as LSD [27] (Line Segment Detector) and EDLines [1] run on a CPU but find all edges, while modern learned wireframe parsers [35, 31, 4, 5] recover only salient segments but require GPU- or phone-class compute. Table I situates representative methods across this spectrum. Classical detectors grow line-support regions from local gradients and validate them statistically. LSD groups pixels with consistent gradient orientation and accepts a segment if its number of false alarms is below one. EDLines reaches comparable quality faster by chaining edge pixels into clean chains. ELSED [25] targets embedded CPUs for high frame rates. Their shared weakness: accuracy degrades under blur, low contrast, and clutter, and runtime is content-dependent. At its evaluated 640×480640× 480 resolution, ELSED also requires several full-frame gradient and edge buffers (∼ 1.5–2 MB) that exceed even the 1 MB SRAM of an STM32H7, and since its edge walk is global and data-dependent, it cannot be tiled and admits no static worst-case memory bound, unlike a fixed-cost CNN. Classical detectors have also been mapped to FPGAs and ASICs for deterministic latency, but these implementations accelerate hand-designed gradient logic, not neural networks on general-purpose microcontrollers. ShanghaiTech Wireframe [9] reframed line detection as a learning problem. L-CNN [35] proposed junctions and verified candidate lines. AFM [30] used attraction fields, while HAWP [31] combined holistic fields with endpoint verification. ULSD [15] generalized across pinhole, fisheye, and spherical cameras, and LETR [29] uses transformers for direct line detection. L-CNN, HAWP, ULSD, and LETR achieve sAP10≈63sAP^10≈ 63–7070 (AFM, an earlier field-based method, scores ≈24≈ 24), but assume workstation-class memory. The unifying observation is that classical detectors are light but find every edge, while learned parsers are accurate but GPU-bound; no learned method yet occupies the MCU column of Table I. Even the lightest learned detector, M-LSD-tiny [5], requires at least 78 MB of runtime memory, orders of magnitude beyond the SRAM budget of typical microcontrollers. For context, the STM32F746 provides only 320 KB of SRAM and 1 MB of flash [23]. On such devices, the bottleneck is peak activation memory, not parameter storage. Prior work differs in how segments are encoded at the network output. Heatmap methods require a separate linker. Tri-point and center-with-displacement designs (TP-LSD [10], M-LSD [5]) target mobile inference. F-Clip [4] compresses each segment to center, length, and angle; we encode that angle as a double-angle (cos2θ,sin2θ)( 2θ, 2θ). On microcontrollers, activations dominate SRAM usage [16, 2]. MCUNet [17] uses hardware-aware search, and MCUNetV2 [16] adds patch-based inference. Integer quantization with straight-through gradients [11, 3] underpins PTQ and QAT. Int8 is generally safe; sub-8-bit demands care [22, 19]. To our knowledge, no prior work combines these threads for MCU-scale line segment detection. This work investigates the maximum achievable accuracy under a sub-megabyte memory budget. We study three axes: (i) output representation: heatmap, center-with-displacement, and F-Clip-style center-with-length-and-angle; (i) quantization: full-precision, 8-bit, and 4-bit; and (i) inference enhancements: sub-pixel decoding, test-time augmentation, and a lightweight verifier. We propose MiLSD, a detector designed for MCU-scale memory. With a 1 MB activation budget, MiLSD achieves sAP10=24.1sAP^10=24.1 on ShanghaiTech Wireframe, improving over a 0.250.25 MB baseline at 10.610.6. Our quantization study reveals that 8-bit inference preserves full-precision performance, while 4-bit quantization causes significant degradation, particularly in angle regression, where quantization-aware training recovers only part of the loss. This sensitivity has not been reported in prior work. The main contributions are: • A comparison of three output representations under extreme memory constraints, identifying F-Clip-style as the most effective at small model sizes. • A quantization study revealing angle regression in the (cos2θ,sin2θ)( 2θ, 2θ) space as the most sensitive component to bit-width reduction. • MiLSD, operating within 1 MB memory while achieving sAP10=24.1sAP^10=24.1 on ShanghaiTech Wireframe. • An accuracy–resource frontier characterizing trade-offs among capacity, quantization, and post-processing. Targeting MCU-scale detection, where memory is the binding constraint, we show that meaningful wireframe quality is achievable within 1 MB despite GPU-class parsers remaining out of reach. Our study maps the accuracy–resource trade-offs across representations, quantization, and post-processing. The rest of the paper is organized as follows. Section I details the proposed architecture, including the three output representations, the compact backbone, and the quantization-aware training pipeline. Section I describes the experimental protocol, dataset, and training hyperparameters. Section IV presents our empirical findings on representation selection, quantization sensitivity, capacity scaling, and comparisons to prior art. Section V introduces the full MiLSD system on the STM32H7, incorporating capacity scaling, sub-pixel decoding, test-time augmentation, and a learned verification head. Section VI summarizes our contributions and discusses directions for future work. TABLE I: Representative line segment detectors across classical, learned, and efficient regimes (core ideas and platforms per the respective papers). The On MCU? column highlights that prior learned methods target GPU, phone, or FPGA platforms. Work Core idea Learned Platform Output On MCU? LSD [27] Gradient region-growing + a contrario validation no CPU segments no EDLines [1] Edge-drawing + line fitting + Helmholtz validation no CPU segments no ELSED [25] Edge-drawing with segment continuation (embedded-oriented) no CPU/ARM segments no Wireframe-CNN [9] Junction++line heatmaps, dataset that started the field yes GPU heatmaps no L-CNN [35] Junction proposals + line verification head yes GPU junctions no AFM [30] Attraction-field map regressed then squeezed to lines yes GPU field no HAWP [31, 32] Holistic attraction field + endpoint verification yes GPU 4D field no TP-LSD [10] Tri-points (center ++ two endpoints), single-stage yes GPU tri-point no F-Clip [4] Fully-convolutional center ++ length ++ angle yes GPU center+geo no DeepLSD [21] Learned line attraction field + classical refinement yes GPU field no LETR [29] Transformer, line entities without edge maps yes GPU endpoints no M-LSD / -tiny [5] Compact MobileNetV2, center ++ displacement (mobile) yes Phone/GPU center+disp no LSDNet [26] Lightweight CNN front-end + classical LSD back-end yes GPU/CPU segments no EvLSD-IED [28] Event-based LSD via image-to-event distillation yes Event cam endpoints no Predecessor (FPGA) [20] Modified Canny + step-length linking, hardware accelerator no FPGA segments n/a This work Tiny FCN, F-Clip output, int8 quantized yes MCU center+geo yes I Proposed MiLSD design This section describes the design of MiLSD, a line-segment detector optimized for microcontroller-scale memory. We first present three output representations for encoding segments on a fixed grid, then describe the compact backbone shared across all variants, followed by the quantization strategy that enables int8 deployment, and finally the training pipeline and deployment flow. I-A Output Representations A key design decision for any learned line-segment detector is how to encode the continuous geometry of a segment into discrete network outputs. We study three representations on a 128×128128× 128 output grid (Fig. 1). (i) Heatmap: A per-pixel binary classification map indicating whether a pixel lies on a line. This is the most direct representation but requires an external post-processing linker to assemble pixels into continuous segments. While conceptually simple, the linker introduces additional computational overhead and hyperparameters, and the network itself does not produce geometric primitives. (i) Center-with-Displacement: Inspired by TP-LSD and M-LSD [10, 5], this representation predicts a center confidence map alongside displacement vectors from each center pixel to the two endpoints. Each segment is thus encoded as a center point plus two offset vectors. This formulation is single-stage and does not require an external linker, but the network must learn to regress four continuous values (two displacements) per detected segment. (i) F-Clip: Following Dai et al. [4], this representation encodes each segment as a center confidence map, a length ℓ , and an orientation. Whereas F-Clip regresses the angle directly as a scalar, we encode it as (cos2θ,sin2θ)( 2θ, 2θ); this double-angle encoding resolves the 180∘180 ambiguity inherent to undirected line segments, making it uniquely defined for any line orientation. For a ground-truth segment with endpoints 1,2p_1,p_2, the targets at the center cell are: ℓ=∥2−1∥,θ=atan2(y2−y1,x2−x1) = _2-p_1 , θ=atan2(y_2-y_1,x_2-x_1) During inference, decoding inverts this representation: for each detected center peak above a confidence threshold, the segment is reconstructed as a line of length ℓ oriented at θ, centered at the detected location. This compact encoding requires only four output channels (center, length, cos2θ 2θ, sin2θ 2θ), making it particularly attractive for memory-constrained deployment. Section IV-A compares these three representations under identical memory budgets. Figure 1: Three output encodings as dense per-pixel maps (not explicit segments). v1 predicts per-pixel line probability and requires an external linker. v2 Center + displacement [10, 5]: center confidence with two endpoint offset vectors (four channels; int4-fragile). v6 F-Clip [4]: center plus length and angle (cos2θ,sin2θ)( 2θ, 2θ). I-B Backbone Architecture Figure 2: Backbone and output head architecture. A 256×256256× 256 grayscale input is encoded through five strided convolutions, reducing spatial resolution to 64×6464× 64 and expanding channels to 3232. A 1×11× 1 projection and nearest-neighbor upsampling restore the resolution to 128×128128× 128, followed by a 3×33× 3 output head producing the four prediction maps. All three output heads share a common compact backbone designed to minimize activation memory while preserving sufficient spatial resolution for accurate line localization. The architecture (Fig. 2) consists of: 1. A strided fully-convolutional encoder with five convolutional layers, channel widths 8→16→32→32→328→ 16→ 32→ 32→ 32, and stride-2 downsampling that reduces the input resolution from 256×256256× 256 to 64×6464× 64. 2. A 1×11× 1 convolutional reduction layer that projects features to a compact representation. 3. A nearest-neighbor upsampling layer that restores the spatial resolution to 128×128128× 128. 4. A 3×33× 3 output head that produces the final prediction maps (center confidence, length, and orientation for F-Clip; center and displacements for endpoint representation; or a single heatmap). The total parameter count is approximately 2525k at the smallest width. Section IV-D demonstrates that parameter capacity is not the primary bottleneck in this regime; rather, input resolution and activation memory constrain performance. I-C Quantization for MCU Deployment Figure 3: Quantization scheme. Continuous weights are snapped to discrete levels: int8 provides 256 levels (fine grid), while int4 provides only 16 levels (coarse grid). Quantization is performed per-tensor and symmetric. To fit the model within microcontroller SRAM and use optimized integer inference kernels such as CMSIS-N [14], we quantize weights and activations to integer precision. We adopt per-tensor symmetric quantization, implemented with fake-quantization in the forward pass and the straight-through estimator (STE) for gradient propagation during backpropagation [11, 3]. For a weight tensor w and target bit-width b, the quantization scale is: s=max|w|2b−1−1s= |w|2^b-1-1 The quantized weight is computed as: w^=s⋅round(ws) w=s·round ( ws ) This operation snaps continuous values onto a discrete grid of 2b2^b levels. As illustrated in Fig. 3, 8-bit quantization provides 256 levels, offering fine granularity, while 4-bit quantization reduces this to only 16 levels, introducing substantial rounding error. We evaluate two quantization strategies: • Post-training quantization (PTQ): The model is first trained in full precision, then weights and activations are quantized once using a small calibration set. This is computationally efficient but can suffer from accuracy degradation, particularly at low bit-widths. • Quantization-aware training (QAT): The quantization operation is simulated during training, allowing the model to learn weights that are robust to quantization error. While more expensive, QAT often recovers some of the accuracy lost in PTQ. Our deployed model uses int8 quantization with QAT, achieving performance comparable to full precision as shown in Section IV-B. We also investigate 4-bit quantization to understand the limits of aggressive compression, revealing that angle regression is particularly sensitive to bit-width reduction. I-D Training Pipeline and Deployment Flow Training is performed entirely off-device on a GPU workstation; the microcontroller executes only int8 inference. This train-off / infer-on split is the defining premise of our deployment strategy and is common practice in TinyML systems. The training pipeline proceeds as follows: 1. A 256×256256× 256 grayscale image is fed into the backbone. 2. The network produces prediction maps (center, length, cos2θ 2θ, sin2θ 2θ for F-Clip) on a 128×128128× 128 grid. 3. Loss is computed against ground-truth segments encoded in the same representation, using a combination of binary cross-entropy for center confidence and smooth L1 loss for geometric attributes. 4. For QAT, quantization simulation is enabled during training with STE gradient propagation. For deployment, the trained model is exported through X-CUBE-AI, STMicroelectronics’ neural network inference library for STM32 microcontrollers. The export process generates optimized C code that runs on the Arm Cortex-M7 core, using CMSIS-N for efficient integer arithmetic. The inference pipeline on the MCU (Fig. 4) consists of: 1. Input image capture (grayscale, 256×256256× 256). 2. int8 inference through the quantized network. 3. Decoding of output maps into line segments (center detection, length and angle extraction, endpoint computation). 4. Optional post-processing: Line-of-Interest verification and non-maximum suppression. The entire inference pipeline is designed to operate within the 320 KB SRAM budget of the STM32F746, with peak activation memory as the primary constraint rather than parameter storage. Figure 4: Off-device training and on-MCU inference pipeline. The model is trained on GPU with quantization simulation, then exported through X-CUBE-AI for deployment on the STM32F746. The MCU executes int8 inference only. I Experimental Setup Dataset and metric We train and evaluate on the ShanghaiTech Wireframe benchmark [9] (5,000 training and 462 held-out evaluation images, ∼ 74 segments per image). Accuracy is structural average precision sAPtsAP^t at squared-endpoint-distance thresholds t∈5,10,15t∈\5,10,15\ in the 1282128^2 output space; we headline sAP10sAP^10. For comparability with the FPGA predecessor [20] we also reference its Q1 (coverage) and Q2 (noise-suppression) measures. Implementation Table I lists the training configuration. Training is in PyTorch on a GPU; versions v1–v6 of the design search [7] share the backbone of Section I. All models are trained for 300 epochs with a batch size of 32, using the Adam optimizer and a cosine annealing learning rate schedule starting from 10−310^-3. Data augmentation is limited to random horizontal and vertical flips. The loss function combines binary cross-entropy for center classification with smooth L1 loss for length and angle regression, weighted by a factor of 2.0 for the geometric terms and masked to ground-truth segment locations. We evaluate both PTQ and QAT at 8 and 4 bits. TABLE I: Training hyperparameters (deployed F-Clip model). Setting Value Input → output resolution 256×256→128×128256× 256→ 128× 128 Backbone channels 8→16→32→32→328\!→\!16\!→\!32\!→\!32\!→\!32 (∼ 25k params) Output head center, length, cos2θ 2θ, sin2θ 2θ Epochs / batch 300 / 32 Optimizer / LR Adam / 1×10−31× 10^-3, cosine schedule Augmentation horizontal ++ vertical flip Loss BCE(center) + 2.0×+\,2.0× L1(length, angle), masked Quantization per-tensor symmetric; PTQ and QAT IV Results IV-A Representation Comparison: The Climb Figure 5: From baseline to MiLSD: sAP10sAP^10 on Wireframe at each step. The output representation drives the first gains (heatmap v1 → endpoint v2 → F-Clip), reaching 10.610.6 for the 25k-parameter F-Clip model; scaling capacity to the width-4 MiLSD backbone (0.390.39 M parameters) lifts this to 17.817.8, and the inference-time stages (test-time augmentation then the Line-of-Interest verification head) carry it to sAP10=24.1sAP^10=24.1 (purple). Fig. 5 traces the evolution of sAP10sAP^10 across the successive versions v1–v6 of our design search, providing a step-by-step account of how accuracy accumulates as each design choice is introduced. At the lowest rung of this progression, the heatmap baseline proves fundamentally inadequate for producing clean, discrete segments, registering only sAP10=0.3sAP^10=0.3. Endpoint regression constitutes the first formulation capable of yielding a meaningful structural score, reaching sAP10=3.6sAP^10=3.6, yet it remains limited in its ability to recover coherent geometry. The decisive inflection occurs with the adoption of the F-Clip representation, which at the identical 25k-parameter budget more than doubles performance to sAP10=7.2sAP^10=7.2, establishing that the output encoding itself, rather than model size, is the dominant factor at this scale. Subsequent refinements complete the climb in a more incremental fashion: aligning the output grid with the label resolution at 256256 px input lifts accuracy to 8.68.6; incorporating the full training set of 5,000 images together with flip augmentation raises it further to 9.39.3; and extending the training schedule to 300 epochs yields the final deployed score of sAP10=10.6sAP^10=10.6. Taken together, these results demonstrate unambiguously that the largest gains originate from the choice of representation, not from additional capacity. This finding carries particular significance for microcontroller-scale design: a geometric encoding that explicitly parameterizes each segment by its center, length, and orientation equips even a 25k-parameter network with sufficient inductive structure to learn meaningful segment hypotheses, whereas the heatmap and endpoint alternatives remain unable to assemble coherent geometric predictions under the same severe parameter constraint. IV-B Quantization Figure 6: sAP10sAP^10 versus bit-width for the deployed F-Clip model on Wireframe. The int8 point overlaps fp32; PTQ at 4 bits fails while QAT partially recovers. Fig. 6 and Table I present the results of our systematic quantization study, evaluated across the three principal output representations corresponding to versions v1, v2, and v6 of the design search. For the deployed F-Clip model, the transition from full-precision fp32 inference to 8-bit integer quantization incurs a degradation of only 0.60.6 sAP10sAP^10 points (10.6→10.010.6→ 10.0), indicating that int8 arithmetic is sufficient for on-device deployment with negligible impact on structural accuracy. By contrast, post-training quantization at 4 bits proves catastrophic, collapsing performance to sAP10=0.7sAP^10=0.7; quantization-aware training partially mitigates this failure, recovering the score to 6.96.9, which corresponds to approximately 60%60\% of the int4-induced gap relative to the fp32 baseline. Inspection of the per-head errors reveals that the degradation is concentrated almost entirely in the (cos2θ,sin2θ)( 2θ, 2θ) angle regression branch, whose inherently narrow dynamic range is poorly served by the coarse 4-bit quantization grid. On this basis, the deployed model adopts int8 throughout. More broadly, these results suggest that pushing quantization beyond 8 bits is unlikely to remain viable for geometric regression heads of this kind without substantial architectural or training modifications. TABLE I: Quantization results, sAP10sAP^10 on Wireframe. Representation fp32 int8 int4 PTQ int4 QAT Heatmap (v1)∗ 0.3 0.3 0.3 n/a Endpoint (v2) 3.6 3.6 ∼ 0.3 fragile F-Clip (v6, deployed) 10.6 10.0 0.7 6.9 ∗Heatmap is not built for sAP; on its own terms Q2=0.86=0.86, recall=0.44=0.44. IV-C Resolution–Memory Trade-off Figure 7: Input resolution sets a genuine accuracy–memory trade-off. Accuracy (blue, left axis) climbs as resolution rises, but only until the 128128 output grid reaches the 128128-px label resolution at 256256 px input; past that the output is finer than the labels and accuracy saturates, while peak SRAM (coral, right axis) keeps growing and crosses the 320320 KB budget. 256256 px is therefore the operating point. Fig. 7 plots both sAP10sAP^10 and peak SRAM consumption as functions of input resolution, enabling a joint assessment of the accuracy–memory trade-off that governs operating-point selection on resource-constrained hardware. The chosen configuration of 256256 px input is selected at the point where the 128×128128× 128 output grid aligns with the native label resolution, and where peak SRAM remains within the 320 KB ceiling imposed by the STM32F746. This analysis reveals a pronounced and interpretable trade-off: as input resolution increases, structural accuracy improves steadily until the output grid reaches parity with the label resolution, at which point further resolution gains yield diminishing or negligible returns. Beyond this saturation point, peak SRAM continues to grow without a commensurate accuracy benefit. The 256256 px operating point therefore represents the optimal balance between detection quality and memory footprint for the F746 deployment target. IV-D Capacity and Overfitting Figure 8: Training the F-Clip model over 300 epochs. Train and held-out loss track together throughout, with a final gap of ≈0.01≈ 0.01: the 25k-parameter model shows no overfitting despite only 5,0005,000 training images. To test whether the 25k-parameter backbone is capacity-limited, we swept backbone width through three operating points (∼ 25k, ∼ 98k, and ∼ 209k parameters) while holding all other training settings fixed, and recorded the held-out loss floor at convergence. The result is nearly flat: the smallest model settles at 1.741.74, while the intermediate and largest variants both reach 1.731.73; an eightfold increase in parameters yields only a 0.010.01 reduction in held-out loss. This pattern is consistent with the capacity-gap effect documented in the knowledge-distillation literature [18], and implies limited headroom for naive distillation-based improvement at this scale. The flatness further suggests that the model is already operating near the information-theoretic limit imposed by the dataset and the chosen input resolution, such that additional parameters are unlikely to translate into measurable gains in structural accuracy. Complementing this capacity analysis, Fig. 8 plots the training and held-out loss trajectories over the full 300-epoch schedule. The two curves remain closely aligned throughout training, converging to a final gap of approximately 0.010.01, indicating the absence of overfitting despite the severely constrained 25k-parameter architecture and the modest size of the training set. Together, these observations support the conclusion that the fixed small-width design is both memory-efficient and well-regularized by its architectural constraints. IV-E Comparison with Prior Work Figure 9: Accuracy vs. parameter budget on the Wireframe benchmark (log-scale x). Our two operating points sit at the extreme low-resource end: the 25k-parameter F-Clip model on the STM32F746 (sAP10=10.6sAP^10=10.6) and MiLSD on the STM32H7 (0.390.39 M parameters, sAP10=24.1sAP^10=24.1, purple). Related learned detectors use 24×24× to 1,600×1,600× more parameters and assume mobile or GPU compute; their figures are from the respective papers (Table IV) [32, 4, 31, 35, 5, 30, 9]. Table IV and Fig. 9 jointly situate our two operating points within the broader accuracy–resource frontier of the learned line-segment detection literature. At the low-resource end of this range, the 25k-parameter F746 model achieves sAP10=10.6sAP^10=10.6 within a 0.25 MB activation footprint, while MiLSD (Section V) extends this capability to sAP10=24.1sAP^10=24.1 under the expanded 1 MB SRAM budget of the STM32H7. In absolute accuracy terms, both models remain substantially below the performance of contemporary transformer-era parsers, including DT-LSD at 71.771.7 [12] and LINEA at 65.065.0–67.967.9 [13], as well as compact GPU-oriented designs such as EM-LSD, which attains 63.263.2 with 1.11.1 M parameters [8]. This disparity is an expected consequence of operating in a memory regime where peak SRAM is measured in kilobytes rather than megabytes. On the resource axis, however, our position is distinctive: Table IV lists no other learned detector with an affirmative On MCU? entry or an accompanying int8/int4 quantization study. To our knowledge, this is the first learned line-segment detector designed and evaluated under sub-megabyte MCU SRAM budgets, occupying a previously empty region between high-accuracy GPU-based parsers and classical lightweight detectors. TABLE IV: Accuracy vs. resources on Wireframe. Prior sAP10sAP^10 figures are from the respective papers or, for methods predating the sAP metric, from later re-evaluations [12, 32, 13, 4, 31, 8, 35, 5, 30, 9, 27]; parameter counts are largely as tabulated by LINEA [13]. LINEA reports the 462-image Wireframe validation split. Method sAP10sAP^10 Params On MCU? DT-LSD [12] 71.7 217 M no HAWPv2 [32] 69.7 ∼ 11 M no LINEA-L [13] 67.9 25 M no F-Clip [4] 67.4 ∼ 28 M no HAWP [31] 66.5 ∼ 10 M no LINEA-N [13] 65.0 3.9 M no EM-LSD [8] 63.2 1.1 M no L-CNN [35] 62.9 ∼ 9.7 M no M-LSD [5] 62.1 1.5 M no M-LSD-tiny [5] 58.0 0.6 M (≥ 78 MB) no AFM [30] 24.4 ∼ 43 M no Wireframe-CNN [9] 5.1 ∼ 30 M no Classical LSD [27] ≈ 0 n/a CPU Ours: F-Clip int8 (F746) 10.6 0.025 M (0.25 MB) yes Ours: MiLSD (H7) 24.1 0.39 M (∼ 1 MB) yes IV-F Qualitative Results Figure 10: Detections on two Wireframe-val images for v1 (heatmap), v2 (endpoint), and v3–v6 (F-Clip progression); layout described in Section IV-F. The dominant visual step is v2→ 3; later versions refine segment placement incrementally. Fig. 10 provides a qualitative side-by-side comparison of versions v1 through v6 on two representative Wireframe-val images [7], offering visual corroboration of the quantitative trends reported above. In the heatmap formulation (v1), predictions remain densely distributed across the image without resolving into discrete, well-formed segments. Endpoint regression (v2) produces scattered short segments that fail to reconstruct the underlying room structure. Beginning with F-Clip at v3, the detections progressively recover coherent architectural geometry, a visual pattern that directly mirrors the quantitative sAP10sAP^10 jump at v3 (3.6→7.23.6→ 7.2) and the more incremental refinement observed across v3–v6 (7.2→10.67.2→ 10.6). The qualitative contrast is visually striking: F-Clip yields coherent, well-localized segments that align closely with salient architectural edges, whereas the heatmap and endpoint alternatives continue to produce noisy, fragmented, or incomplete detections that lack geometric consistency. V MiLSD: Verification-Augmented Detection on the STM32H7 Figure 11: MiLSD inference pipeline on the STM32H7. An int8 fully-convolutional backbone predicts F-Clip center/length/angle maps; candidate segments are decoded by 3×33×3 peak non-maximum suppression with sub-pixel refinement; optional test-time flip augmentation averages the predicted maps; and a small Line-of-Interest (LoI) head pools features along each candidate and re-scores it. All stages reuse a single ≈1≈1 MB activation arena. The 320 KB SRAM budget of the STM32F746 imposes a hard ceiling on the detector developed in Section I, restricting it to approximately 25k parameters and a correspondingly minimal activation footprint. A larger yet still microcontroller-class platform, the STM32H7, which provides 1 MB of SRAM and is executed via CMSIS-N [14] on a Cortex-M7 core, affords sufficient headroom to accommodate both a more capable backbone and a substantially richer inference pipeline. We designate the resulting system MiLSD (Micro Line-Segment Detector). MiLSD preserves the F-Clip center–length–angle output representation [4] (Section I-A) introduced earlier and extends it along two complementary axes: first, a capacity-scaled int8 backbone whose activation arena is deliberately sized to approach, but not exceed, the 1 MB SRAM budget; and second, a sequence of inference-time refinement stages, comprising sub-pixel decoding, test-time augmentation, and a learned verification head, each of which contributes additional accuracy without increasing the size of the trained network. The complete pipeline is illustrated in Fig. 11. In contrast to the F746 model, whose performance is bounded by its severely constrained 25k-parameter budget, MiLSD exploits the expanded memory envelope to scale model capacity while preserving a lightweight, inference-efficient pipeline appropriate for real-time embedded deployment. V-A Capacity-Scaled Backbone With eight times the SRAM of the F746, the backbone width is increased until the int8 activation arena approaches, but does not exceed, 1 MB, yielding a approximately 0.39 M-parameter model (peak arena approximately 1 MB at 256 px input; a 0.7 MB fallback configuration is also retained for devices with tighter memory). Trained as in Section I for 300 epochs, this model attains sAP10=17.8sAP^10=17.8 on Wireframe-val, versus 10.610.6 for the 25k F746 model, confirming that, beyond the extreme F746 regime, capacity is a genuine lever. This 68% relative improvement demonstrates that the additional parameters are effectively utilized when the memory budget permits, validating our decision to scale the backbone for the H7 platform. V-B Sub-Pixel Decoding and Test-Time Augmentation The center peaks are refined to sub-pixel accuracy by a one-dimensional parabolic fit over each peak’s neighbourhood, directly targeting the endpoint precision that structural AP rewards (sAP10:17.8→18.1sAP^10:17.8→ 18.1). This refinement is particularly beneficial for structural AP, which penalizes endpoint localization errors quadratically. Averaging the predicted maps over the image and its horizontal, vertical, and diagonal flips (test-time augmentation, TTA) further improves robustness (sAP10:18.1→21.0sAP^10:18.1→ 21.0), a gain of nearly 3 points from the four-view ensemble. TTA multiplies inference latency by the number of views but reuses the same activation arena, so it does not raise peak memory, making it a memory-free accuracy boost at the cost of increased latency. V-C Line-of-Interest Verification Head The largest gain comes from a trained verifier in the spirit of L-CNN [35] and HAWP [31], scaled to the microcontroller. With the backbone frozen, a small multilayer perceptron takes, for each candidate segment, features bilinearly pooled at 32 points along the line from the backbone feature map and the output maps, together with a short geometric descriptor, and predicts a verification score (real vs. spurious), trained with one-to-one matched labels. Re-ranking by verification × center score reaches the MiLSD row of Table V. The decode and post-filtering design were obtained by analyzing the inference stages of the principal wireframe parsers [35, 31, 4, 33, 34]; across that study, weight-free post-processing saturates near sAP10=21sAP^10=21, and only the trained verifier advances beyond it, contributing an additional 3.1 points to reach 24.1. TABLE V: MiLSD on Wireframe-val (STM32H7 model). Each stage is inference-time only; the trained network is unchanged. The oracle ranks the same candidates by their true labels and is the recall ceiling of the candidate set. Configuration sAP5sAP^5 sAP10sAP^10 sAP15sAP^15 Trained model (sub-pixel decode) 12.1 18.1 21.2 + test-time augmentation (×4× 4) 15.1 21.0 24.0 + LoI verification (MiLSD) 16.0 24.1 27.9 Oracle (perfect verifier) 24.1 37.4 40.0 The oracle row (sAP10=37.4sAP^10=37.4) bounds what the candidate set can deliver; the LoI head recovers about 55% of the gap from TTA. The remainder reflects unannotated image edges and recall limits; junction-based candidate generation [35] could help but exceeds the 1 MB budget. V-D Qualitative Results Fig. 12 shows MiLSD on held-out scenes. The detector is complete on the salient structure (cabinetry, counters, window mullions, and architectural edges are recovered at correct orientation and length). The dense scene of example 2 illustrates the verifier suppressing the redundant ridge detections that a raw center-heatmap emits, demonstrating the effectiveness of the learned verification head. Example 3 shows that the remaining stray predictions are real but unannotated edges (reflections, texture seams), consistent with the oracle analysis above, which identified that many false positives are actually unlabeled ground-truth edges. These qualitative results validate that MiLSD achieves its accuracy gains through meaningful structural understanding rather than overfitting to the training set. Figure 12: Four Wireframe-val scenes: ground truth (left, green) and MiLSD output (right, yellow) after LoI verification; line opacity encodes verifier confidence. V-E Deployment Budget The SRAM ceiling is set by the backbone’s int8 activation arena (approximately 1 MB); the LoI head’s pooled feature (<<0.5 MB) fits within that peak and TTA reuses it, so neither raises it. Weights total approximately 0.54 MB (backbone plus head), well within flash. Latency is dominated by the int8 convolutions and scales with the number of TTA views; the LoI head adds a small per-line cost. On-device arena and latency must be confirmed with ST Edge AI [24]; the figures here are software-measured. The memory-efficient design ensures that all inference stages operate within the 1 MB SRAM budget, making MiLSD deployable on the STM32H7 without requiring external memory. Source code is released for reproducibility [6]. VI Conclusion This paper presented MiLSD, a line-segment detector explicitly designed for microcontroller-scale memory, alongside a systematic study of the accuracy–resource trade-off under extreme memory constraints. We compared three output representations and found that the F-Clip center-with-length-and-angle encoding learns most effectively at small model sizes, achieving sAP10=10.6sAP^10=10.6 with only 25k parameters. Our quantization study revealed that 8-bit weights preserve full-precision accuracy, while 4-bit quantization collapses, particularly in the (cos2θ,sin2θ)( 2θ, 2θ) angle regression, with quantization-aware training recovering only part of the loss. By scaling the backbone to a 1 MB activation budget and adding inference-time enhancements including sub-pixel decoding, test-time augmentation, and a Line-of-Interest verification head, MiLSD improves sAP10sAP^10 from 10.610.6 at 0.25 MB to 24.124.1 within 1 MB on the ShanghaiTech Wireframe benchmark. To our knowledge, no prior work characterizes the joint trade-off among representation choice, quantization bit-width, and on-device post-processing at this memory scale. F-Clip wins at int8 but its angle head is int4-fragile, whereas heatmaps tolerate lower precision yet require an external linker, a finding that informs future TinyML geometric-vision designs. As expected, Wireframe accuracy remains far below GPU-class parsers given the SRAM envelope we target; that gap is inherent to the memory regime rather than a limitation we aim to overcome. References [1] C. Akinlar and C. Topal (2011) EDLines: a real-time line segment detector with a false detection control. Pattern Recognition Letters 32 (13), p. 1633–1642. Cited by: TABLE I, §I. [2] C. Banbury, C. Zhou, I. Fedorov, R. Matas Navarro, U. Thakker, D. Gope, V. Janapa Reddi, M. Mattina, and P. N. Whatmough (2021) MicroNets: neural network architectures for deploying tinyml applications on commodity microcontrollers. Proc. of Machine Learning and Systems (MLSys). Note: arXiv:2010.11267 Cited by: §I. [3] Y. Bengio, N. Léonard, and A. Courville (2013) Estimating or propagating gradients through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432. Note: Straight-through estimator Cited by: §I, §I-C. [4] X. Dai, H. Gong, S. Wu, X. Yuan, and Y. Ma (2022) Fully convolutional line parsing. Neurocomputing 506, p. 1–11. Note: F-Clip. arXiv:2104.11207 External Links: Document Cited by: TABLE I, §I, §I, Figure 1, §I-A, Figure 9, TABLE IV, TABLE IV, §V-C, §V. [5] G. Gu, B. Ko, S. Go, S. Lee, J. Lee, and M. Shin (2022) Towards light-weight and real-time line segment detection. In AAAI Conf. on Artificial Intelligence, Note: M-LSD / M-LSD-tiny; MobileNetV2, center+displacement. arXiv:2106.00186 Cited by: TABLE I, §I, §I, Figure 1, §I-A, Figure 9, TABLE IV, TABLE IV, TABLE IV. [6] P. Hassani Shariat Panahi, A. H. Jalilvand, and M. H. Najafi (2026) MiLSD: micro line-segment detector. Note: https://github.com/F4RAN/MiLSDSource code, trained models, and evaluation scripts for the MiLSD implementation. Cited by: §V-E. [7] P. Hassani Shariat Panahi (2026) LSD-TML-All: training and evaluation notebooks for versions v1–v6. Note: https://w.kaggle.com/code/parsahshariatpanahi/lsd-tml-allKaggle notebooks for the representation and quantization study (v1–v6). Cited by: §I, §IV-F. [8] S. Hu, L. Zhao, and Q. Wang (2026) EM-lsd: a lightweight and efficient model for multi-scale line segment detection. Robotics and Autonomous Systems 195, p. 105192. External Links: ISSN 0921-8890, Document, Link Cited by: §IV-E, TABLE IV, TABLE IV. [9] K. Huang, Y. Wang, Z. Zhou, T. Ding, S. Gao, and Y. Ma (2018) Learning to parse wireframes in images of man-made environments. In IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Cited by: TABLE I, §I, §I, Figure 9, TABLE IV, TABLE IV. [10] S. Huang, F. Qin, P. Xiong, N. Ding, Y. He, and X. Liu (2020) TP-LSD: tri-points based line segment detector. In European Conf. on Computer Vision (ECCV), Note: arXiv:2009.05505 Cited by: TABLE I, §I, Figure 1, §I-A. [11] B. Jacob, S. Kligys, B. Chen, M. Zhu, M. Tang, A. Howard, H. Adam, and D. Kalenichenko (2018) Quantization and training of neural networks for efficient integer-arithmetic-only inference. In IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Note: arXiv:1712.05877 Cited by: §I, §I-C. [12] S. Janampa and M. Pattichis (2025-02) DT-lsd: deformable transformer-based line segment detection. In Proceedings of the Winter Conference on Applications of Computer Vision (WACV), p. 3477–3486. Cited by: §IV-E, TABLE IV, TABLE IV. [13] S. Janampa and M. Pattichis (2025) LINEA: fast and accurate line detection using scalable transformers. External Links: 2505.16264, Link Cited by: §IV-E, TABLE IV, TABLE IV, TABLE IV. [14] L. Lai, N. Suda, and V. Chandra (2018) CMSIS-N: efficient neural network kernels for arm cortex-m CPUs. arXiv preprint arXiv:1801.06601. Cited by: §I-C, §V. [15] H. Li, H. Yu, J. Wang, W. Yang, L. Yu, and S. Scherer (2021) ULSD: unified line segment detection across pinhole, fisheye, and spherical cameras. ISPRS J. of Photogrammetry and Remote Sensing. Note: arXiv:2011.03174 Cited by: §I. [16] J. Lin, W. Chen, H. Cai, C. Gan, and S. Han (2021) MCUNetV2: memory-efficient patch-based inference for tiny deep learning. In Advances in Neural Information Processing Systems (NeurIPS), Note: arXiv:2110.15352 Cited by: §I. [17] J. Lin, W. Chen, Y. Lin, J. Cohn, C. Gan, and S. Han (2020) MCUNet: tiny deep learning on IoT devices. In Advances in Neural Information Processing Systems (NeurIPS), Note: arXiv:2007.10319 Cited by: §I. [18] S. I. Mirzadeh, M. Farajtabar, A. Li, N. Levine, A. Matsukawa, and H. Ghasemzadeh (2020) Improved knowledge distillation via teacher assistant. In AAAI Conf. on Artificial Intelligence, Note: capacity-gap effect Cited by: §IV-D. [19] P. Novac, G. Boukli Hacene, A. Pegatoquet, B. Miramond, and V. Gripon (2021) Quantization and deployment of deep neural networks on microcontrollers. Sensors 21 (9), p. 2984. Cited by: §I. [20] C. Ossimitz and N. Taherinejad (2021-05) A fast line segment detector using approximate computing. p. 1–5. External Links: Document Cited by: TABLE I, §I. [21] R. Pautrat, D. Barath, V. Larsson, M. R. Oswald, and M. Pollefeys (2023) DeepLSD: line segment detection and refinement with deep image gradients. In IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Note: Line attraction field. arXiv:2212.07766 Cited by: TABLE I. [22] M. Rusci, A. Capotondi, and L. Benini (2019) Memory-driven mixed low precision quantization for enabling deep network inference on microcontrollers. arXiv preprint arXiv:1905.13082. Cited by: §I. [23] STMicroelectronics STM32F746x arm cortex-m7 microcontroller datasheet. Note: https://w.st.com/en/microcontrollers-microprocessors/stm32f746ng.html320 KB SRAM, 1 MB flash, 216 MHz Cortex-M7. Cited by: §I. [24] STMicroelectronics (2025) ST Edge AI Suite / X-CUBE-AI / ST Edge AI Developer Cloud. Note: https://w.st.com/en/embedded-software/x-cube-ai.htmlModel analysis, int8 code generation, and on-target benchmarking for STM32. Cited by: §V-E. [25] I. Suárez, J. M. Buenaposada, and L. Baumela (2022) ELSED: enhanced line segment drawing. Pattern Recognition 127, p. 108619. Note: arXiv:2108.03144 External Links: Document Cited by: TABLE I, §I. [26] L. Teplyakov, L. Erlygin, and E. Shvets (2022) LSDNet: trainable modification of LSD algorithm for real-time line segment detection. IEEE Access 10, p. 45256–45265. Note: arXiv:2209.04642 External Links: Document Cited by: TABLE I. [27] R. G. von Gioi, J. Jakubowicz, J. Morel, and G. Randall (2010) LSD: a fast line segment detector with a false detection control. IEEE Trans. on Pattern Analysis and Machine Intelligence (TPAMI) 32 (4), p. 722–732. Cited by: TABLE I, §I, §I, TABLE IV, TABLE IV. [28] Wang et al. (2024) EvLSD-IED: event-based line segment detection with image-to-event distillation. IEEE Trans. on Instrumentation and Measurement (TIM). Note: Knowledge-distillation precedent for LSD. Cited by: TABLE I. [29] Y. Xu, W. Xu, D. Cheung, and Z. Tu (2021) Line segment detection using transformers without edges. In IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Note: LETR. arXiv:2101.01909 Cited by: TABLE I, §I. [30] N. Xue, S. Bai, F. Wang, G. Xia, T. Wu, and L. Zhang (2019) Learning attraction field representation for robust line segment detection. In IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Note: AFM. arXiv:1812.02122 Cited by: TABLE I, §I, Figure 9, TABLE IV, TABLE IV. [31] N. Xue, T. Wu, S. Bai, F. Wang, G. Xia, L. Zhang, and P. H.S. Torr (2020) Holistically-attracted wireframe parsing. In IEEE/CVF Conf. on Computer Vision and Pattern Recognition (CVPR), Note: HAWP. arXiv:2003.01663 Cited by: TABLE I, §I, §I, Figure 9, TABLE IV, TABLE IV, §V-C. [32] N. Xue, T. Wu, S. Bai, F. Wang, G. Xia, L. Zhang, and P. H.S. Torr (2023) Holistically-attracted wireframe parsing: from supervised to self-supervised learning. IEEE Trans. on Pattern Analysis and Machine Intelligence (TPAMI). Note: HAWPv2/v3. arXiv:2210.12971 Cited by: TABLE I, Figure 9, TABLE IV, TABLE IV. [33] Z. Zhang, Z. Li, N. Bi, J. Zheng, J. Wang, K. Huang, W. Luo, Y. Xu, and S. Gao (2019) PPGNet: learning point-pair graph for line segment detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), p. 7105–7114. Cited by: §V-C. [34] K. Zhao, Q. Han, C. Zhang, J. Xu, and M. Cheng (2020) Deep Hough transform for semantic line detection. In Proceedings of the European Conference on Computer Vision (ECCV), Cited by: §V-C. [35] Y. Zhou, H. Qi, and Y. Ma (2019) End-to-end wireframe parsing. In IEEE/CVF Int. Conf. on Computer Vision (ICCV), Note: L-CNN. arXiv:1905.03246 Cited by: TABLE I, §I, §I, Figure 9, TABLE IV, TABLE IV, §V-C, §V-C. Parsa Hassani Shariat Panahi received his B.Sc. degree in Computer Engineering from Azad University South Tehran Branch, Tehran, Iran, and the M.Sc. degree in Computer Engineering - Computer Networks from Iran University of Science and Technology, Tehran, Iran. His research interests include cellular networks, QoE assessment, telecommunication networks, wireless communication, and machine learning. He can be reached at parsa_hassani@comp.iust.ac.ir. Amir Hossein Jalilvand received his B.Sc. degree in Computer Engineering from Bu-Ali Sina University, Hamadan, Iran, and the M.Sc. degree in Computer Engineering - Computer Architecture from Iran University of Science and Technology, Tehran, Iran. He is currently pursuing his Ph.D. in Computer Engineering. His research interests include cellular networks, stochastic and unary computing, computer architecture, fuzzy logic, and machine learning. Mr. Jalilvand has authored several publications in these fields. He can be reached at jalilvand_a@comp.iust.ac.ir. M. Hassan Najafi received his Ph.D. in electrical and electronics engineering from the University of Minnesota-Twin Cities, Minneapolis, MN, USA, in 2018. He is currently an Associate Professor at the Electrical, Computer, and Systems Engineering Department at Case Western Reserve University. His research interests include stochastic and approximate computing, unary processing, in-memory computing, and hyperdimensional computing. He has authored/coauthored more than 120 peer-reviewed papers and has been granted 12 U.S. patents with more pending. Dr. Najafi received the NSF CAREER Award in 2024, the Best Paper Award at GLSVLSI’23 and ICCD’17, and the 2018 EDAA Outstanding Dissertation Award. Dr. Najafi is a senior member of IEEE and a senior member of the U.S. National Academy of Inventors (NAI). He can be reached at najafi@case.edu.