quadrilateral-fitter
QuadrilateralFitter is an efficient and easy-to-use Python library for fitting irregular quadrilaterals from irregular polygons or any noisy data.
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 on this page — 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
quadrilateral-fitter on PyPI
pip
pip install quadrilateral-fitteruv
uv add quadrilateral-fitterpoetry
poetry add quadrilateral-fitterInstalling 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 the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — shapely, numpy, scipy |
| Maintenance | dormant — 716 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 117,330/month — #12,167 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: quadrilateral_fitter-1.12-py3-none-any.whl
Keywords: quadrilateral, fitter, polygon, shape analysis, geometry
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
qrdetDetects and segments QR codes in images using a…
permissive · top 15,000 on PyPI
rectangle-packerPacks a set of rectangles with fixed…
permissive · top 15,000 on PyPI
antimeridianFixes Shapely geometries and GeoJSON features…
permissive · top 15,000 on PyPI
mapbox-earcutFast 2D polygon triangulation using the Mapbox…
permissive · top 5,000 on PyPI
shapely-polyskelComputes the straight skeleton of a polygon, a…
copyleft · top 15,000 on PyPI
bermudaProvides Rust-accelerated triangulation…
permissive · top 15,000 on PyPI
shapelyShapely provides Python tools for creating,…
permissive · top 1,000 on PyPI
piecewise-regressionFits piecewise linear regression models to data…
permissive · top 15,000 on PyPI
lmfitLmfit provides non-linear least-squares…
permissive · top 5,000 on PyPI
pypcd4pypcd4 reads, writes, and manipulates Point…
permissive · top 15,000 on PyPI