Пример #1
0
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            if (_device != null)
            {
                LogMessage("Already started");
                return;
            }

            try
            {
                _device = _context.OpenDefaultDevice();
            }
            catch (NotSupportedException ex)
            {
                LogMessage(ex.Message);
            }
            if (_device == null)
            {
                LogMessage("Could not open default device");
                return;
            }

            Start.IsEnabled = false;
            Stop.IsEnabled  = true;

            _frameQueueSource     = new FrameQueue();
            _frameQueueRegistered = new FrameQueue();
            _frameConsumers.Add(new DummyFrameConsumer(_frameQueueSource, FrameType.InfraRed));
            _frameConsumers.Add(new ColorRenderer(_frameQueueRegistered, _colorBitmap));
            _frameConsumers.Add(new DepthRenderer(_frameQueueRegistered, _depthBitmap));

            var listener = new FrameListener(_frameQueueSource, message => Dispatcher.BeginInvoke(new Action(() => LogMessage(message))));

            _device.SetColorListener(listener);
            _device.SetDepthListener(listener);

            _device.StartAll();
            LogMessage("Started");

            // Device parameters can only be obtained after start
            _registration = new Registration(_device.InfraRedCameraParameters, _device.ColorCameraParameters);
            var firmwareVersion = _device.FirmwareVersion;

            LogMessage("Device firmware: {0}", firmwareVersion);

            _frameConsumers.Add(new FrameRegistrationProcessor(_frameQueueSource, _frameQueueRegistered, _registration));
            _frameConsumers.ForEach(fc => fc.Start());
        }
Пример #2
0
 public JpegRenderer(FrameQueue queue, WriteableBitmap bitmap)
     : base(queue, FrameType.Color)
 {
     _bitmap = bitmap;
 }
Пример #3
0
 protected FrameConsumer(FrameQueue queue, params FrameType[] frameTypes)
 {
     _queue      = queue;
     _frameTypes = frameTypes;
 }
 public FrameRegistrationProcessor(FrameQueue inQueue, FrameQueue outQueue, Registration registration)
     : base(inQueue, FrameType.Depth, FrameType.Color)
 {
     _outQueue     = outQueue;
     _registration = registration;
 }
Пример #5
0
 protected SingleFrameConsumer(FrameQueue queue, FrameType frameType)
     : base(queue, frameType)
 {
     _frameType = frameType;
 }
Пример #6
0
 public FrameListener(FrameQueue queue, Action <string> logger)
 {
     _queue     = queue;
     _logger    = logger;
     _stopwatch = Stopwatch.StartNew();
 }
Пример #7
0
 public DepthRenderer(FrameQueue queue, WriteableBitmap bitmap)
     : base(queue, FrameType.Depth)
 {
     _bitmap = bitmap;
     _pixels = new byte[_bitmap.PixelWidth * _bitmap.PixelHeight];
 }
 public DummyFrameConsumer(FrameQueue queue, params FrameType[] frameTypes)
     : base(queue, frameTypes)
 {
 }