NMAC427 / SwiftOCR

Fast and simple OCR library written in Swift
Apache License 2.0
4.62k stars 480 forks source link

Add ability to choose character set for recognition #126

Closed skelet2394 closed 6 years ago

skelet2394 commented 6 years ago

I dont really know how this magic works, but as i understand, there is a possibility array for each symbol it found. I often get "B" instead of "3". So i propose to make an ability to choose between character sets, so when it thinks that its 95% "B" and 90% "3" its gonna choose "3" instead of "B" Maybe you will add this in TODO list

siobhandougall commented 6 years ago

If you're only limiting the character set, you can use the characterBlackList and characterWhiteList properties, which work as advertised. For example:

        let ocr = SwiftOCR()
        ocr.characterWhiteList = "1234567890"
        ocr.recognize(ocrImage) { string in
            print(string)
        }

If you want to add characters to the list (e.g. lowercase letters, as in #122, or punctuation, as in my case), then it seems you have to train a new network. That part doesn't seem to be working as well for me.