Realtime sudoku solver

using image recognition and backtracking · September 2020

Image recognition

Small proof of concept to learn a few things about image (pre)processing. Take the sudoku in your local newspaper, hold it in front of your webcam and see the solution projected on your image. Cool. Great for lazy people.

How does the magic work? Using OpenCV, I apply some filters on the image to detect the largest blob, which should be the sudoku grid (2-6). Find the edges of the blob, cut it out and rotate into a nice square image of just your sudoku (7). Using the processed black and white version, a neural network figures out the digit in each of the small squares (8). A backtracking algorithm calculates the solution, and we project it on the original stream in realtime (9).