Solve hand drawing sudoku by OpenCV and image processing
To solve hand drawing sudoku, need to perform the following steps:
- Step 1: Crop sudoku cells out of the image by looking straight and horizontal lines
- Step 2: Find the numbers and identify by handwriting library
- Step 3: Solve the sudoku box by the shallow method
Step 1: Crop sudoku cells out of the image by looking for horizontal and vertical lines
Pictures are taken as examples of pencil drawings on A4 paper. The first is to load the image

Convert the image to a black-and-white image and reverse the image color, since the Houghline algorithm only looks for pixels with a value of 1 (white).


Bold the lines because there may be some lines too thin

Làm đậm các đường kẻ vì có thể 1 số đường mỏng quá


Find the largest blob and color 255 for it, the other blobs fill 64 (blob is the set of pixels with the same value adjacent). So sudoku is the biggest blob

Delete the blobs with a value of 64, leaving only a blob of 255


Find all the lines in the picture

Retain the horizontal or vertical line, thus requiring the input image not to be distorted. If the image is distorted, there is another way to do it.


Then crop the image based on the intersection of the lines, so that step 1


Step 2: Find the numbers and identify by handwriting library
Crop photos into 81 squares, divided into crop and crop

Use SVM to identify characters. At the end of the article is a source containing a set of training SVM data.
Step 3: Solve the sudoku box by the shallow method
This step does not need to explain because there are many on the Internet, and not related to image processing.
Conclude
Conclude
Conclusion:
This is a simple method of processing images with less distortion, less noise. For complex sudoku cells there will be other processing methods.
Source Code:
Source Code:
Solve hand drawing sudoku by OpenCV and image processing
Reviewed by Jacky
on
December 10, 2017
Rating:

No comments: