fix(vision): swap corners diagonally for webcam orientation

Webcam images are oriented such that screen positions need to be
swapped diagonally to get the correct physical orientation in the
rectified output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-12-31 17:25:19 -06:00
parent 47088e4850
commit dd8efe379d

View File

@@ -193,16 +193,18 @@ export function rectifyQuadrilateral(
// Source image
srcMat = cv.matFromImageData(imageData)
// Source points (quadrilateral corners) - order: TL, TR, BR, BL
// Source points - swap diagonally for webcam orientation
// Screen topLeft → physical bottomRight, etc.
// Order matches destination: TL, TR, BR, BL (physical/output positions)
srcPoints = cv.matFromArray(4, 1, cv.CV_32FC2, [
corners.topLeft.x,
corners.topLeft.y,
corners.topRight.x,
corners.topRight.y,
corners.bottomRight.x,
corners.bottomRight.y,
corners.bottomRight.y, // screen BR → output TL
corners.bottomLeft.x,
corners.bottomLeft.y,
corners.bottomLeft.y, // screen BL → output TR
corners.topLeft.x,
corners.topLeft.y, // screen TL → output BR
corners.topRight.x,
corners.topRight.y, // screen TR → output BL
])
// Destination points (rectangle corners) - map to standard rectangle