{"id":17447849,"url":"https://github.com/benng/sudoku-recognizer","last_synced_at":"2025-08-30T18:31:10.269Z","repository":{"id":89073164,"uuid":"76441856","full_name":"BenNG/sudoku-recognizer","owner":"BenNG","description":"Grab sudoku info with computer vision","archived":false,"fork":false,"pushed_at":"2019-02-14T13:13:39.000Z","size":49788,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-15T19:47:00.211Z","etag":null,"topics":["opencv","puzzle","recognizer","sudoku"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenNG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-14T08:54:06.000Z","updated_at":"2024-05-06T06:58:52.000Z","dependencies_parsed_at":"2023-06-13T19:30:35.206Z","dependency_job_id":null,"html_url":"https://github.com/BenNG/sudoku-recognizer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenNG%2Fsudoku-recognizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenNG%2Fsudoku-recognizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenNG%2Fsudoku-recognizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenNG%2Fsudoku-recognizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenNG","download_url":"https://codeload.github.com/BenNG/sudoku-recognizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231515080,"owners_count":18388407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opencv","puzzle","recognizer","sudoku"],"created_at":"2024-10-17T19:54:24.479Z","updated_at":"2024-12-27T16:58:29.366Z","avatar_url":"https://github.com/BenNG.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sudoku-recognizer\n\n## Requirement\n\n- CMake [[sources](https://cmake.org/)]\n- Boost v.1.58.0 (test only) [[sources]](http://www.boost.org/users/history/version_1_58_0.html)\n  - ./bootstrap.sh --with-libraries=test\n  - ./b2\n  - sudo ./b2 install\n- OpenCV 3.2.0 [[install](https://docs.opencv.org/3.2.0/d7/d9f/tutorial_linux_install.html)] [[more info](https://docs.opencv.org/3.2.0/df/d65/tutorial_table_of_content_introduction.html)]\n  - build for desktop application\n    - Download, extract and get yourself inside the sources of OpenCV 3.1.0 and create a `build` folder. Then:\n    ```\n    cd build\n    # CMAKE_BUILD_TYPE could either \"Release\" or \"Debug\".\n    # WITH_OPENCL The usage of OpenCL is a big improvement in terms of performance but you don't have to worry about it if you system has support you got it for free. On ubuntu I had to install\n    sudo apt-get install opencl-headers beignet beignet-dev\n    cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_OPENCL=ON -DENABLE_PRECOMPILED_HEADERS=OFF ..\n    make -j4\n    sudo make install\n    ```\n  - build for android application [here](http://answers.opencv.org/question/126795/build-opencv-31-for-android-with-opencl-support/)\n\n## Useful information\n\nNote that all the commands have to be invoked in the `build` folder. The first time you have to create it.\n\n```\nmkdir build \u0026\u0026 cd build\n```\n\n## Recognizer\n\n![hhh.gif](https://bitbucket.org/repo/zpnRyB/images/276570042-sudoku4.gif)\n\n### Tests\n\nOnce you have installed all the requirements, execute the tests to see if everything is OK\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026  ctest -V\n```\n\n### Parse one of the provided puzzle located in `assets/puzzles`\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/recognize ./../assets/puzzles/s1.jpg\n```\n\n### Tools that can help you during the development process\n\n#### Show all extracted puzzles located in `assets/puzzles`\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted\n```\n\n![eee.gif](https://bitbucket.org/repo/njp6xM/images/4118982265-eee.gif)\n\n#### Show all extracted cells for `assets/puzzles/s33.jpg`\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted --puzzleNumber 33 --showCell\n```\n\n![fff.gif](https://bitbucket.org/repo/njp6xM/images/1253348601-fff.gif)\n\n#### Other actions\n\n##### will show all extracted puzzles\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted\n```\n\n##### will show all extracted cells\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted --showCell\n```\n\n##### will show the extracted puzzle: `assets/puzzles/s33.jpg`\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted --puzzleNumber 33\n```\n\n##### will show the cell index: 10 of `assets/puzzles/s33.jpg`\n\n```\n## useful in situation where only cell number 40 is wrong\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted --puzzleNumber 33 --showCell --cellNumber 10\n```\n\n##### will show the cell index: 10 of `assets/puzzles/s33.jpg` plus the process of extraction\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/showExtracted --puzzleNumber 33 --showCell --cellNumber 10 --debug\n```\n\n### Create the `assets/raw-features.yml` yourself\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/prepareData # create training data from s0 --\u003e s35\n```\n\n- The knn network can be tested using this:\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/testKnn\n```\n\n\u003e You can iterate over each picture by setting debug=true in the `testKnn` fn\n\n## The whole process\n\n```\ncmake .. \u0026\u0026 make \u0026\u0026 src/mouline ./../assets/puzzles/s0.jpg\n```\n\n![iii.gif](https://bitbucket.org/repo/njp6xM/images/1534426116-iii.gif)\n\nAll the hard work was to recognize the numbers that's why this part comes after the `Recognizer` even if obviously this is what people want to do.\nA [mouline](https://github.com/BenNG/sudoku-recognizer/blob/master/src/lib/sudoku.cpp#L1743) function has been created that gather all other functions.\nSo the process is:\n\n- parse the original image that holds the sudoku puzzle and extract it\n- parse the extracted puzzle and use a computer vision algorithm to grab the initial state.\n- Solve the sudoku\n- write the solution on the extracted puzzle\n- merge the extracted puzzle on the original picture\n\n## Tips (Personal memo)\n\n- There are 2 extraction process\n  - the extraction of the puzzle\n  - the extraction of the grid within the puzzle (somethimes it is the same see s6.jpg)\n- If you want to play with `HOGDescriptor` add set(OpenCV_LIBS opencv_core opencv_objdetect) (this is not used in the project anymore)\n- The function `prepareData` creates `assets/raw-features.yml` and getKnn uses it\n- boost library (used only for test)\n- check is the /FindBoost.cmake the supported version (the lib is not used anymore because it is not possible to use it on android)\n- If you ask for a cell and you have an error chances are that your cell is a 1 and it is too tiny go to extractNumber and play with (and do not forget to run prepareData \u0026\u0026 test after)\n  - area\n  - boundingArea\n  - width_threshold\n  - height_threshold\n- Before the portage on android, I used a system for resolving the path of file that looked for the root of the project and join the path given but in a apk application\n  there are no path so I had to rewrite all and use relative paths\n- adding curl to the project (not use anymore)\n  - dl the source code [here](https://github.com/curl/curl/releases)\n  - in the source code there is a `CMakeLists.txt` so:\n    - cmake .\n    - make\n    - sudo make install\n  - [then](https://github.com/BenNG/sudoku-recognizer/blob/2f30e4dc54620b646df8a97a8ec5651a171c3e56/src/CMakeLists.txt#L1)\n  - [and](https://github.com/BenNG/sudoku-recognizer/blob/2f30e4dc54620b646df8a97a8ec5651a171c3e56/src/CMakeLists.txt#L31)\n- When you do a project using computer vision think about the resolution you will use for:\n  - the camera\n  - the image being processed by the algorithm\n\n## Thank you for answering my questions\n\n- [Berak](http://answers.opencv.org/users/2130/berak/)\n- [Baptiste Wicht](https://github.com/wichtounet/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenng%2Fsudoku-recognizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenng%2Fsudoku-recognizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenng%2Fsudoku-recognizer/lists"}