Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. recognizer.process(visionImage) { result, error in
  2. guard error == nil, let result = result else {
  3. // ...
  4. return
  5. }
  6.  
  7. // Text recognition results
  8. let resultText = result.text
  9. // `VisionText` is made of `VisionTextBlock`s...
  10. for block in resultText.blocks {
  11. // ...and each `VisionTextBlock` has
  12. // text, confidence level, list of recognized languages and corner points and frame in which the text was detected...
  13. let blockText = block.text
  14. let blockConfidence = block.confidence
  15. let blockLanguages = block.recognizedLanguages
  16. let blockCornerPoints = block.cornerPoints
  17. let blockFrame = block.frame
  18. // ...and each `VisionTextBlock` is made of `VisionTextLine`s...
  19. for line in block.lines {
  20. // ...which again have text, confidence level, list of recognized languages, corner points and the frame in which the text was detected...
  21. let lineText = line.text
  22. let lineConfidence = line.confidence
  23. let lineLanguages = line.recognizedLanguages
  24. let lineCornerPoints = line.cornerPoints
  25. let lineFrame = line.frame
  26. // ... and each `VisionTextLine` is further made of `VisionTextElement`s...
  27. for element in line.elements {
  28. // ...and each `VisionTextElement` has
  29. // text, confidence level, list of recognized languages, corner points and the frame in which the text was detected.
  30. let elementText = element.text
  31. let elementConfidence = element.confidence
  32. let elementLanguages = element.recognizedLanguages
  33. let elementCornerPoints = element.cornerPoints
  34. let elementFrame = element.frame
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement