Giter VIP home page Giter VIP logo

sudokuextract's Introduction

SudokuExtract

Library for extracting Sudokus from images using scikit-image.

This package is, and will continue to be, unmaintained. It has been removed from PyPI, but will be available for installation from this archived repo instead.

Requirements

  • numpy>=1.9.2
  • scipy>=0.15.1
  • scikit-image<0.12.0
  • Pillow>=3.1.0
  • pyefd>=0.1.2
  • dlxsudoku>=0.10.0

Usage

Install via pip:

$ pip install sudokuextract

SudokuExtract is a tool for parsing Sudokus from images, this primarily to be able to send it forward to some kind of solver. It applies some image analysis on the input image and then uses a K-Nearest Neighbours classifier to determine which digits that are present in which box.

SudokuExtract can be used as a command line tool:

parse-sudoku -p /path/to/sudoku_image.jpg

which prints the parsed Sudoku in the terminal. In can also be called with an url to an image:

parse-sudoku -u http://www.domain.com/sudoku.jpg

It can also be used as a regular Python package:

In [1]: from sudokuextract.extract import extract_sudoku, load_image, predictions_to_suduko_string

In [2]: img = load_image('/path/to/sudoku_image.jpg')

In [3]: predictions, sudoku_box_images, whole_sudoku_image = extract_sudoku(img)

In [4]: print(predictions_to_suduko_string(predictions))
800603001
057401630
000000000
006109800
400000007
001805400
000000000
072504310
900302004

There are possibilities of using a classifier of your own creation when predicting digits; see the documentation for more details.

Testing

Run tests with pytest:

$ py.test tests.py

Documentation

TBD.

References

This library includes classifiers trained with data from the MNIST dataset (This data is also included in SudokuExtract).

[1] LeCun et al. (1999): The MNIST Dataset Of Handwritten Digits

The current parsing strategy for the sudokuextract package is inspired by this blog entry:

[2] AI: SuDoKu Grabber with OpenCV

sudokuextract's People

Contributors

hbldh avatar s-raza avatar

Stargazers

Ian Dow-Wright avatar  avatar İlker Yasin AKSOY avatar Utkarsh Sinha avatar Yusuke FURUKAWA avatar  avatar

Watchers

 avatar  avatar

Forkers

kami83 s-raza

sudokuextract's Issues

Error during install

Hello. I'm trying to install this package but I get this error during install of scikit-image

Collecting scikit-image<0.12.0 (from sudokuextract)
  Downloading https://files.pythonhosted.org/packages/02/67/7f44f79b981413d72ffe505c3fa06f9d0c20a2ad944503bf7395deb7930d/scikit-image-0.11.3.tar.gz (18.6MB)
    100% |████████████████████████████████| 18.6MB 86kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-Nf3Z8M/scikit-image/setup.py", line 77, in <module>
        import scipy
    ImportError: No module named scipy
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-Nf3Z8M/scikit-image/

How can I solve?

TypeError: The numpy boolean negative, the `-` operator, is not supported, use the `~` operator or the logical_not function instead

I encountered the below error, on my first run after installing sudokoextract through pip. The error is fixed by replacing "-" with "~" in the source code. I will be creating a pull request with a reference to this issue.

$parse-sudoku -p sudoku1.jpg
Traceback (most recent call last):
File "/opt/progs/py2venv-2/bin/parse-sudoku", line 8, in
sys.exit(main())
File "/opt/progs/py2venv-2/local/lib/python2.7/site-packages/sudokuextract/extract.py", line 63, in main
preds, images, subimage = extract_sudoku(image)
File "/opt/progs/py2venv-2/local/lib/python2.7/site-packages/sudokuextract/extract.py", line 33, in extract_sudoku
predictions, sudoku_box_images, subimage = method(image, classifier)
File "/opt/progs/py2venv-2/local/lib/python2.7/site-packages/sudokuextract/methods/map.py", line 31, in extraction_method_map
for sudoku, subimage in _extraction_iterator_map(image, use_local_thresholding, apply_gaussian, n=n):
File "/opt/progs/py2venv-2/local/lib/python2.7/site-packages/sudokuextract/methods/map.py", line 60, in _extraction_iterator_map
for edges in iter_blob_contours(img, n=n):
File "/opt/progs/py2venv-2/local/lib/python2.7/site-packages/sudokuextract/imgproc/blob.py", line 51, in iter_blob_contours
bimg = (-binary_erosion(bimg))
TypeError: The numpy boolean negative, the - operator, is not supported, use the ~ operator or the logical_not function instead.
$python --version
Python 2.7.15+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.