Using AVCaptureDevice as SCNScene background content

試著忘記壹切 提交于 2019-12-02 05:07:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!