Coder Social home page Coder Social logo

Recognising numbers about swiftocr HOT 4 CLOSED

nmac427 avatar nmac427 commented on May 17, 2024
Recognising numbers

from swiftocr.

Comments (4)

NMAC427 avatar NMAC427 commented on May 17, 2024

I'm sorry that I didn't explain it anywhere correctly. If you train the NN for the characters 0-9 then you have to change internal var recognizableCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" to internal var recognizableCharacters = "0123456789" in the SwiftOCR.swift file.
You should be able to ignore the separators and add them later.

func addSeperator(seperator: String, toMACAddress macAddress: String) -> String? {
    guard macAddress.characters.count == 12 else {
        return nil
    }

    //0..<6 because every MAC Adsress has 12 characters which are grouped into *6* groups
    var seperatedMACAddressArray = [String]()

    for sectionIndex in 0..<6 {
        let substringRange = macAddress.startIndex.advancedBy(sectionIndex * 2)..<macAddress.startIndex.advancedBy(sectionIndex * 2 + 2)
        let sectionSubstring = macAddress.substringWithRange(substringRange)
        seperatedMACAddressArray.append(sectionSubstring)
    }

    let macAddress = seperatedMACAddressArray.joinWithSeparator(seperator)
    return macAddress
}

SwiftOCR().recognize(myImage) {recognizedString in
    let macAddress = addSeperator("-", toMACAddress: recognizedString)
}

Let me know if it worked. Good luck :-)

from swiftocr.

LeoSnek avatar LeoSnek commented on May 17, 2024

Hmm strange, when I change the recognisable characters to ABCDEF0123456789 it works very well but with the original set it doesn't pick up any single number. Why would that be?

from swiftocr.

NMAC427 avatar NMAC427 commented on May 17, 2024

The output of the NN looks somewhat like this [0.01, 0.5, 0.02]. As you can see 0.5 is the largest output and it's index is 1. After SwiftOCR knows that, it will look what character is at index 1 of recognizableCharacters and appends this character to recognizedString (which in the end gets returned).

If you set recognizableCharacters to "ABC" then you would get B as your result , but if you set it to "XYZ" you will get Y.

I hope this makes sense (I'm pretty bad at explaining ^^)

from swiftocr.

LeoSnek avatar LeoSnek commented on May 17, 2024

Aha, this is why the order of the recognisable characters is so critical!

I got it working perfectly with text on a Word document but we're trying to read the address from a crappy quality screen with low res text. I shall persevere! Thanks.

from swiftocr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.