由于ARKit中没有自动对焦功能,因此我想在半个屏幕的视图中加载ARKit,而下半个屏幕将具有AVFoundation -> AVCamera。是否可以在同一个应用程序中同时加载AVCamera和ARKit?谢谢。
发布于 2017-12-09 13:40:02
不是的。
ARKit在内部使用AVCapture (如WWDC talk introducing ARKit中所述)。一次只能运行一个AVCaptureSession,所以如果你运行自己的捕获会话,它将暂停ARKit的会话(并中断跟踪)。
更新:但是,在iOS 11.3 (也称为"ARKit 1.5")中,ARKit默认情况下启用自动对焦,您可以选择使用isAutoFocusEnabled选项禁用它。
发布于 2018-02-23 09:18:15
改变相机的焦点会扰乱跟踪-所以这肯定是不可能的(至少现在是这样)。
更新:参见上面的@rickster答案。
发布于 2022-02-06 10:41:18
我通过调用self.sceneView.session.run(self.sceneView.session.configuration!)成功地将AVFoundation与ARKit结合使用在拍完照片之后。
在拍照后立即使用self.captureSession?.stopRunning()可以更快地恢复会话。
self.takePhoto()
self.sceneView.session.run(self.sceneView.session.configuration!)
func startCamera() {
captureSession = AVCaptureSession()
captureSession.sessionPreset = AVCaptureSession.Preset.photo
cameraOutput = AVCapturePhotoOutput()
if let device = AVCaptureDevice.default(for: .video),
let input = try? AVCaptureDeviceInput(device: device) {
if (captureSession.canAddInput(input)) {
captureSession.addInput(input)
if (captureSession.canAddOutput(cameraOutput)) {
captureSession.addOutput(cameraOutput)
captureSession.startRunning()
}
} else {
print("issue here : captureSesssion.canAddInput")
}
} else {
print("some problem here")
}
}
func takePhoto() {
startCamera()
let settings = AVCapturePhotoSettings()
cameraOutput.capturePhoto(with: settings, delegate: self)
self.captureSession?.stopRunning()
}https://stackoverflow.com/questions/47725418
复制相似问题