Showing posts with label computer vision. Show all posts
Showing posts with label computer vision. Show all posts

Sunday, 11 January 2015

Programming - Elite Dangerous Tools - OCR Pt 2

Update: You can now support this project at Patreon!


Some progress with the OCR I'm implementing, I've now broken the black and white filtered image down into rows, and then each row into the characters, and then I've looked and analysed where the gaps are between characters and decided where the columns are....


So here we see my pattern matching (simple pattern matching - not a neural network) reading through the characters and building the words for column 1, which is the name of the commodity...

As you can see it is working quite well... I need to keep training the pattern matching weights more, and this is very memory intensive (it takes over 300MB of data to process the various images, sub images, patterns and pixel values I'm summing & weighing against one another).

The biggest stumbling blocks is that the sourcing of the images from the client is very user dependent and twitchy, there are rules for it and ways for the user to capture the image in order and with the best overlap to help the stitching algorithms.

But this is the first pass of this tool, this is for me, to help capture and use market data personally... When I've collected a bunch of such data I may see if there are interested parties in helping collect more and more data.

Until then however, keep yourselves informed by popping back to the blog from time to time, and as ever let me know if you would use a tool like this!  Or even sponsor me to develop it further!

Friday, 12 December 2014

Programming - Elite Dangerous Tools - Sobel Edge Detection (with Full Code)

Update: You can now support this project at Patreon!

Forearmed with our greyscale code we can therefore look at the Sobel mask to give us a nice crisp delimitation between the background and the text on our screen shots... Lets say we capture the top half of the market prices screen upon landing... We can capture the screen shot, convert to grey scale and then sun the sobel mask over the pixels to give a crisper showing of the text for our later OCR work...

There are many explanations of how Sobel Operations work, however they are very mathematical... Simply put we have each pixel (except the ones in the edge) value and for it and each neighbour we apply a mask... Lets draw some simple pictures....

Below we see the grid of pixels in our image...
Each pixel is made up of a value for Red, Green and Blue, but because the image is greyscale all three of these values are the same number, so we can just take one of them...
Next in code we need two masks, these are 3 x 3 grids of numbers, these values in the grid are applied to each pixel, except the edge pixels in our image.












So, from 1 until 1 less than the width, from 1 until 1 less than the height... Sliding the middle of the mask over the pixel target we then apply the mask to each pixel value around and including the pixel.

So we calculate and sum these values writing them into the resulting same pixel location on the end result image...
Saving the image result we see the edges of the shapes within highlighted...


Find the full code here and the previous step code for greyscale here.