SwiftOCR icon indicating copy to clipboard operation
SwiftOCR copied to clipboard

Line 85: SwiftOCR.swift file fatal error after training.

Open Kpsixas opened this issue 7 years ago • 0 comments

I have trained a set of characters, "AKOST" to be specific and saved the file created. I replaced it with the original OCR-Network file of the project and then i tried to run the debug app to see how it's working. After showing the original image and preprocessed image, i get this error.

fatal error: Index out of range
2017-04-04 19:26:42.907560+0300 SwiftOCR Debug OS X[1735:37419] fatal error: Index out of range
Current stack trace:
0    libswiftCore.dylib                 0x00000001004dcce0 swift_reportError + 132
1    libswiftCore.dylib                 0x00000001004fa090 _swift_stdlib_reportFatalError + 61
2    libswiftCore.dylib                 0x00000001002f00c0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355
3    libswiftCore.dylib                 0x000000010046c230 partial apply for (_fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never).(closure #2) + 109
4    libswiftCore.dylib                 0x00000001002f00c0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355
5    libswiftCore.dylib                 0x00000001004243f0 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never + 96
6    libswiftSwiftOnoneSupport.dylib    0x0000000100aab7a0 specialized Array.subscript.getter + 126
7    SwiftOCR Debug OS X                0x0000000100012130 SwiftOCR.(recognize(NSImage, (String) -> ()) -> ()).(indexToCharacter #1)(Int) -> Character + 160
8    SwiftOCR Debug OS X                0x0000000100012760 SwiftOCR.(recognize(NSImage, (String) -> ()) -> ()).(closure #1) + 2293
9    SwiftOCR Debug OS X                0x0000000100005540 thunk + 39
10   libdispatch.dylib                  0x0000000100ba7cf2 _dispatch_call_block_and_release + 12
11   libdispatch.dylib                  0x0000000100b9e784 _dispatch_client_callout + 8
12   libdispatch.dylib                  0x0000000100ba076d _dispatch_root_queue_drain + 1364
13   libdispatch.dylib                  0x0000000100ba06ab _dispatch_worker_thread3 + 114
14   libsystem_pthread.dylib            0x0000000100c152ff _pthread_wqthread + 1299
15   libsystem_pthread.dylib            0x0000000100c152e0 start_wqthread + 13
(lldb) 

On the training part, I edited the files for training, changing the characters i want to recognize to "AKOST" as described above, and selected some fonts from the trainer app and started training. I saved the network and then replaced it with the original. Did i do something wrong?

///The characters the globalNetwork can recognize.
///It **must** be in the **same order** as the network got trained
public var recognizableCharacters = "AKOST"

///Only recognize characters on White List
open      var characterWhiteList: String? = "AKOST"

These are the lines i changed on the SwiftOCR.swift file.

Kpsixas avatar Apr 04 '17 16:04 Kpsixas