title: How to pass AR Session's frame to Vision? In SwiftUI
body: <p>in brief: How to pass every frame from AR Session to a funcion?</p>
  <hr />
  <p>I'm making an app:</p>
  <ul>
  <li>It displays the image of the rear camera in real time. (in <code>AR View</code>)（✅）</li>
  <li>When it detects a QR code, it will read the text content in the QR code.（I don't know how to do it in real time, get data from AR session）</li>
  </ul>
  <pre><code>func getQRCodeContent(_ pixel: CVPixelBuffer) -&gt; String {
      let requestHandler = VNImageRequestHandler(cvPixelBuffer: pixel, options: [:])
      let request = VNDetectBarcodesRequest()
      request.symbologies = [.qr]
  
      try! requestHandler.perform([request])
      let result = request.results?.first?.payloadStringValue
      
      if let result = result {
          return result
      } else {
          return &quot;non&quot;
      }
  }
  </code></pre>
  <ul>
  <li>And then do some logic with the content, and display the corresponding AR model in the AR View.</li>
  </ul>
  <hr />
  <p>I know I have to feed images into the <code>Vision Framework</code>, I started with <code>AVFoundation</code>, but I found that when <code>AR View</code> is loaded, the <code>AVCaptureSession</code> is paused.</p>
  <p>And I want to feed <code>AR Session</code>'s frame into <code>Vision Framework</code>. However, all the tutorials I can find are based on <code>story board</code> and <code>UI kit</code> to complete this function. I don't know how to complete this function in <code>Swift UI</code> at all.</p>
  <p>I tried to extent <code>ARView</code>:</p>
  <pre class="lang-swift prettyprint-override"><code>extension ARView: ARSessionDelegate {
      func renderer(_ renderer: SKRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) {
          let capturedImage = session.currentFrame?.capturedImage
          print(capturedImage)
      }
  }
  </code></pre>
  <pre class="lang-swift prettyprint-override"><code>struct ARViewCustom: UIViewRepresentable {
      func makeUIView(context: Context) -&gt; ARView {
          let arView = ARView(frame: .zero)
          arView.session.delegate = arView
          return arView
      }
  
      func updateUIView(_ uiView: ARView, context: Context) {}
  }
  </code></pre>
  <p>No error, but it doesn't work.</p>