Replace the two-pass closed-form deskew (getPerspectiveTransform + per-axis scale corrections) with an alternating-minimisation loop around cv.findHomography (internal Levenberg–Marquardt). Each outer iteration recomputes per-datum point correspondences from the current H and the datum's shape constraint, then findHomography refines H. Confidence drives per-correspondence replication; primary gets a 3× gauge boost. - Add EllipseDatum type (center + two conjugate semi-axis endpoints + known diameter) with 3-handle Konva rendering and coin presets. - Generalise primary selection to any datum type. Priority rect > ellipse > line; within type, confidence then image size. Warm-start anchors: rect = 4 axis-aligned corners; ellipse = 4 conjugate-axis samples on a world circle; line = 2 endpoints + 2 synthetic perpendicular points (isotropic image-scale assumption). - Direction-agnostic shape residuals: Procrustes-fit ideal (w × h) rect to projected corners; midpoint-preserving line rescale; radial-snap ellipse samples to a circle at projectPoint(H, center). - Drop the "at least one rectangle" requirement. Any datum combination works; diagnostics widgets auto-pick a scale reference across types. - Diagnostics: replace X/Y axis-correction cards with RMS residual + iteration count; per-datum table shows a residual breakdown column (edge %, perp Δ°, iso/skew/dia). - Detect period-2 oscillation in the outer loop and warn to console. - Relative convergence threshold so the affine and perspective entries of H are weighted comparably. - Guard diagnostic diameter via geometric-mean-radius for non-circular conics; guard collinear-axes ellipses; fix Mat leak in solveHomography on the exception path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Skwik
Client-side image deskewing tool. Upload a photo taken at an angle, place reference measurements on known objects, and get a perspective-corrected output with real-world scale.
Everything runs in the browser -- no server, no uploads.
How it works
- Upload a JPG or HEIC image (HEIC is converted automatically)
- Review EXIF data -- camera, lens, focal length
- Place datums on the image -- rectangles or lines with known real-world dimensions
- Run correction -- OpenCV.js computes a perspective transform and outputs a corrected image
The algorithm
The highest-confidence rectangle datum defines the initial perspective correction via getPerspectiveTransform. All other datums (rectangles and lines) are projected through that transform and measured. Per-axis weighted scale corrections are computed from the discrepancies, folded back into the destination rectangle, and a single clean warpPerspective produces the output. One matrix, one warp, no post-hoc distortion.
Datum confidence scores (1--5) act as weights in the correction.
Quick start
pnpm install
pnpm dev
Open http://localhost:5173.
Build
pnpm build # type-check + production build
pnpm preview # serve the build locally
Lint & format
pnpm lint # eslint (strict TS + Vue)
pnpm lint:fix # auto-fix
pnpm format # prettier
pnpm type-check # vue-tsc
Stack
| Layer | Tech |
|---|---|
| Framework | Vue 3 + TypeScript (strict) |
| Build | Vite |
| Components | shadcn-vue + Tailwind CSS v4 |
| Canvas | Konva.js + vue-konva |
| CV | OpenCV.js 4.12 (WASM) |
| HEIC | heic-to |
| EXIF | exifr |
| State | Pinia |
Datum presets
Rectangles: A3, A4, A5, A6, 15x10 cm. Custom dimensions supported. Lines: any length.
How Skwik compares
There are plenty of tools that do part of what Skwik does, but none that combine everything:
| Tool | Client-side | Multi-datum weighting | Real-world mm scale | Measurement tools | Scale bar export |
|---|---|---|---|---|---|
| Skwik | ✅ | ✅ | ✅ | ✅ | ✅ |
| MYOG Perspective Correction | ✅ | ❌ | ✅ | ❌ | ❌ |
| PerspectiveFix | ✅ | ❌ | ❌ | ❌ | ❌ |
| PicFix.pro | ✅ | ❌ | ❌ | ❌ | ❌ |
| ImageOnline Perspective | ✅ | ❌ | ❌ | ❌ | ❌ |
| Toolschimp Image Measure | ✅ | ❌ | ✅ | ✅ | ❌ |
| Aspose Deskew | ❌ | ❌ | ❌ | ❌ | ❌ |
Most deskew tools just pull 4 corners to a rectangle without any real-world dimensions -- the output has no scale. Most measurement tools calibrate against a single reference and don't correct perspective. Skwik uses multiple weighted datums (rectangles + lines, each with a confidence score) to solve both problems in one pass, and lets you measure distances or export with a scale bar on the corrected image.
License
MIT