0

iOS 13.1.3 on iPad Pro

Seem like there is a a same problem on previous iOS versions. Using AVCaptureDevice as SCNScene background content

My app uses front cam to create AR face in iOS. At first tour, my app uses default SCNView with camera input. After first tour, I am setting ARSCNView background to a UIImage. After setting this I can't go back to previous state by setting scnview.scene.background to nil or inputdevice.

How can I take it back to previous state that shows camera input? First, I set like below which is shown successfully.

sceneView.scene.background.contents = UIImage(named: "bruin.jpeg")

Then after 15 seconds, I set it with the code below but I get stable image not video preview layer.

DispatchQueue.main.async {
    let captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, 
                                           for: .video, 
                                      position: .front)!
    self.sceneView.scene.background.contents = captureDevice
}

I get this error in output:

// SceneKit Error: Could not get pixel buffer (CVPixelBufferRef)
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Ozgur Sahin
  • 1,305
  • 16
  • 24

0 Answers0