title: How can I take a photo of a detected rectangle in Apple Vision framework
body: <p>How can I take a photo (get an CIImage) from the successful VNRectangleObservation object?</p>
  
  <p>I have a video capture session running and in <code>func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection)</code> I do the handling, namely</p>
  
  <pre><code>func captureOutput(_ output: AVCaptureOutput,
                     didOutput sampleBuffer: CMSampleBuffer,
                     from connection: AVCaptureConnection) {
      guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
  
      do {
          try handler.perform([request], on: pixelBuffer)
      } catch {
          print(error)
      }
  }
  </code></pre>
  
  <p>Should I save somewhere the pixel-buffer that I pass to the handler and manipulate on that buffer? It's a damn shame that I can not access the image as a property from the observation object :(</p>
  
  <p>Any ideas?</p>