问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/46173225/using-avcapturedevice-as-scnscene-background-content