示例#1
0
    // Start is called before the first frame update
    async void Start()
    {
#if ENABLE_WINMD_SUPPORT
        statusBlock.text     = "Starting camera...";
        _videoFrameProcessor = await VideoFrameProcessor.CreateAsync();

        Debug.Log("Created video frame processor");
        _faceTrackerProcessor = await FaceTrackerProcessor.CreateAsync(_videoFrameProcessor);

        statusBlock.text = "No faces detected";
        _isReadyToRender = true;
#endif
    }
        public void OnCameraAdded(
            HolographicSpace sender,
            HolographicSpaceCameraAddedEventArgs args
            )
        {
            Deferral          deferral          = args.GetDeferral();
            HolographicCamera holographicCamera = args.Camera;

            Task task1 = new Task(() =>
            {
                //
                // TODO: Allocate resources for the new camera and load any content specific to
                //       that camera. Note that the render target size (in pixels) is a property
                //       of the HolographicCamera object, and can be used to create off-screen
                //       render targets that match the resolution of the HolographicCamera.
                //

                //camera = Camera.CreateAsync(VideoProfileFormats.BalancedVideoAndPhoto896x504x30, MediaEncodingSubtypes.Nv12).GetAwaiter().GetResult();
                videoFrameProcessor  = VideoFrameProcessor.CreateAsync().GetAwaiter().GetResult();
                faceTrackerProcessor = FaceTrackerProcessor.CreateAsync(videoFrameProcessor).GetAwaiter().GetResult();

                // Create device-based resources for the holographic camera and add it to the list of
                // cameras used for updates and rendering. Notes:
                //   * Since this function may be called at any time, the AddHolographicCamera function
                //     waits until it can get a lock on the set of holographic camera resources before
                //     adding the new camera. At 60 frames per second this wait should not take long.
                //   * A subsequent Update will take the back buffer from the RenderingParameters of this
                //     camera's CameraPose and use it to create the ID3D11RenderTargetView for this camera.
                //     Content can then be rendered for the HolographicCamera.
                deviceResources.AddHolographicCamera(holographicCamera);

                // Holographic frame predictions will not include any information about this camera until
                // the deferral is completed.
                deferral.Complete();
            });

            task1.Start();
        }