Ejemplo n.º 1
0
        private void Run()
        {
            if (_doorDetector != null && _doorDetector.IsRunning)
            {
                _doorDetector.CancelAsync();
            }

            ColorBasedDoorDetector cDetector = _doorDetector as ColorBasedDoorDetector;

            if (cDetector != null)
            {
                _imageStream = VideoStream.Instance;
            }
            else
            {
                DepthBasedDoorDetector dDetector = _doorDetector as DepthBasedDoorDetector;
                if (dDetector != null)
                {
                    _imageStream = DepthStream.Instance;
                }
                else
                {
                    InfraredBasedDoorDetector iDetector = _doorDetector as InfraredBasedDoorDetector;
                    if (iDetector != null)
                    {
                        _imageStream = InfraredStream.Instance;
                    }
                }
            }

            if (_imageStream != null && this.DoorDetector != null)
            {
                _doorDetector.RunAsync(_imageStream);
            }
        }
Ejemplo n.º 2
0
        //Render the background
        private void UpdateBackground()
        {
            //const DispatcherPriority priority = DispatcherPriority.Render;
            while (true)
            {
                BaseFrame       frame       = null;
                WriteableBitmap frameBitmap = null;

                ColorBasedDoorDetector cDetector = _doorDetector as ColorBasedDoorDetector;
                if (cDetector != null)
                {
                    frame = VideoStream.Instance.GetFrame();
                    if (frame != null)
                    {
                        frameBitmap = frame.GetBitmap();
                    }
                }
                else
                {
                    DepthBasedDoorDetector dDetector = _doorDetector as DepthBasedDoorDetector;
                    if (dDetector != null)
                    {
                        frame = DepthStream.Instance.GetFrame();
                        if (frame != null)
                        {
                            frameBitmap = frame.GetWriteableBitmapForDoorNavi();
                        }
                    }
                    else
                    {
                        InfraredBasedDoorDetector iDetector = _doorDetector as InfraredBasedDoorDetector;
                        if (iDetector != null)
                        {
                            frame = InfraredStream.Instance.GetFrame();
                            if (frame != null)
                            {
                                frameBitmap = frame.GetBitmap();
                            }
                        }
                    }
                }

                if (frameBitmap != null)
                {
                    RenderImage(frameBitmap, ImageView1);
                }
                Thread.Sleep(1000 / FRAMERATE);
            }
        }
Ejemplo n.º 3
0
        private void RadioButton_CheckedChanged(object sender, RoutedEventArgs e)
        {
            // ... Get RadioButton reference.
            var    button             = sender as RadioButton;
            string detectionMethodStr = button.Content.ToString();

            if (detectionMethodStr == "ColorBased")
            {
                DoorDetector = new ColorBasedDoorDetector();
            }
            else if (detectionMethodStr == "DepthBased")
            {
                DoorDetector = new DepthBasedDoorDetector();
            }
            else if (detectionMethodStr == "InfraredBased")
            {
                DoorDetector = new InfraredBasedDoorDetector();
            }
            this.Run();
        }