Humm without having an image processing module for PHP installed on the server you will suffer a little, take a look if the place you host has the module Imagemagick, create a phpinfo();
just to check what modules you have installed for your PHP. If the ImageMagick
have available things improve but do not get less complicated.
I can only guide you with the necessary steps, I don’t know if there is something ready, the challenge seems to be more interesting than just copying something from someone, you will need some mathematical knowledge, linear algebra and if you want an algorithm really close to perfection you’ll need neural networks.
Let’s start with the most basic method possible:
- create vectors with the patterns of all letters and numbers, you will need to crop each letter and number, extract the pixels of each one, use Imagemagick if available, store in the way you find convenient (txt, mysql).
- Now you already have the basis for comparison, you will want to compare sentences/texts/words with the extracted patterns, again use if available Imagemagick to crop each letter of your texts, computationally speaking you go comparing horizontally each pixel until you find the beginning and end of each letter, we are talking about something basic here, so 99% of the texts are in black with white background, then walk until the white pixel end mark position and walk until the black pixel end mark position, this will tell you where to crop each letter or number (start and end).
- Perfect cut out the letter of the text, now extracts the pixels from it, as well as in the first step made to build your database.
- Now compare what was extracted from the text with your database, in linear algebra has a concept called
espaço linear
in this case we will have which pixels appear most frequently, it is a simple way that can be used to measural which is the most similar letter.
- Mount each word based on this rank (the larger the cosine returned by linear space the better)
Well there is a basic way to build an OCR with your own hands, without relying on third party modules (except Imagemagick, used here to crop and extract pixels).
Sorry, but then I wouldn’t have to install Tesseractocr on my server? Or call with exec? I don’t have permissions for either. Or I just copy the Tesseractocr "api" folder on my server?
– Marta
@Marta This is a very limiting factor. You can try webservices like Google Docs OCR: https://developers.google.com/google-apps/documents-list/#uploading_documents_using_optical_character_recognition_ocr
– OnoSendai
Thanks @Onosendai. I like my hosting but the difficulty in installing things really has limited me a lot.
– Marta
@Marta, a suggestion, why not hire a cheap VPS (Linode, Digital Ocean or AWS and etc). Implements a service that uses the Tesseract on it (as a Web Service) and uses from your current hosting?
– Wakim
I looked into it and I think it will be the case. Thank you.
– Marta
@Marta good luck - and feel at ease in case of any doubt.
– OnoSendai