4459

Evaluate the suitability and performance of the MAX78000 for a vehicle license plate recognition application

Having dabbled on the fringes of AI a couple of times in the past I was kind of waiting for the field to get a bit more user-friendly before diving fully in. It hasn't got there yet but maybe this new Maxim chip would be a good place to start. I had already developed Python code for a largely non-AI automatic number plate reader, (http://www.marvellconsultants.co.uk/ANPR) it works extremely well but is a bit slow, maybe a dose of AI could help speed it up?  I'd tried AI-based ANPRs before and found them to be pretty hopeless frankly but as I was lucky enough to receive a free MAX78000FTHR kit from Elektor I decided to re-investigate the application of modern AI to my existing ANPR code.
The MAX78000FTHR kit comes with a speech recognition demo pre-loaded, it fired up and worked impressively well straight out of the box. Although it's certainly not able to recognise naturally-spoken multi-digit numbers, if you enunciate clearly and leave gaps between words it maybe gets 90% correct..
Maxim provides an eclipse-based SDK by way of software development support, again after some false starts and head-scratching I was able to successfully work my way through some of the CNN examples - despite the very poor documentation. Thank you Elektor for providing some very helpful material on getting started with the MAX78000FTHR.
Now to my particular interest, the character recognition example: mnist.  I first make a copy of c:\MaximSDK\Examples\MAX78000\CNN\mnist in C:\users\\eclipse-workspace\ then from the IDE I use File -> Import -> General -> 'Existing projects in to workspace' option to load the copied mnist project into the IDE workspace. Now make the obligatory changes to the makefile and to the mnist -> properties -> 'C/C++ Build' -> 'Build command' text box, click the hammer and run buttons. The compilation, build & download proceed smoothly and the serial console soon reveals the expected result. The CNN has scanned the pre-loaded 28px x 28px x 8bit bit-map and matched it to a 7.
Next step is to present it with some bitmaps of my own to see how well it recognises uk number-plate digits.  I have a database of several thousand images of UK number-plates each with an accurate reading. I chose a couple of easy ones to start with: straight and level undistorted characters with good focus and contrast, low noise and no motion blur. I scaled them down to 28 pixels in height (to match the mnist demo requirements) whilst maintaining correct aspect ratio, converted to monochrome and took a 28 horizontal pixel extract centered on three numerical digits: a "7" a "6" and a "9". I then wrote a python script to convert the tiny image to a list of 196 32bit hex numbers suitable to swap out the sample data in the demo code's sampledata.h file. Note that it's necessary to subtract 128 from each pixel's gray-level value to make the data compatible with the demo's CNN. I made sure I got this right by also writing a python script to take the 196 32bit hex values and doing the reverse process to generate a viewable PNG file. This worked perfectly with the demo code's original sample data of a "7" digit. It's also necessary to remove the call to the "check_output()" function from mnist's main.c as this is only pertinent to the built-in sample. I've added the bitmap2viewer python script  (including four sample bitmaps) to this project.

The first test went very well, my "7" sample image was recognised with 100% confidence. However the "6" and the "9" were both recognised as "8" with 55% confidence. This was very disappointing, my hope was that the digits 0 to 9 from even poor quality source material would all be recognised perfectly. Even then I would have to re-train the net to recognise A..Z digits in addition. Maybe now I would need to re-train for 0-9 and A-Z?
It was then that I came across this article written by an AI pro: http://karpathy.github.io/2019/04/25/recipe/
I understood enough of it to know that unless I wanted to spend the next year of life getting deeply into the technicalities of AI then the smart course of action would be to give up now and do something else! I would therefore urge anyone currently thinking of experimenting with AI to read the above article first and then think again - this is not a field for the amateur.  Any AI pros reading this will I'm sure agree, but I have a proposition to any such person: collaborate with me and my data-set to get a CNN trained to read UK number plates running on the MAX78000 - that would be cool.