Skip to content

Instantly share code, notes, and snippets.

@bapspatil
Created April 15, 2019 06:37
Show Gist options
  • Save bapspatil/2e6ce4447c0d3dc97a37b8bd0f941c19 to your computer and use it in GitHub Desktop.
Save bapspatil/2e6ce4447c0d3dc97a37b8bd0f941c19 to your computer and use it in GitHub Desktop.
recognizer.process(visionImage) { result, error in
guard error == nil, let result = result else {
// ...
return
}
// Text recognition results
let resultText = result.text
// `VisionText` is made of `VisionTextBlock`s...
for block in resultText.blocks {
// ...and each `VisionTextBlock` has
// text, confidence level, list of recognized languages and corner points and frame in which the text was detected...
let blockText = block.text
let blockConfidence = block.confidence
let blockLanguages = block.recognizedLanguages
let blockCornerPoints = block.cornerPoints
let blockFrame = block.frame
// ...and each `VisionTextBlock` is made of `VisionTextLine`s...
for line in block.lines {
// ...which again have text, confidence level, list of recognized languages, corner points and the frame in which the text was detected...
let lineText = line.text
let lineConfidence = line.confidence
let lineLanguages = line.recognizedLanguages
let lineCornerPoints = line.cornerPoints
let lineFrame = line.frame
// ... and each `VisionTextLine` is further made of `VisionTextElement`s...
for element in line.elements {
// ...and each `VisionTextElement` has
// text, confidence level, list of recognized languages, corner points and the frame in which the text was detected.
let elementText = element.text
let elementConfidence = element.confidence
let elementLanguages = element.recognizedLanguages
let elementCornerPoints = element.cornerPoints
let elementFrame = element.frame
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment