Hmm 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 have installed for your PHP. If ImageMagick
is available things improve but they do not get any less complicated.
I can only guide you with the necessary steps, I do not know if something is ready, the challenge seems to be more interesting than simply copying something from someone, you will need some mathematical knowledge, linear algebra and if you want a really close algorithm of perfection will need neural networks.
Let's start with the most basic method possible:
- Create vectors with the patterns of all letters and numbers, you'll need to cut out each letter and number, extract the pixels of each, use ImageMagick if available, store as you see fit (txt, mysql).
- Now you already have the basis for comparison, you will want to compare sentences / texts / words with the extracted patterns, once again use ImageMagick to cut out each letter of your texts, computationally speaking you will be comparing each pixel horizontally until we 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, so walk until the white pixel finish mark the position and walk until the black pixel finish mark the position, this will tell you where to cut each letter or number (start and end).
- Perfect trimmed the letter of the text, now extract the pixels of it, as well as the first step to build your bank.
- 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 more frequently, it is a simple way that can be used to mensural which is the most similar letter.
- Assemble each word based on this rank (the higher the cosine returned by the better linear space)
Well here's a basic way to build an OCR with your own hands, without relying on third-party modules (except for ImageMagick, used here to crop and extract pixels).