Liberty BASIC Community Forum
« Neural OCR »

Welcome Guest. Please Login or Register.
Jan 23rd, 2018, 7:32pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Neural OCR  (Read 109 times)
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5618
xx Neural OCR
« Thread started on: Dec 13th, 2017, 2:34pm »

There has been some discussion about neural networks. A practical example appears to be Optical Character Recognition.

So just for fun for the holidays.

Create a 26 node neural net that accepts 72 inputs. It should attempt to recognise lower case a through z

You will need to create the net, train it and then have it assess characters.

In this bare bones code the bitmap character is stored as one long integer. AND the pixel data to see whether the pixel is the same or different.


Code:
'nomainwin
WindowWidth  = 600
WindowHeight = 600
UpperLeftX   = (DisplayWidth-WindowWidth)/2
UpperLeftY   = (DisplayHeight-WindowHeight)/2
graphicbox #1.enc, 10, 10, 10, 11
graphicbox #1.dec, 30, 10, 10, 11
open "Neural Net OCR" for window as #1

'Get the device context
hW=hwnd(#1.enc)
hDC = hDC(hW)

#1 "trapclose [quit]"
#1.enc "down ; font Courier_New 8"
#1.dec "down"

'#1.enc "place 0 7 ;\m"
'#1.enc "set 0 0"
'#1.enc "set 7 0"
'#1.enc "set 0 1"
dim bits(127)

for c= 97 to 122
    #1.enc "cls ; place 0 7 ;\";chr$(c)
    bits=0
    for y=0 to 8
        for x=0 to 7
            col=PixelLong(hDC,x,y)
            if col<16000000 then
                '#1.enc "color black ; set ";x;" ";y
                bits=bits + 2^(y*8+x)
                'print x,y,bits
            else
                '#1.enc "color white ; set ";x;" ";y
            end if
        next
    next
    #1.enc "color black"
    for y=0 to 8
        for x=0 to 7
            if bits and 2^(y*8+x) then
                #1.dec "color black ; set ";x;" ";y
            else
                #1.dec "color white ; set ";x;" ";y
            end if
        next
    next

    bits(c)=bits
next

wait


[quit]
call ReleaseDC hW,hDC
close #1
end



Function PixelLong(hDC, xVar, yVar)
    Open "gdi32"for DLL as #gdi
    CallDLL #gdi, "GetPixel",_
        hDC as Ulong,_
        xVar as Long,_
        yVar as Long,_
        PixelLong as Long
   Close #gdi
End Function

Function hDC(handle)
    CallDLL #user32, "GetDC",_
        handle as Ulong,_
        hDC as Ulong
End Function

Sub ReleaseDC hW, hDC
    CallDLL#user32,"ReleaseDC", _
        hW as Ulong, _
        hDC as Ulong, _
        result as Long
End Sub



 
User IP Logged

tsh73
Moderator
ImageImageImageImageImage


member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: Neural OCR
« Reply #1 on: Dec 13th, 2017, 2:54pm »

I'm completely un-aware of this.
Is it along
https://en.wikipedia.org/wiki/Artificial_neural_network
(EDIT:
https://en.wikipedia.org/wiki/Perceptron
?
)
or is where some introductory text exist?
« Last Edit: Dec 13th, 2017, 3:13pm by tsh73 » User IP Logged

damned Dog in the Manger
tenochtitlanuk
Board Moderator

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1180
xx Re: Neural OCR
« Reply #2 on: Dec 13th, 2017, 5:24pm »

I played with this kind of thing in 2016.
See earlier poasting and also my site

Don't have time at present to play further but will be very interested in any contributions.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5618
xx Re: Neural OCR
« Reply #3 on: Dec 14th, 2017, 02:48am »

Bluatigro has posted once or twice. But his code is very difficult to understand. He puts few words of explanation in and the variables are cryptic. Given his vision this is entirely understandable.

I had not remembered John's work but I thought it might be fun to research and understand neurons/perceptrons a little more and code something.

It is just for fun. So read, research and code what you can.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls