Lightweight realtime mobile-based computer vision Sudoku solver
Deployed at https://knosmos.github.io/sudontku/
Starting with the raw camera feed, Otsu's adaptive thresholding gives us a binary black-and-white image. After some more preprocessing to clean up the image, we run contour detection and polygon approximation to find candidate board boundary points. We look for the largest square-shaped contour (four edges that are roughly equal in length), and run a homography to correct the perspective distortion. From here, we can split the board into its 81 cells and individually run digit recognition on each of them; this is implemented with template matching. The last step is the easiest: a backtracking algorithm takes the detected board and solves the Sudoku.
My friend is too good at Sudoku. She beat me ten times in a row, so I figured I would try to level the playing field :)
- Camera image capture
- Image preprocessing
- Board detection and perspective transformation
- Template-matching digit recognition
- Sudoku solver
- Clean UI
- Image upload
- Board detection confidence and prompting for manual corner selection