MiLSD: A Micro Line-Segment Detector for Resource-Constrained Devices

MiLSD enables accurate line segment detection on microcontrollers under 1 MB. Explore quantization, optimization, and embedded vision insights.

viernes, 31 de julio de 2026 • 5 min read • Q2BSTUDIO Team

Detección de líneas en MCUs con precisión y menos de 1 MB

Line segment detection is a key task in computer vision, but implementing it on resource-limited devices remains a challenge. Mobile robots, augmented reality systems and industrial inspection cameras need to understand the geometry of a scene without relying on external servers. In this context, a deep learning model must provide accuracy with very little memory, because low-cost microcontrollers cannot load dozens of megabytes of parameters.

Common commercial solutions are trained on GPUs and run on powerful computers. When moved to a microcontroller, the model must coexist with the real-time operating system, the camera buffer and control tasks. It is not enough to reduce the number of layers; the output representation and inference process need to be reconsidered. A recent study explores this limit: what is the maximum accuracy that can be achieved with less than one megabyte? The answer directly affects applications such as visual SLAM, 3D reconstruction and industrial inspection, where line segments are a valuable geometric cue.

The MiLSD proposal starts from a compact and fully convolutional backbone. Instead of predicting complete segments directly, it compares multiple output representations. The most effective one, called F-Clip, encodes each segment using its center, length and angle. This formulation makes learning easier for small models and prevents the network from wasting capacity on ambiguous tasks. The result is that representation matters as much as architecture, especially when the memory budget is only a few hundred kilobytes.

Quantization is another critical factor. Reducing weights to 8 bits preserves full-precision behavior, which makes this option reasonable for microcontrollers with tight flash memory. In contrast, dropping to 4 bits introduces a noticeable loss in quality, especially in angle regression. Quantization-aware training helps, but it does not fully compensate for the damage. This shows that architecture and output representation must be designed with quantization in mind from the start, not as a final step.

Post-processing also contributes a significant share of performance. Sub-pixel decoding refines center coordinates; test-time augmentation makes the model more robust to small variations; and a lightweight verifier removes false positives without excessive cost. With these improvements, the sAP10 metric on ShanghaiTech Wireframe goes from 10.6, with a 25,000-parameter model and 0.25 MB, to 24.1 within a 1 MB budget. This is a meaningful advance for embedded systems.

One aspect that is often underestimated is memory consumption during inference. It is not enough for the weights to fit in flash memory; intermediate activations also occupy RAM. The fully convolutional design of MiLSD is decisive because it avoids dense layers that inflate the parameter count and makes computational cost predictable. Moreover, the activation budget acts as a design constraint: once the maximum available memory is known, the width of each layer and the size of the feature maps can be set before training. This discipline is common in custom software development for embedded systems, where every kilobyte counts.

Evaluating these models is delicate. The sAP10 metric measures the agreement between detected and ground-truth segments with a tolerance of 10 pixels, and it is especially sensitive to length and angle errors. For this reason, an improvement in angle regression has a direct impact on the final score. In 4-bit models, deterioration of orientation not only shifts segments but also breaks the visual connectivity of the scene, which is unacceptable in applications such as SLAM.

From a business perspective, this type of research has immediate applications. Smart factories, autonomous vehicles and logistics platforms require edge vision with low latency and no dependency on a continuous connection. At Q2BSTUDIO we develop custom software solutions to integrate these models into real products. The design of a compact network does not end with training; it requires deployment engineering that considers available memory, energy consumption and remote firmware updates.

In addition, AI agents are changing the way vision systems operate. An agent can monitor a camera, detect anomalies and decide whether to send an image to the cloud for deeper analysis. For this scheme to work, a fast and accurate local model such as MiLSD is essential, as well as an AI infrastructure that manages the complete model lifecycle. At Q2BSTUDIO, we guide companies through AI solution deployment, from architecture selection to integration with existing information systems.

The cloud architecture also plays an important role. An edge device with line segment detection can send relevant events to an AWS/Azure cloud infrastructure to train more powerful models or correlate measurements over time. Once structured, this information feeds BI/Power BI dashboards that help production managers make data-driven decisions. Of course, any connected solution must include cybersecurity from the design phase, because a vulnerable microcontroller can become an entry point to the entire industrial network. At Q2BSTUDIO we integrate these capabilities into custom application projects, combining AI, cloud and security in the same roadmap.

We should not forget the importance of MLOps in these projects. Deploying a model on a microcontroller is not the end: performance must be monitored, models must be updated when the environment changes, and decisions based on their outputs must be auditable. Therefore, companies looking for a real advantage need efficient hardware, custom software and a team that understands the full AI lifecycle.

MiLSD is not intended to replace large GPU-scale models. Its goal is to fill the space of low-cost devices, where connectivity is intermittent and energy consumption is a priority. In that scenario, the balance between accuracy and memory matters more than any accuracy record. This philosophy aligns with the edge computing trend: process locally what the cloud does not need, and send only what adds value.

In short, MiLSD shows that high accuracy is not exclusive to large systems. A well-chosen output representation, proper quantization and efficient post-processing make it possible to bring line segment detection to sub-megabyte devices. For companies, this represents a real opportunity to incorporate computer vision into affordable, scalable and robust products. The key is to understand the complete problem: not only the model, but also the device, the data, the cloud and the people who will use the information. At Q2BSTUDIO, we work on each of these levels so that technology stops being an experiment and becomes a competitive advantage.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.