{"id":15033298,"url":"https://github.com/nmac427/swiftocr","last_synced_at":"2025-05-14T19:05:56.176Z","repository":{"id":41553960,"uuid":"56840338","full_name":"NMAC427/SwiftOCR","owner":"NMAC427","description":"Fast and simple OCR library written in Swift","archived":false,"fork":false,"pushed_at":"2020-12-13T08:49:55.000Z","size":11613,"stargazers_count":4621,"open_issues_count":86,"forks_count":480,"subscribers_count":155,"default_branch":"master","last_synced_at":"2024-10-29T15:35:07.125Z","etag":null,"topics":["deprecated","ios","macos","ocr","ocr-engine","ocr-library","optical-character-recognition","swift","swiftocr"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NMAC427.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-22T08:39:02.000Z","updated_at":"2024-10-28T22:39:57.000Z","dependencies_parsed_at":"2022-07-19T22:02:06.843Z","dependency_job_id":null,"html_url":"https://github.com/NMAC427/SwiftOCR","commit_stats":null,"previous_names":["garnele007/swiftocr"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMAC427%2FSwiftOCR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMAC427%2FSwiftOCR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMAC427%2FSwiftOCR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMAC427%2FSwiftOCR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NMAC427","download_url":"https://codeload.github.com/NMAC427/SwiftOCR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710407,"owners_count":21149185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deprecated","ios","macos","ocr","ocr-engine","ocr-library","optical-character-recognition","swift","swiftocr"],"created_at":"2024-09-24T20:20:38.780Z","updated_at":"2025-04-13T11:46:14.465Z","avatar_url":"https://github.com/NMAC427.png","language":"Swift","readme":"\u003ch3 align=\"center\"\u003e⛔️ This Project is deprecated and no longer gets maintained!\u003c/h3\u003e\n\nPlease use Apple's [Vision](https://developer.apple.com/documentation/vision/recognizing_text_in_images) framework instead of SwiftOCR. It is very fast, accurate and much less finicky.\n\n---\n\n![Deprecated](https://img.shields.io/badge/Status-Deprecated-critical)\n![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)\n![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwiftOCR.svg)\n![Platform](https://img.shields.io/cocoapods/p/SwiftOCR.svg?style=flat)\n\n# SwiftOCR\n\nSwiftOCR is a fast and simple OCR library written in Swift. It uses a neural network for image recognition.\nAs of now, SwiftOCR is optimized for recognizing short, one line long alphanumeric codes (e.g. DI4C9CM). We currently support iOS and OS X.\n\n## Features\n- [x] Easy to use training class\n- [x] High accuracy\n- [x] Great default image preprocessing\n- [x] Fast and accurate character segmentation algorithm\n- [x] Add support for lowercase characters\n- [x] Add support for connected character segmentation\n\n## Why should I choose SwiftOCR instead of Tesseract?\n\nThis is a really good question. \n\nIf you want to recognize normal text like a poem or a news article, go with Tesseract, but if you want to recognize short, alphanumeric codes (e.g. gift cards), I would advise you to choose SwiftOCR because that's where it exceeds.\n\nTesseract is written in C++ and over 30 years old. To use it you first have to write a Objective-C++ wrapper for it. The main issue that's slowing down Tesseract is the way memory is managed. Too many memory allocations and releases slow it down.\n\nI did some testing on over 50 difficult images containing alphanumeric codes. The results where astonishing. SwiftOCR beat Tesseract in every category.\n\n|          | SwiftOCR  | Tesseract |\n| -------- | :-------: | :-------: |\n| Speed    | 0.08 sec. | 0.63 sec. |\n| Accuracy | 97.7%     | 45.2%     |\n| CPU      | ~30%      | ~90%      |\n| Memory   | 45 MB     | 73 MB     |\n\n\n## How does it work?\n\n1) Input image is thresholded (binarized).\n2) Characters are extracted from the image, using a technique called [Connected-component labeling](https://en.wikipedia.org/wiki/Connected-component_labeling).\n3) Separated characters are converted into numbers, which are then fed into the neural network.\n\n## How to use it?\n\nSwiftOCR is available through CocoaPods. To install it, simply add the following line to your Podfile:\n\n`pod 'SwiftOCR'`\n\nIf you ever used Tesseract you know how exhausting it can be to implement OCR into your project. \nSwiftOCR is the exact opposite of Tesseract. It can be implemented using **just 6 lines of code**. \n\n```swift\nimport SwiftOCR\n\nlet swiftOCRInstance = SwiftOCR()\n    \nswiftOCRInstance.recognize(myImage) { recognizedString in\n    print(recognizedString)\n}\n```\n\nTo improve your experience with SwiftOCR you should set your Build Configuration to `Release`.\n\n#### Training\n\nTraining SwiftOCR is pretty easy. There are only a few steps you have to do, before it can recognize a new font.\n\nThe easiest way to train SwiftOCR is using the training app that can be found under `/example/OS X/SwiftOCR Training`. First select the fonts you want to train from the list. After that, you can change the characters you want to train in the text field. Finally, you have to press the `Start Testing` button. The only thing that's left now, is waiting. Depending on your settings, this can take between a half and two minutes. After about two minutes you may manually stop the training.\nPressing the `Save` button will save trained network to your desktop.\nThe `Test` button is used for evaluating the accuracy of the trained neural network.\n\n## Examples\n\nHere is an example image. SwiftOCR has no problem recognizing it. If you try to recognize the same image using Tesseract the output is 'LABMENSW' ?!?!?.\n\n![Image 1](https://github.com/garnele007/SwiftOCR/blob/master/example/OS%20X/SwiftOCR%20Example%20OS%20X/SwiftOCR%20Example%20OS%20X/images/Test%202.png?raw=true)\n\nThis image is difficult to recognize because of two reasons:\n- The lighting is uneven. This problem is solved by the innovative preprocessing algorithm of SwiftOCR.\n- The text in this image is distorted. Since SwiftOCR uses a neural network for the recognition, this isn't a real problem. A NN is flexible like a human brain and can recognize even the most distorted image (most of the time).\n\n## TODO\n\n- [ ] Port to [GPUImage 2](https://github.com/BradLarson/GPUImage2)\n\n## Dependencies\n\n* [Swift-AI](https://github.com/collinhundley/Swift-AI)\n* [GPUImage](https://github.com/BradLarson/GPUImage)\n* [Union-Find](https://github.com/hollance/swift-algorithm-club/tree/master/Union-Find)\n\n## License\n\n    The code in this repository is licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n**NOTE**: This software depends on other packages that may be licensed under different open source licenses.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmac427%2Fswiftocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmac427%2Fswiftocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmac427%2Fswiftocr/lists"}