Ios 如何实例化ARSCNView

Ios 如何实例化ARSCNView,ios,xamarin.ios,arkit,Ios,Xamarin.ios,Arkit,我想使用ARKit来计算当前视频帧中的环境光线量。但是,在创建ARSCNView对象后,当我检索当前帧时,它返回空值 我做错了什么 public class EyeAlignmentUICameraPreview : UIView, IAVCaptureVideoDataOutputSampleBufferDelegate { void Initialize() { CaptureSession = new CaptureSession(); PreviewLayer

我想使用ARKit来计算当前视频帧中的环境光线量。但是,在创建ARSCNView对象后,当我检索当前帧时,它返回空值

我做错了什么

public class EyeAlignmentUICameraPreview : UIView, IAVCaptureVideoDataOutputSampleBufferDelegate
{

void Initialize()
{
      CaptureSession = new CaptureSession();
      PreviewLayer = new AVCaptureVideoPreviewLayer(CaptureSession)
      {
            Frame = Bounds,
            VideoGravity = AVLayerVideoGravity.ResizeAspectFill
      };
      var device = AVCaptureDevice.GetDefaultDevice(AVCaptureDeviceType.BuiltInTelephotoCamera, AVMediaType.Video, AVCaptureDevicePosition.Back);

     ARSCNView SceneView = new ARSCNView();
     // frame is null after this line is executed
     var frame = SceneView.Session.CurrentFrame;
}
}
更新我的评论以回答更多细节

作为AR会话的一部分捕获的视频图像和位置跟踪信息

视频帧图像,以及会话最近捕获的相关AR场景信息

根据这些Apple ARKit文档,
currentFrame
将在ARSession获取视频和相关AR场景信息时具有价值因此,我们必须首先运行会话。

要运行,我们需要会话配置:

运行会话需要会话配置:ArcConfiguration类的实例或其子类ARWorldTrackingConfiguration。这些类确定ARKit如何跟踪设备相对于真实世界的位置和运动,从而影响您可以创建的AR体验类型

因此,运行ARSession的代码段如下所示:

public override void ViewWillAppear(bool animated)
{
    base.ViewWillAppear(animated);

    //Create a session configuration
    var configuration = new ARWorldTrackingConfiguration
    {
        PlaneDetection = ARPlaneDetection.Horizontal,
        LightEstimationEnabled = true
    };

    // Run the view's session
    SceneView.Session.Run(configuration, ARSessionRunOptions.ResetTracking);
}

您没有为ARSCNView创建会话配置,并且ARFrame是作为AR会话的一部分捕获的视频图像和位置跟踪信息。。因此,当视频显示时,帧将具有值。