Advertisement
neetrath

LiveText

Nov 2nd, 2022
1,396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.66 KB | None | 0 0
  1. private func showLiveText() {
  2.     guard let image = imageView.image else {
  3.         return
  4.     }
  5.  
  6.     Task {
  7.         let configuration = ImageAnalyzer.Configuration([.text])
  8.  
  9.         do {
  10.             let analysis = try await imageAnalyzer.analyze(image, configuration: configuration)
  11.  
  12.             DispatchQueue.main.async {
  13.                 self.interaction.analysis = nil
  14.                 self.interaction.preferredInteractionTypes = []
  15.  
  16.                 self.interaction.analysis = analysis
  17.                 self.interaction.preferredInteractionTypes = .automatic
  18.             }
  19.  
  20.         } catch {
  21.             print(error.localizedDescription)
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement