MiLSD: Micro Line-Segment Detector Under 1 MB for MCUs

Learn how MiLSD brings precise line segment detection to MCUs under 1 MB, with 8-bit quantization and optimized post-processing.

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

IA embebida: detector MiLSD en menos de 1 MB de memoria

Line segment detection has become a fundamental component in computer vision systems, especially in disciplines such as visual SLAM, three-dimensional reconstruction, and industrial inspection. However, bringing these algorithms to low-cost microcontroller devices is not trivial: available memory is usually far below what conventional deep learning models require. It is in this context that MiLSD appears, a line segment detector specifically designed to operate with memory budgets below one megabyte. At Q2BSTUDIO, as a company specialized in software and technology development, we believe this kind of progress is essential to enable artificial intelligence applications in embedded environments and in real industry.

The main challenge of MiLSD is to maximize accuracy without exceeding strict memory limits. The smallest line segment detection models usually occupy several megabytes, which prevents them from running on MCUs. MiLSD addresses this issue with a compact, fully convolutional backbone that dramatically reduces the number of parameters and the memory footprint, while maintaining a sufficiently expressive intermediate representation. The key is not only reducing size, but doing so without degrading prediction quality. For this reason, three output representations are compared within the same lightweight architecture, looking for the most efficient way to encode line segments. In addition, in industrial environments, update frequency and energy consumption also influence system feasibility. Therefore, MiLSD's architecture is designed not only to fit in memory, but also to offer reasonable latency and sustainable computational cost.

The most effective representation is called F-Clip center-with-length-and-angle. Instead of predicting heat maps of endpoint positions or dense masks, this formulation focuses the output on the segment's center point, its length, and its angle. This compact representation is especially suitable for small models because it reduces the load on the final layers and makes basic geometry easier to learn. The study shows that, with the same computational budget, F-Clip achieves more stable learning and better results than other alternatives. For a company developing custom software, this finding has practical implications: choosing the right representation in a vision model can be more decisive than simply adding more layers.

Quantization is another critical factor. MiLSD evaluates the impact of reducing model weights to 8 and 4 bits. Results show that 8-bit quantization preserves almost all full-precision performance, while 4-bit quantization causes notable degradation, especially in angle regression. Quantization-aware training can recover part of that loss, but not all of it. This conclusion guides embedded system design: it is not enough to compress the model; it must be trained with quantization in mind and prioritize the most sensitive components, such as angular output.

In addition to representation and quantization, MiLSD incorporates inference improvements: sub-pixel decoding, test-time augmentation, and a lightweight verifier. These techniques increase accuracy without significantly increasing memory consumption. The result is an improvement in sAP10 on ShanghaiTech Wireframe from 10.6 with 25 thousand parameters and 0.25 MB to 24.1 within 1 MB. This evolution demonstrates that it is possible to obtain a competitive line segment detector for extremely constrained environments, as long as all stages of the pipeline are optimized, from the model to post-processing. These gains are obtained without specialized hardware, opening the door to integration into existing products.

The study does not intend to compete with GPU-scale solutions, but rather to map the trade-off between accuracy and memory. For engineering teams working on commercial products, knowing this map allows informed decisions: how many parameters to allocate to the model, what bit width to choose, which post-processing techniques are worth including. In many cases, a small, well-tuned model is more valuable than a large network that cannot fit in the target hardware. This approach aligns with Q2BSTUDIO's philosophy, where software and technology development seeks efficient and sustainable solutions in the real world.

The process of taking a line detector to an MCU does not end with choosing the architecture. Optimization involves calibrating the model, generating efficient embedded code, and validating behavior on the target hardware. In real projects, collaboration between the AI team and firmware engineers is essential. MiLSD provides a solid foundation for this type of integration, but each product needs specific adjustments. This is where custom software development makes the difference: no universal solution fits all cases. Platforms such as AWS or Azure can complement local inference with model update services or remote analysis, as long as cybersecurity measures are respected. This systems approach prevents an efficient algorithm from being left isolated in a device without practical value.

Computer vision on constrained devices also benefits from a complete system architecture. At Q2BSTUDIO, we routinely work with clients who need to integrate AI modules into their physical products. For them, the cloud offers the possibility of offloading complex processes to platforms such as AWS or Azure, while the local device runs lightweight models like MiLSD. This hybrid combination makes it possible to scale performance without sacrificing privacy or latency. At the same time, cybersecurity becomes essential to protect both embedded firmware and communication with cloud services. Our experience in cybersecurity allows us to design robust end-to-end systems, from the sensor to the analytics dashboard.

Another relevant aspect is monitoring and exploiting the data generated by these systems. Once a device with line segment detection capabilities starts operating, it produces useful information about environments, obstacles, or defects. Integrating that information with Business Intelligence platforms, such as Power BI, eases decision making. For example, on an industrial inspection line, machine vision data can feed dashboards that show defect rates, cycle times, and quality changes in real time. Q2BSTUDIO offers BI and Power BI services to turn vision data into business value. In addition, incorporating AI agents allows automating predictive maintenance or quality control tasks, reducing manual intervention and improving consistency. This ability to convert visual signals into operational decisions represents a competitive advantage for companies betting on industrial digitalization.

In the future, combining models like MiLSD with agile development methodologies will accelerate the life cycle of embedded products. The key is understanding that model size alone does not determine practical usefulness. A detector with less than one megabyte can enable advanced functions in security cameras, cleaning robots, drones, or medical devices, as long as it is integrated with a solid software strategy. To achieve this, companies need technology partners that master both custom software development and cloud infrastructure, artificial intelligence, and cybersecurity. At Q2BSTUDIO, we combine these capabilities to take computer vision from the laboratory to production.

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.