Utility allows to capture videos from ARKit scene and export to Photos app.
You can use CocoaPods to install ARCapture by adding it to your Podfile:
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'ARCapture', :git => 'https://gitlab.com/seriyvolk83/arcapture.git'
endTo use this library in your project manually you may:
- for Projects, just drag needed *.swift files to the project tree
- for Workspaces, to the same
- Add the following into
Info.plist.
<key>NSCameraUsageDescription</key>
<string>Will allow to use AR features.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Export captured photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Export captured photos and videos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Will record audio for the video.</string>
- Use this example to implement client code:
private var capture: ARCapture?
...
override func viewDidLoad() {
super.viewDidLoad()
// Create a new scene
let scene = SCNScene()
...
// TODO Setup ARSCNView with the scene
// sceneView.scene = scene
// Setup ARCapture
capture = ARCapture(view: sceneView)
}
/// "Record" button action handler
@IBAction func recordAction(_ sender: UIButton) {
capture?.start()
// or
capture?.start(captureType: ARFrameGenerator.CaptureType.renderOriginal, captureDepth: ARFrameGenerator.CaptureDepth.default)
// or
capture?.start(captureType: ARFrameGenerator.CaptureType.renderOriginal, captureDepth: ARFrameGenerator.CaptureDepth.smooth)
}
/// "Stop" button action handler
@IBAction func stopAction(_ sender: UIButton) {
capture?.stop({ (status) in
print("Video exported: \(status)")
})
}