[Solved Sudoku] Chapter VBI-13.   OCR and Sudoku

 

This chapter does not appear in the book.

 

This chapter looks at how to use the webcam for optical character recognition (OCR) while solving Sudoku puzzles. The application is shown in the picture after having analyzed the webcam image on the left, and completed the puzzle on the right.

OCR presents two coding problems it requires a good-quality image (which my old webcam fails to deliver), and OCR functionality isn't part of standard OpenCV.

Tesseract is perhaps the most popular free OCR library, with several Java bindings, including tesjeract and Tess4J. Alternatively, it's easy to call the tesseract command line tool via Java's Runtime.exec() method. However, Sudoku doesn't require the power, flexibility or accuracy of Tesseract, because the Sudoku format is well-defined (a standard grid) and uses a limited range of characters (the digits, 1 to 9). As a consequence, I'll be using the much simpler gocr OCR command line tool.

JavaCV still plays an important role in the application, to improve the webcam image before passing it over to gocr. The improvements include smoothing, adaptive thresholding, contour finding, perspective warping, and flood-filling, which I'll detail later.

 

Downloads


Navigation:


Dr. Andrew Davison
E-mail: ad@fivedots.coe.psu.ac.th
Back to my home page