Sudoku Program with Hand gesture
DLIP Final LAB Report
Date: 20-06-2022
Author: 김승환(21600102)
Github link: https://github.com/SH-Kim97/DLIP/tree/main/FinalLAB
Introduction
In this project, I will create a program that detect and solve sudoku puzzle. In this program, user can control sudoku screen with hand gesture and input numbers with fingers. When user inputs 'f' key, solve result and solution are displayed.

1. Flow Chart

Requirement
1. Hardware
Intel Core i5-7300HQ
GTX 1050 Ti
2. Software Installation
Follow the link below to see and install all the requirements
https://ykkim.gitbook.io/dlip/installation-guide/installation-guide-for-deep-learning
Then install Mediapipe, Tensorflow, Keras at py39 in anaconda prompt
(optional, when keras did not installed with tensorflow)
Below list is the overall requirements
Python 3.9.12
Open-cv 4.5.5.64
Numpy 1.21.5
Pytorch 1.9.1
Cudnn 7.6.5
Tensorflow 2.9.1
Keras 2.9.0
Mediapipe 0.8.10
Protobuf 3.19.4
*Copy and paste 4 source codes in the Appendix below with exact same file name
Dataset
Two test sudoku images (1.jpg, 2.jpg)
Download link: https://github.com/murtazahassan/OpenCV-Sudoku-Solver/tree/main/Resources
*Test images must be in the same folder with source codes
Tutorial Procedure
1. Download Pre-Trained Model
For hand detection, use model in Mediapipe module
For sudoku detection, download and use pre-trained model in Keras (myModel.h5)
Download link: https://github.com/murtazahassan/OpenCV-Sudoku-Solver/tree/main/Resources
*Model must be in the same folder with source codes
2. Detect Sudoku and Save Solution
Preprocess the source image
Find contours
Find the biggest contour
Reshape image with the biggest coontour
Detect and save the digits in the sudoku
Solve and save solution

3. Control Sudoku Solving Screen with Hand Gesture (Move Mode)
In this mode, there are 4 hidden buttons(up, down, left, right) on the webcam screen. When the middle point of thumb is on button, the button is activated and user can click by folding index finger.

4. Input Numbers in Original Sudoku (Solve Mode)
In this mode, program detects number of fingers. When the number maintained for 20 frame, the number inputed in the selected position. When user inputs 0, the position is reset.

5. Get Keyboard Input (Mode Change)
When user inputs 'm' key, the mode is changed. One is move mode and the other is solve mode.

6. Get Keyboard Input (Finish Solving)
When user inputs 'f' key to finish solving, solve result and solution are displayed. 'Success!' is displayed when all the digits fit with solution. Otherwise, 'Fail!' is displayed.

Results and Analysis
For the number of fingers and hand gesture detection, it well works 100%
For the sudoku detection, it well works 5~6 times in 10 times with random sudoku image
Reference
https://ykkim.gitbook.io/dlip/installation-guide/installation-guide-for-deep-learning
https://www.computervision.zone/courses/hand-tracking/
https://www.computervision.zone/courses/finger-counter/
https://github.com/murtazahassan/OpenCV-Sudoku-Solver
Appendix
Entire Source Code
[DLIP_FinalLAB_21600102_김승환.py]
[HandTrackingModule.py]
[sudokuMain.py]
[sudokuSolver.py]
Last updated
Was this helpful?