Drivers License Detection and PHP Source

  • Last Post 31 October 2018 posted this 24 October 2018

What are the specific changes to make to the PHP source code for drivers license detection. Right now it is returning a bunch of nonsense, and unusable data. I can see some of the data that is on the license but it is really not parsable.



Oksana S. posted this 31 October 2018

The general idea for your scenario could be the following:

1) Use the processImage method and export the recognized text to the XML format (with information about all found text blocks, their coordinates and values, etc.). The recognized text is presented in proper hierarchy: document > page > block > region > etc. Please see the Output XML Document article for detailed description of the XML output.

2) Apply some post-processing to this XML file to extract needed data on your side. As the XML output also includes the coordinates of each element, you can parse the words by coordinates and extract the necessary data from the output. The basic idea is that the field value and the field name would be close to each other in a document. Therefore, you could, for example, search the XML for the keywords like the field names, get those keywords’ coordinates and then find other text blocks with the field values situated somewhere near those keywords (right below them, on the same level to the right, etc.). If you need to find the words from one line, you can use the baseline coordinate of the words. If the baseline coordinates are close, the words are from the same line.

Or you can also use the field-level recognition (where the text coordinates are specified directly). This approach is reasonable especially if you know information about the structure of the card.

Moreover we have the processMRZ method for extracting MRZ data from different identity documents. Hope this method will be also useful for your scenario.