How to delegate ARSession and AVCaptureSession at the same time?

Viewed 3722

I've seen people running ARKit with ARSCNView, and they're able to fetch said a QR code rectangle in the camera and render something at the position somehow related to the place QR code resided in the space. I thought they did it by delegating AVCaptureMetadataOutputObjectsDelegate, so I went ahead and attempt to achieve the following logic:

  1. Running ARSCNViewDelegate, ARSessionDelegate and AVCaptureMetadataOutputObjectsDelegate at the same time.

  2. Wire up an ARSCNView, delegate the view and its session to self.

  3. Wire up an AVCaptureSession, delegate it to self, and start the session.

  4. Start the ARSCNView session, since the official example did this in viewWillAppear(), I did the same thing.

The application did run without any error, but I could only get a few callbacks from AVCaptureMetadataOutputObjectsDelegate, like 3 to 5, and then it would never be called again like the delegate of ARSession seized its authority, was I implementing the wrong approach or you just can't delegate ARSession and AVCaptureSession at the same time?

1 Answers
Related