Card Detection
A webcam prototype that detects multiple playing cards, straightens angled frames and identifies a captured six-card set with ORB feature matching.

Playing cards make a compact computer-vision problem: the camera has to separate each white rectangle from the table, handle rotation and glare, then decide whether the card matches anything it has seen before. A weak matcher will confidently assign the wrong name to every unfamiliar card.
I split detection from recognition. Contour analysis finds convex quadrilaterals and a perspective transform flattens each one to the same size. I capture reference images from the deck, cache their ORB descriptors at startup and require both a minimum score and a clear margin over the next candidate before showing a name.
Contour detection and perspective correction
Filters the threshold mask by area, shape, aspect ratio and convexity, then warps each detected card into a consistent 300 × 420 image.
ORB matching with rejection
Compares cached binary descriptors with Hamming distance and Lowe’s ratio test. Weak or ambiguous results stay labeled Unknown.
Capture and debug tools
Builds templates from the webcam, labels every live contour and exposes the threshold mask plus normalized crops for tuning and saved evidence.
Most of the improvement came from making the inputs consistent. Once each contour was ordered, flattened and resized the same way, ORB had a fair comparison to make. The rejection threshold mattered just as much: admitting uncertainty is better than attaching a confident wrong label.


