ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - pintowar/sudoscan: Scans and solves Sudoku Puzzles from images using AI
Scans and solves Sudoku Puzzles from images using AI - pintowar/sudoscan
Visit Site

GitHub - pintowar/sudoscan: Scans and solves Sudoku Puzzles from images using AI

GitHub - pintowar/sudoscan: Scans and solves Sudoku Puzzles from images using AI

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:

  • Parser/Plotter: computer vision components responsible the read/write information from/to an image;
  • Recognizer: responsible to recognize the number images and translate it into an integer;
  • Solver: responsible to effectively solve the sudoku puzzle;
  • Engine: a pipe that glues all above components together to achieve the main objective of the project.

Project Modules

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

  • sudoscan-api: module containing domain classes, spi for solvers and recognizers and main engine.
  • sudoscan-solver-choco: module containing a spi implementation using choco solver (a CSP solver) to solve to find the sudoku solution;
  • sudoscan-solver-ojalgo: module containing a spi implementation using ojAlgo (a MIP solver) to solve to find the sudoku solution;
  • sudoscan-recognizer-djl: module containing a spi implementation using djl (a deep learning framework) to recognize numeric images;
  • sudoscan-recognizer-dl4j: module containing a spi implementation using dl4j (a deep learning framework) to recognize numeric images (this is the default recognizer);
  • sudoscan-cli: cli application using other modules to solve sudoku problems using a webcam as user interface.

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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory