public async void StartVideo()
        {
            //Raw data and decoded data listener
            if (_videoParser == null)
            {
                _videoParser = new DJIVideoParser.Parser();
                _videoParser.Initialize(delegate(byte[] data)
                {
                    return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data));
                });

                this._videoParser.SetCameraSensor(AircraftCameraType.Others);

                _videoParser.SetSurfaceAndVideoCallback(0, 0, _swapChainPannel, ReceiveDecodedData);
                DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush;
            }
            //get the camera type and observe the CameraTypeChanged event.
            DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).CameraTypeChanged += OnCameraTypeChanged;
            var type = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).GetCameraTypeAsync();

            OnCameraTypeChanged(this, type.value);
            this._swapChainPannel.Visibility = Visibility.Visible;

            if (_telloDrone != null)
            {
                _telloDrone.Tello.Controller.StartVideo();
            }
        }
示例#2
0
        //Callback of SDKRegistrationEvent
        private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode)
        {
            if (resultCode == SDKError.NO_ERROR)
            {
                System.Diagnostics.Debug.WriteLine("Register app successfully.");

                //Must in UI thread
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                {
                    //Raw data and decoded data listener
                    if (videoParser == null)
                    {
                        videoParser = new DJIVideoParser.Parser();
                        videoParser.Initialize(delegate(byte[] data)
                        {
                            //Note: This function must be called because we need DJI Windows SDK to help us to parse frame data.
                            return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data));
                        });
                        //Set the swapChainPanel to display and set the decoded data callback.
                        videoParser.SetSurfaceAndVideoCallback(0, 0, swapChainPanel, ReceiveDecodedData);
                        DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush;
                    }
                    //get the camera type and observe the CameraTypeChanged event.
                    DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).CameraTypeChanged += OnCameraTypeChanged;
                    var type = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).GetCameraTypeAsync();
                    OnCameraTypeChanged(this, type.value);
                });
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("SDK register failed, the error is: ");
                System.Diagnostics.Debug.WriteLine(resultCode.ToString());
            }
        }
示例#3
0
 public void UninitializeVideoFeedModule()
 {
     if (DJISDKManager.Instance.SDKRegistrationResultCode == SDKError.NO_ERROR)
     {
         videoParser.SetSurfaceAndVideoCallback(0, 0, null, null);
         DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated -= OnVideoPush;
         videoParser = null;
     }
 }
        public void StopVideo()
        {
            if (_videoParser != null)
            {
                DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated -= OnVideoPush;
                _videoParser = null;
            }

            if (_telloDrone != null)
            {
                _telloDrone.Tello.Controller.StopVideo();
            }
        }
        private async void ConnectDJICam()
        {
            //Raw data and decoded data listener
            if (_videoParser == null)
            {
                _videoParser = new DJIVideoParser.Parser();
                _videoParser.Initialize(delegate(byte[] data)
                {
                    //Note: This function must be called because we need DJI Windows SDK to help us to parse frame data.
                    return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data));
                });
                //Set the swapChainPanel to display and set the decoded data callback.
                _videoParser.SetSurfaceAndVideoCallback(0, 0, _swapChainPannel, ReceiveDecodedData);
                DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush;
            }
            //get the camera type and observe the CameraTypeChanged event.
            DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).CameraTypeChanged += OnCameraTypeChanged;
            var type = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).GetCameraTypeAsync();

            OnCameraTypeChanged(this, type.value);
            this._swapChainPannel.Visibility = Visibility.Visible;
        }
示例#6
0
 private async void InitializeVideoFeedModule()
 {
     //Must in UI thread
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
     {
         //Raw data and decoded data listener
         if (videoParser == null)
         {
             videoParser = new DJIVideoParser.Parser();
             videoParser.Initialize(delegate(byte[] data)
             {
                 //Note: This function must be called because we need DJI Windows SDK to help us to parse frame data.
                 return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data));
             });
             //Set the swapChainPanel to display and set the decoded data callback.
             videoParser.SetSurfaceAndVideoCallback(0, 0, swapChainPanel, ReceiveDecodedData);
             DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush;
         }
         //get the camera type and observe the CameraTypeChanged event.
         DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).CameraTypeChanged += OnCameraTypeChanged;
         var type = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).GetCameraTypeAsync();
         OnCameraTypeChanged(this, type.value);
     });
 }
示例#7
0
        public async void InitializeVideoFeedModule()
        {
            if (videoTest)
            {
                var t = Task.Run(() => {
                    int count = 0;
                    while (true)
                    {
                        Thread.Sleep(20);
                        int width        = 500;
                        int height       = 500;
                        byte[] pixelData = new byte[4 * width * height];

                        int index  = 0;
                        Random rnd = new Random();
                        for (int y = 0; y < height; ++y)
                        {
                            for (int x = 0; x < width; ++x)
                            {
                                pixelData[index++] = (byte)rnd.Next(0, 255);  // B
                                pixelData[index++] = (byte)rnd.Next(0, 255);; // G
                                pixelData[index++] = (byte)rnd.Next(0, 255);; // R
                                pixelData[index++] = (byte)rnd.Next(0, 255);; // A
                            }
                        }

                        ReceiveDecodedData(pixelData, width, height);
                        System.Diagnostics.Debug.WriteLine(count);
                        count++;

                        if (videoParser != null)
                        {
                            break;
                        }
                    }
                });

                return;
            }

            //Must in Thread
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                //Raw data and decoded data listener
                if (videoParser == null)
                {
                    videoParser = new DJIVideoParser.Parser();
                    videoParser.Initialize(delegate(byte[] data)
                    {
                        //Note: This function must be called because we need DJI Windows SDK to help us to parse frame data.
                        return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data));
                    });
                    //Set the swapChainPanel to display and set the decoded data callback.
                    videoParser.SetSurfaceAndVideoCallback(0, 0, swapChainPanel, ReceiveDecodedData);
                    DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush;
                }
                //get the camera type and observe the CameraTypeChanged event.
                DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).CameraTypeChanged += OnCameraTypeChanged;
                var type = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).GetCameraTypeAsync();
                OnCameraTypeChanged(this, type.value);
            });
        }