Home

Awesome

SudoScan

master status Sonar Coverage

develop status

GitHub tag (latest) GitHub license

Scan and Solve Sudoku Puzzles

Project Info

This is a toy project for educational purpose. I usually use this project to explore some JVM/Kotlin libs, new Gradle features/plugins, AI libs and CI pipes (using github actions).

Sudoscan Project

For a more detailed explanation of how the project works, check out the Project Blog.

Project Concepts

The main objective of this project is to use an image of a sudoku puzzle as input, identify the puzzle, recognize the numbers, solve the problem and plot the solution back to the original image.

That been said, the project can be divided in concepts:

Project Modules

The project was broken into the following modules (using java SPI):

Both solvers (choco-solver and ojalgo) are implementations that use different discrete optimizations approaches. To learn more about MIP and CSP approaches on Sudoku problems, take a look at the following Kaggle Notebook.

Both recognizers (dlf4 and djl) are implementations that use a pre-trained model. The model creation and training can be found on the following Kaggle Notebook.

Project Modules Usage

Add the repository

maven {
    name = "SudoscanLibs"
    url = uri("https://pintowar.jfrog.io/artifactory/sudoscan-libs-release")
}

Add api, solver and recognizer the dependencies

implementation("com.github.pintowar:sudoscan-api:x.y.z")
implementation("com.github.pintowar:sudoscan-solver-choco:x.y.z") // or sudoscan-solver-ojalgo
implementation("com.github.pintowar:sudoscan-recognizer-dl4j:x.y.z") // or sudoscan-recognizer-djl

Building Project

To build the fat jar client version of the app, run the following command:

gradle -PjavacppPlatform=linux-x86_64,macosx-x86_64,windows-x86_64 clean assembleCliApp

The command above will build a fat jar containing the native dependencies of all informed platforms. To build a more optimized jar, just inform the desired platform, for instance:

gradle -PjavacppPlatform=linux-x86_64 clean assembleCliApp

This second command will build a smaller jar, but it will run only on linux-x86_64 platforms.

It is also possible to chose in compile time, which solver/recognizer module to use. The commands above (by default) will generate a jar using sudoscan-solver-choco and sudoscan-recognizer-dl4j as the main solver and recognizer. To use sudoscan-solver-ojalgo and sudoscan-recognizer-djl as solver and recognizer components, run the following command:

gradle -Pojalgo -Pdjl -PjavacppPlatform=macosx-x86_64 clean assembleCliApp

Native Image Build

It is also possible to generate a native image of the sudoscan-cli, using a special JVM called the GraalVM.

GraalVM provides this mechanism that helps to create a native image of the application which can be executed as a standalone executable. The build process builds the executable with all the required dependencies such that there is no need the JVM to run the application.

The latest GraalVM version tested was GraalVM CE 21.2.0 (graalvm-21.2.0+java11) which is for Java 11. To build the native image, run the following command on sudoscan-cli module:

gradle -PjavacppPlatform=linux-x86_64 clean nativeCompile