Sudoku Solver AI with OpenCV

We will be creating a Sudoku Solver AI using python and Open CV to read a Sudoku puzzle from an image and solving it. There a lot of methods to achieve this goal. Thus in this series, I have compiled the best methods I could find/research along with some hacks/tricks I learned along the way.

This article is a part of the series Sudoku Solver AI with OpenCV.

Part 1: Image Processing

Part 2: Sudoku and Cell Extraction

Part 3: Solving the Sudoku

Image for post

Before and End of Part 2: Left and right respectively

Steps

  1. Import the image
  2. Pre Processing the Image
  3. 2.1** Gaussian blur:** We need to gaussian blur the image to reduce noise in thresholding algorithm
  4. 2.2 **Thresholding: **Segmenting the regions of the image
  5. 2.3 Dilating the image: In cases like noise removal, erosion is followed by dilation.
  6. Sudoku Extraction
  7. 3.1** Find Contours**
  8. 3.2** Find Corners: **Using Ramer Doughlas Peucker algorithm / approxPolyDPfor finding corners
  9. 3.3 **Crop and Warp Image: **We remove all the elements in the image except the sudoku
  10. 3.4 Extract Cells
  11. Interpreting the Digits
  12. 4.1 Import the libraries and load the dataset
  13. 4.2** Preprocess the data**
  14. 4.3** Creating the Model**
  15. 4.4 Predicting the digits
  16. Solving the Sudoku

#deep-learning #python #sudoku-solver #ai #opencv

Part 3: Solving the Sudoku
5.75 GEEK