NMAC427 / SwiftOCR

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

SwiftOCR direction mode #89

Closed jhonny-me closed 7 years ago

jhonny-me commented 7 years ago

SwiftOCR works like a charm when recognizing single line numbers with a trained model.

Here comes my question: When I have a two lines of numbers, like this:

12345
67890

SwiftOCR give me a result 1627384950 instead of 1234567890, so I'm wondering if SwiftOCR can have some direction mode that can be configured.

And currently I split the image into two smaller image each contains only one line of number which works fine but from the result it seems SwiftOCR do have the ability to recognize multiple lines. So, guys, any idea?

NMAC427 commented 7 years ago

You can modify the sorting function outputImages.sort(by: {return $0.0.1.origin.x < $0.1.1.origin.x}) at Line 460 in the extractBlobs function so that the first line of numbers is sorted before the second line.