Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement