Exemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the DepthWithColor viewer control
        /// </summary>
        /// <param name="sensor">Instance of the KinectSensor object</param>
        /// <returns>Returns an instance of the control</returns>
        private static SwapChainPanel CreateDepthwithColor(KinectSensor sensor)
        {
            DepthMapPanel control = new DepthMapPanel();

            control.DepthSource = sensor.DepthFrameSource;
            control.PanelMode   = DEPTH_PANEL_MODE.DEPTH_RAMP;

            return(control);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialization of the main camera panel and other properties of the window
        /// </summary>
        /// <param name="sender">sender of the event</param>
        /// <param name="e">event parameters</param>
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // configure each camera with appropriate Kinect Source
            var modeLst = (DEPTH_PANEL_MODE[])Enum.GetValues(typeof(DEPTH_PANEL_MODE));

            this.cameraDataMode = modeLst.OfType <DEPTH_PANEL_MODE>().ToList();

            // remove depth ramp w/color as an option in the camera view
            this.cameraDataMode.RemoveAt(this.cameraDataMode.IndexOf(DEPTH_PANEL_MODE.DEPTH_RAMP));

            // set last panel
            this.lastCameraPanel = this.cameraDataMode[0];

            // get the sensor
            this.kinectSSensor = KinectSensor.GetDefault();
            this.kinectSSensor.IsAvailableChanged += this.IsAvailableChanged;
            this.kinectSSensor.Open();

            // create depth swappanel
            this.lastSwapChainPanel = new DepthMapPanel()
            {
                CoordinateMapper = this.kinectSSensor.CoordinateMapper,
                DepthSource      = this.kinectSSensor.DepthFrameSource,
                InfraredSource   = this.kinectSSensor.InfraredFrameSource,
                ColorSource      = this.kinectSSensor.ColorFrameSource,
                PanelMode        = this.lastCameraPanel
            };

            // set the camera on the panel
            this.CameraPreview.Child = this.lastSwapChainPanel;

            // get the tech collection
            ThumbnailViewModel viewModel = new ThumbnailViewModel(this.kinectSSensor);
            var result = from t in viewModel.Panels
                         where t.PanelType == DXSwapPanel.Type.Tech
                         group t by t.PanelType into g
                         orderby g.Key
                         select new { Key = g.Key, Items = g };

            ThumbnailsSource.Source = result;

            // select the first item from the collection
            this.lastSelectedTechIndex = -1;
        }
Exemplo n.º 3
0
        /// <summary>
        /// switches the camera panel to next source view
        /// </summary>
        /// <param name="direction">navigate forward or back</param>
        private void SwitchCameraView(Direction direction = Direction.Forward)
        {
            int oldID = this.cameraDataMode.IndexOf(this.lastCameraPanel);
            int newID = oldID + ((direction == Direction.Forward) ? 1 : -1);

            if (newID >= this.cameraDataMode.Count)
            {
                newID = 0;
            }
            else if (newID < 0)
            {
                newID = this.cameraDataMode.Count - 1;
            }

            this.lastCameraPanel = this.cameraDataMode[newID];

            DepthMapPanel view = this.lastSwapChainPanel as DepthMapPanel;

            if (view != null)
            {
                view.PanelMode = this.lastCameraPanel;
            }
        }