ios - 在 didUpdateFrame 方法中保存 ARSCNView 快照会导致相机卡住

标签 ios objective-c github arkit

我在 session 期间在 ARKit 中创建视频。当我按下录制按钮时,相机卡住。我在 didUpdateFrame 委托(delegate)中编写了导致问题的代码。在那里,我将 scene.snapshot 保存在一个数组中。此外,当我从这些图像创建视频时,应用程序在调试器中崩溃并显示以下消息:
来自调试器的消息:由于内存问题而终止

    -(void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame
    {
     if (_recordButton.state  == UIControlStateSelected)
     {
      currentState = Recording;
     [self saveImage];
    }
    else if (previousState == Recording)
    {
    NSLog(@"Stop recording");
    currentState = NotRecording;
    recordTime = NULL;
    self.nextButton.enabled=YES;
   }
//update recording state per frame update
previousState = currentState;

}
    -(void)saveImage 
    {
      UIImage *image = self.sceneView.snapshot;
      [self.bufferArray addObject:image];
      image = nil;
   }

最佳答案

不要将 ARSCNView.snapshot 与实现 ARSessionDelegate.didUpdateFrame 一起使用。我有同样的问题,解决方案是不实现 ARSessionDelegate.didUpdateFrame。我已经将 CADisplayLink 与 ARSCNView.snapshot 一起使用,并且效果很好。
我也尝试使用 ARFrame.capturedImage,但它根本不包含 AR 对象。 ARSCNView.snapshot 包含它们。

关于ios - 在 didUpdateFrame 方法中保存 ARSCNView 快照会导致相机卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45282587/

相关文章:

ios - UICollectionView 水平滚动不滚动到最后一项

github - 如何知道人们何时在 github 上为我的 repo 加星标?

iphone - XCode 4.5.2 GM Seed 版本与 iOS 6 的方向问题

ios - 当一个 UIButton 被点击时,你如何让它变大,然后使用 Swift 3 回到以前/正常的大小?

ios - 在 iOS 上使用 HTTP post 发送图像和文本

objective-c - 你怎么称呼在有条件的情况下做作业?

git pull 错误 "The requested URL returned error: 503 while accessing"

github - Markdown 表未显示在 github .md 页面上

iphone - 向后方向的 NSRegularExpression?

ios - 如何从 UIImage 对象获取所有图像像素