Home iOS - How to add sceneKit node objects on top of the front facing camera. Not ArKit
Reply: 1

iOS - How to add sceneKit node objects on top of the front facing camera. Not ArKit

Nicolas Gonzalez Thomas
Nicolas Gonzalez Thomas Published in 2017-12-07 20:48:52Z

I'm trying to create some animations to be seen in the front facing camera in iOS, with SceneKit. Something similar to what ArKit does on the back camera. Not using iPhone X nor ArKit (ArKit does not work on the front facing camera). Right now I'm not able to combine the camera and the sceneKit scene for both to appear. I can see either the front camera view from:

AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front) 

or I can see the scene view.

It should look like the front facing camera live as a backdrop and all the nodes in the scene appearing in the front on top of that.

Another way to think of it is that I want the background of the scene to by a live feed from the front facing camera.

How would I do this?

mnuages Reply to 2017-12-07 21:40:43Z

SCNScene.background is an instance of SCNMaterialProperty which can take an AVCaptureDevice instance as its contents. The online documentation doesn't reflect that addition to iOS 11 yet, but it's mentioned in the SceneKit headers as well as their WWDC'17 presentation.

// Setup background video
let captureDevice: AVCaptureDevice = ...
scene.background.contents = captureDevice
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336937 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO