Solving sudoku with Scala, JavaCV (Image processing) and DeepLearning4j (OCR)
- Loading image from file in greyscale
- Using
Cannyfor edge detection - Find largest contour among detected edges. We assume that sudoku grid will be the biggest object on the image
- Compute bounding rectangle and apply a perspective transformation to an image
- Apply
adaptiveTheshold(image will become binary) - Split image in 81 cell
- Filter cells, so that only those containing digits left
- Resize each cell image
- Pass each cell to neural network (2-layer MLP with
AdamandNegativeLogLikelihood) for digit recognition - Solving sudoku with
Constraint propagation, afterward if not solved yet withBacktrackingas described here
