我想使用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;
}
}发布于 2017-11-24 06:28:33
更新我的评论,以回答更多细节。
作为AR会话的一部分捕获的视频图像和位置跟踪信息。
带有相关AR场景信息的视频帧图像,最近由会话捕获。
根据这些苹果ARKit文档,当currentFrame获得视频和相关的AR场景信息时,ARSession将有价值。因此,我们必须首先运行会话..
要运行ARSession,我们需要一个会话配置:
运行会话需要会话配置: ARConfiguration类或其子类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);
}https://stackoverflow.com/questions/47401727
复制相似问题