ios - 如何在 iOS 上录制视频时保存 TrueDepth 数据?
问题描述
我正在寻找一种在使用 TrueDepth 相机录制视频时将深度信息(对于每一帧)保存到文件中的方法。我找到了在拍照时保存深度数据的解决方案,而不是视频。
我目前有用于录制视频并将其保存到文件并同时捕获深度数据的代码。但是,我不知道如何保存深度数据。基本上我使用 AVCaptureSession 和 AVCaptureMovieFileOutput 来保存录制的视频。我发现深度数据是由 AVCaptureDepthDataOutput 给出的,但是如何将它保存到文件中呢?
代码的主要部分:
let captureSession = AVCaptureSession()
let sessionOutput = AVCapturePhotoOutput()
let movieOutput = AVCaptureMovieFileOutput()
let depthDataOutput = AVCaptureDepthDataOutput()
if let device = AVCaptureDevice.default(.builtInTrueDepthCamera,
for: .video, position: .front) {
let input = try AVCaptureDeviceInput(device: device )
if captureSession.canAddInput(input){
captureSession.sessionPreset = AVCaptureSession.Preset.photo
captureSession.addInput(input)
if captureSession.canAddOutput(sessionOutput){
captureSession.addOutput(sessionOutput)
// Code for adding previewing the video
}
}
if captureSession.canAddOutput(depthDataOutput){
captureSession.addOutput(depthDataOutput)
}
if let connection = depthDataOutput.connection(with: .depthData) {
connection.isEnabled = true
depthDataOutput.isFilteringEnabled = false
print("Depth data working")
} else {
print("No AVCaptureConnection")
}
// Capture the video to a file
captureSession.addOutput(movieOutput)
captureSession.startRunning()
// ...
// How to store the depth data from AVCaptureDepthDataOutput ?
}
有任何想法吗?
解决方案
推荐阅读
- asp.net-mvc - 在同一个域上运行 Asp.net MVC 和 React
- python-3.x - 数据集 API RecursionError:超出最大递归深度
- python - 根据关系模型值自动创建模型对象
- sql - 有没有办法提高在 select 子句中使用多个子查询的查询的性能
- google-apps-script - 如何用 mailto 替换变量:google doc apps 脚本中的链接
- python - 根据其他数据框中的行和列信息索引数据框
- protractor - 在 afterEach 块中放置断言是一种好习惯吗?
- php - 是否可以传递一个变量来路由像 api.php 这样的文件以用作中间件的名称?
- greenfoot - 多人游戏方向键
- html - 带有文本的按钮内部的画布