Created
November 1, 2022 10:12
-
-
Save wizard1066/975d5ff5a9d555e86972126a95db12ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func scanText() { | |
var superString:String = "" | |
let requestHandler = VNImageRequestHandler(cgImage: (selectedImage?.cgImage)!) | |
let request = VNRecognizeTextRequest{ (request, error) in | |
guard let observations = request.results as? [VNRecognizedTextObservation] else { return } | |
for textObjects in observations { | |
let topCandiate = textObjects.topCandidates(1) | |
if let recognizedText = topCandiate.first { | |
print(recognizedText.string) | |
superString += recognizedText.string | |
} | |
} | |
} | |
request.recognitionLevel = .accurate | |
try? requestHandler.perform([request]) | |
strings.append(superString) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment