2

During the SceneKit: What's New presentation at WWCD2017 (44:19) it was stated that we can now use AVCaptureDevice as background content for SCNScene.

Snippet from the presentation:

let captureDevice: AVCaptureDevice = ...
scene.background.contents = captureDevice

However the following code

let captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)!
scene.background.contents = captureDevice

produces an error:

[SceneKit] Error: Cannot get pixel buffer (CVPixelBufferRef)

I also tried to create and start AVCaptureSession and then use the device, but it gives the same result.

What might be an issue here?

Lësha Turkowski
  • 1,361
  • 1
  • 10
  • 21

1 Answers1

2

Edit

This bug seems to be fixed in iOS 11.2


Original answer

this appears to be a bug in SceneKit.

If that works for you a workaround would be to use an ARSCNView. It gives you access to all the SceneKit APIs, and it automatically draws the video feed as the scene's background.

mnuages
  • 13,049
  • 2
  • 23
  • 40
  • 1
    Bug reappeared at iOS 11.3 – lePapa May 10 '18 at 12:19
  • I have encountered the same issue on iOS 11.4 on a 5S. However, I am using an AVPlayer rather than the AVCaptureDevice. Does anyone have a link to Apple's ticket to fix this issue? – marcel Jun 25 '18 at 04:06