How to Train Your AI
For image recognition, I used a popular computer vision library called OpenCV. The amount of resources I could find for beginner OpenCV tutorials using C++ rather than Python were limited, but in the end I managed to find a tutorial for character recognition which I was able to adapt and use for the project.
The training works by giving an input image containing many hand-drawn variations of each symbol. The program will then go over all the symbols in the image and ask what character it should be associated with. The user can then press a key to associate with the symbol. For example, the moon symbol is associated with the “c” key, and the slash symbol is associated with the “-” key. When the training is complete, it saves the data to an .xml file. You can then feed your drawn symbol into the image recognition function, which will use the generated .xml file to look up which character it resembles the closest.
While it was very easy to get into the project and it gets the job done, I realized shortly after that the image recognition is not very accurate. This is because the kNN classifier that was used in the tutorial is not suitable for OCR (optical character recognition). A much more commonly used classifier for OCR development is the SVM classifier. Although it was very daunting because I had no experience with using OpenCV and I would have to modify the original tutorial code, I still wanted to give it a shot. I wasn’t confident that I would succeed, but I thought I would at least learn something valuable.
As I struggled with finding resources online for practical SVM applications, I got very worried that I would not be able to make the switch. However, OpenAI’s ChatGPT actually ended up being an invaluable help and guided me every step of the way. I am so thankful for this incredible tool being accessible for all developers for free. After a full day of debugging together, we finally succeeded with switching the kNN classifier out for SVM, and the result was immediately noticeable! It is much more consistently accurate, and the performance is improved as well.