--- id: quadrilateral-fitter version: "1.12" license: MIT license_treatment: permissive maintenance: dormant --- # quadrilateral-fitter — QuadrilateralFitter is an efficient and easy-to-use Python library for fitting irregular quadrilaterals from irregular polygons or any noisy data. License: permissive · Maintenance: dormant · Downloads: 117.3K/mo ## What it is and what it does QuadrilateralFitter solves the problem of extracting a clean four-corner polygon from noisy or irregular shape detections. It takes a polygon defined by any number of points and finds the smallest-area quadrilateral that fully contains all those points, minimizing the Intersection Over Union (IoU) metric. The library wraps shapely, numpy, and scipy to perform the geometric optimization. Typical use is cleaning up detections from computer vision pipelines—such as form boundaries or document corners detected with noise—before applying perspective correction or template matching. You instantiate it with a polygon (as a numpy array, list, tuple, or shapely Polygon), call fit() to get the corners, or access tight_quadrilateral for a tighter fit when some point loss is acceptable. The package includes optional Douglas-Peucker simplification to speed up processing on large convex hulls. Use it for: - Clean up noisy document or form corner detections from image processing before perspective correction. - Extract a four-corner bounding quadrilateral from irregular polygon detections in computer vision pipelines. - Prepare shape data for template matching by fitting a quadrilateral to noisy point cloud input. - Simplify irregular polygons to corners for downstream geometric analysis or pattern recognition. - Reduce noise in polygon data from sensor or detection systems before further processing steps. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Fits the smallest-area quadrilateral that contains all points from a noisy polygon or point cloud, useful for cleaning up irregular detections before perspective correction or pattern matching. Yes, if you need to fit quadrilaterals to noisy polygons or point clouds. The package is lightweight, has no known vulnerabilities, and carries a permissive MIT license. Maintenance is dormant but the code is stable and the dependency set is standard. Install it if your workflow involves cleaning up shape detections; skip it if you need active support or ongoing feature development. ## Install pip install quadrilateral-fitter uv add quadrilateral-fitter poetry add quadrilateral-fitter ## Installing quadrilateral-fitter Before you install: Low friction: pure Python wheel with three common dependencies (shapely, numpy, scipy). Maintenance is dormant—last commit was 2024-08-25—but the package is marked Production/Stable and carries no known vulnerabilities. License in practice: MIT license is permissive: you can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions, provided you include the license notice. Quickstart: pip install quadrilateral-fitter from quadrilateral_fitter import QuadrilateralFitter import numpy as np noisy_polygon = np.array([[x1, y1], [x2, y2], ...]) # Your polygon points fitter = QuadrilateralFitter(polygon=noisy_polygon) fitted_quad = fitter.fit() # Returns tuple of (x, y) corners Verify before relying: - Whether the package works correctly with very large point clouds or whether performance degrades significantly. - How the Douglas-Peucker simplification threshold (default 10) affects accuracy in typical real-world use cases. - Whether the tight_quadrilateral property is suitable as a drop-in replacement when some point loss is acceptable. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 117.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fit quadrilateral to polygon, noisy shape detection cleanup, perspective correction preparation, four-corner polygon fitting, point cloud to quadrilateral, geometry shape approximation, polygon simplification to quad, geometry, computer-vision, shape-fitting [View on SkillFed](https://skillfed.io/packages/quadrilateral-fitter) · [View on PyPI](https://pypi.org/project/quadrilateral-fitter/)