Skip to content

Instantly share code, notes, and snippets.

@kravik
Last active February 1, 2019 12:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kravik/f4b77481db1c91d732f1da03b30f6d41 to your computer and use it in GitHub Desktop.
Save kravik/f4b77481db1c91d732f1da03b30f6d41 to your computer and use it in GitHub Desktop.
iOS 11 Vision. Text detection
let image = UIImage(named: "text.png")!
let vnImage = VNImageRequestHandler(cgImage: image.cgImage!, options: [:])
let textRectsRequest = VNDetectTextRectanglesRequest { (request, error) in
if let results = request.results as? [VNTextObservation] {
for result in results {
print("boundingBox \(result.boundingBox)")
print("characterBoxes \(result.characterBoxes)")
}
}
}
textRectsRequest.reportCharacterBoxes = true
try vnImage.perform([textRectsRequest])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment