{"id":22736571,"url":"https://github.com/fredwangwang/webcam-sudoku-solver","last_synced_at":"2026-05-02T05:43:42.707Z","repository":{"id":45625460,"uuid":"109195585","full_name":"fredwangwang/webcam-sudoku-solver","owner":"fredwangwang","description":"A realtime webcam sudoku solver.","archived":false,"fork":false,"pushed_at":"2021-12-04T05:24:34.000Z","size":1361,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T14:11:55.921Z","etag":null,"topics":["opencv","python","sudoku-solver","z3-smt-solver"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fredwangwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-01T23:38:36.000Z","updated_at":"2022-08-06T12:48:18.000Z","dependencies_parsed_at":"2022-09-10T23:12:38.912Z","dependency_job_id":null,"html_url":"https://github.com/fredwangwang/webcam-sudoku-solver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fredwangwang/webcam-sudoku-solver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fwebcam-sudoku-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fwebcam-sudoku-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fwebcam-sudoku-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fwebcam-sudoku-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredwangwang","download_url":"https://codeload.github.com/fredwangwang/webcam-sudoku-solver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwangwang%2Fwebcam-sudoku-solver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32524565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","python","sudoku-solver","z3-smt-solver"],"created_at":"2024-12-10T21:27:45.333Z","updated_at":"2026-05-02T05:43:42.662Z","avatar_url":"https://github.com/fredwangwang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webcam-sudoku-solver\n\n## Introduction\nThis is a project mainly to explore OpenCV. Since I don't know how to play sudoku at all, it would be nice if I could create something that can do it for me. Here it is.\n\n## How to run\n### Install dependencies\nMake sure you have Python 2.7. __Does not__ work with Python 3.\n```\npip install -r requirements.txt\n```\nThat should bring you all the dependencies.\n\n### Train the neural network model\n```\ncd src\npython nn_train.py\n```\nThis takes a while. I am using a simple NN to do the digit recognition. The result is not quite satisfactory. So here is a __TODO__. \n\n### Execute the program\n```\npython main.py\n```\n\n## How does it work\nFirst thing is of course get the video buffer from the camera, like this: \n\n![raw](./picture/raw.jpg)\n\nThen extract the contours, try to find a sudoku board. If a qualified square contour is found, project it as an orthophoto, and do some pre-processing to it. \n\n![ortho_bw](./picture/ortho_bw.png)\n\nAfter successfully extract the board, run Hough line transformation on it. If everything goes right, effectively each cell is determined. Then we can do the digit recognition on each cell. Empty cells are denoted as 0. \n\n![ortho_raw](./picture/ortho_raw.png)\n\nOnce we have a grid of digits, we can use the solver to solve it! In this project, a [Z3](https://github.com/Z3Prover/z3) solver is used. Basically model the problem as a CSP, then Z3 can give the arrangment efficiently. Which bring us to the final result: \n\n![result](./picture/projected_raw.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwangwang%2Fwebcam-sudoku-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredwangwang%2Fwebcam-sudoku-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwangwang%2Fwebcam-sudoku-solver/lists"}