Handwritten Digit Recognition using R



I am using tesseract package in R to read pre printed and handwritten text / digit on the image and then storing those values in R dataframe

Appreciate if you could guide me on the below 2 queries;

  • How do I add specific english words (text on the image) to the tesseract word list and use it in R ?
  • How do i read all the digits handwritten on the image ?

I tried the following function but it is not reading all the numbers

“”“tesseract(options = list(tessedit_char_whitelist = “01234567890”))”"""

Image has been converted to “Grayscale”

Thanks in advance



Why don’t you use Keras package. This package we can not using Generally. For Image recognition I feel you should you keras package.


Thanks. Will explore Keras but any clue about tesseract ?



  1. How do I add specific english words (text on the image) to the tesseract word list and use it in R ?
    Ans: - Use Tesseract Control Parameters from below link


  1. How do i read all the digits handwritten on the image ?
    Ans: May be You need to read one by one image using FOR loop


thanks for the link. It helped however it is somehow not referring to my word list.

Did the configuration as per below link but not working

Now, if you pass the word bazaar as a trailing command line parameter to Tesseract, Tesseract will not bother loading the system dictionary nor the dictionary of frequent words -

tesseract raj_001.jpeg" output --user-words eng.user-words bazaar

Getting below error
Error: unexpected symbol in “text <- tesseract::ocr(“raj_001.jpeg”, conf) bazaar”

Any suggestions ?



After trying out tesseract in R and Google vision APi in Python still handwritten text on the image was not recognized so I need to take your suggestion of using keras as a last option.

I have few questions, appreciate if you could help with it…

  • Do I need to train the model on MNIST database for digits first and then validate the model on the images having handwritten digits ?

  • Do i need to provide actual raw image jpegs as input to the model or pixel values ?

I want to read the text / digits from the image attached herewith. Based on your experience, do you reckon that keras would help ?

Is there a url that I can refer to ?





if you want to recognise this type of Image you need same image with there target variable or you need to break this image in several parts like “back strength” - > back strength(target variable), “115 kg” - > for this you need to train “115 kg” image. So you need to train Images according to your image and your traget variable.

I attached link I hope it will help you for understanding in Image recognition.
In this tutorial model recognising number plate image. So first they train so many number plate images and then they test with new number plate image.


I hope it will help you.


Thanks Prem. Sure, looking at the provided link.


Hi Vashish. I also started working on handwriting recognition with R and facing lot of challenges in doing this. Can you help me please ?


HI Harsh
I would suggest Python over R for it. I have tried using R but it did not give any success.

Also, image resolution plays a major role in handwritten recognition. You might have to do lot of pre processing before putting the image into the model.

Hope this helps


Thank you for getting back. I have absolutely no knowledge of Python but am aware of R hence, R was my preferred approach. Btw do you have a Python code for me to go through and see if I can understand it ?


If you prefer R then i would recommend go through the below url for implementing CNN / Keras in R and MXNET package.

Train your model using keras with backend tenserflow support to recognize handwritten digits / characters that would be best bet.