lsdetect/lib.rs
1//! A line segment detector (LSD) in Rust, with optional Python bindings.
2//!
3//! Implements "LSD: a Line Segment Detector" (Grompone von Gioi et al., IPOL
4//! 2012) as an independent, permissively licensed implementation,
5//! plus a parallel perspective warp for applying the geometry the
6//! segments reveal and a coordinate-map remap for any other geometry.
7//!
8//! ```
9//! # fn main() -> Result<(), lsdetect::SizeMismatch> {
10//! // A vertical step edge through a 96x96 frame.
11//! let mut image = vec![50u8; 96 * 96];
12//! image.chunks_mut(96).for_each(|row| row[48..].fill(200));
13//!
14//! let segments = lsdetect::detect(&image, 96, 96, lsdetect::SCALE)?;
15//! let longest = segments.iter().max_by(|a, b| {
16//! a.length().total_cmp(&b.length())
17//! });
18//! assert!(longest.is_some_and(|s| s.angle().abs() > 88.0));
19//! # Ok(())
20//! # }
21//! ```
22
23mod detector;
24mod sample;
25mod warp;
26
27pub use detector::{SCALE, Segment, detect};
28pub use sample::{Gray, Sample, SizeMismatch};
29pub use warp::{Filter, remap_gray, remap_rgb, warp_rgb};
30
31#[cfg(feature = "extension-module")]
32mod python;