DEV Community

Cover image for Image to Text [OCR/Python]

Image to Text [OCR/Python]

woosal profile image Vusal Ismayilov ・2 min read

It might sound kind of impossible, which probably is, at least for now to access the backend of MODDLE, however, nothing really stops us to use the current technologies that we own, which is being improved day-by-day and apply it on the frontend to abuse the MOODLE's blocked copy the question option.

Let me get it straight, in order to get whatever you want to copy, either you have to have an access to the website's codes (inspect elements is an option), or you have to use another logic and algorithm to copy the what you want to copy. In this article I will talk about how to apply a simple practical application of simple deep learning model on our project in order to copy the text from anywhere we want (MOODLE is just one of them). 

I have simplifed the code as much as possible, where all you have to do right now is just specify the area you want to copy through the code, and let the rest of the code work on it and return you the text in a string formatted output, where all you have to is just use it.


The general algorithm is based on the Google's provided above average OCR model, called as, Teserract. In the current project, I will be using the Python version of this model, however, the whole model is written in C++. You probably already understand what is expecting you in the rest of the article if you have ever heard of what is an OCR is, or anytime in your life experienced anything related with the Machine Learning/ Deep Learning/AI etc. OCR originally stands for "Optical Character Recognition", about which you can learn more by clicking here.

So, the logic is that, the code does already provide you with getting your custom screenshot, so all you have to do is to take a reasonable screenshot, and the model provided by Google will go over the screenshot, which you just got, and work on the image, and return you the final text in a string format throughout the terminal.

There is still a lot of features to be added, and will be by the time. If you have any suggestions, or implementations, let me know over GitHub, or any other social media, or email.

Source Code (GitHub):



Editor guide