Develop Intelligent iOS Apps with Swift by Özgür Sahin
Author:Özgür Sahin
Language: eng
Format: epub
ISBN: 9781484264218
Publisher: Apress
return
}
let maximumCandidates = 1
if let visionResult = results.first {
guard let candidate =
visionResult.topCandidates(maximumCandidates).first
else { return }
print(candidate.string)
showString(string: candidate.string)
}
Listing 4-2Text Recognition Process Results
In the preceding code, we check whether results exist in the request, and if they exist, we get the first result. This is the prediction result of the text recognition request. The âtopCandidatesâ function returns the prediction results sorted by decreasing confidence score, so the top one is the best prediction. We get the prediction string for the first candidate and show it on the screen. The âshowStringâ method takes the string and shows it in the text view. It dispatches this call in the main thread by calling DispatchQueue.main.async to ensure UI updates performed properly.
Our OCR app is ready. Now you can just run the app and try on your iPhone. If you focus the camera on any text, you will see the OCR results like in Figure 4-5. You canât use the simulator for this app because it does not provide camera capture.
Figure 4-5Text Recognition App
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(9918)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9797)
The Mikado Method by Ola Ellnestam Daniel Brolund(9780)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8303)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7784)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7764)
Grails in Action by Glen Smith Peter Ledbrook(7699)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7559)
Windows APT Warfare by Sheng-Hao Ma(6868)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6602)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6470)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6420)
Kotlin in Action by Dmitry Jemerov(5068)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4320)
Functional Programming in JavaScript by Mantyla Dan(4040)
Solidity Programming Essentials by Ritesh Modi(4021)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3812)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3755)
The Ultimate iOS Interview Playbook by Avi Tsadok(3731)
