【问题标题】:ARSKView snapshot iOSARSKView 快照 iOS
【发布时间】:2017-09-02 14:18:26
【问题描述】:

有人在 ARKit 项目中截取了ARSKView 的屏幕截图吗?

我尝试过这样的事情:

if let sc = view.snapshotView(afterScreenUpdates: true) {

    DispatchQueue.main.async {
        UIGraphicsBeginImageContextWithOptions(sc.bounds.size, true, 0.0)
        sc.drawHierarchy(in: sc.bounds, afterScreenUpdates: true)
        let screenshot = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        UIImageWriteToSavedPhotosAlbum(screenshot!, nil, nil, nil)
    }
}

但输出的是黑色图像。

在 Apple 的示例中,他们使用 ARSCNView,他们可以在其中调用快照函数,它会自动完成所有操作。

我使用的是 SpriteKit 而不是 SceneKit,所以在 spriteKit 中没有快照方法。

【问题讨论】:

    标签: ios sprite-kit augmented-reality arkit


    【解决方案1】:
    • 我在ARSKView上使用drawHeirarchy(in:afterScreenUpdates:)时也出现黑屏

    • 对我来说失败的另一种方法:使用 ARSession 属性 (ARFrame *)currentFrame - 将像素缓冲区 capturedImage 转换为 UIImage 但这只是显示现实世界的图像,它不包括精灵。

    • 对我有用的只是从 View Controller 视图而不是 ARSKView 截取屏幕截图。

    • 仍然可以切换到 SceneKit,因为您仍然可以在 SCNNode 上使用 SpriteKit 作为材质。 SceneKit 还附带了一些不错的东西,比如快照。

    • 还有像 ARVideoKit https://github.com/AFathi/ARVideoKit 这样的开源实现

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-15
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      • 2017-06-25
      相关资源
      最近更新 更多