Inheritance: IKinectSettings
コード例 #1
0
ファイル: KinectV1Core.cs プロジェクト: vancegroup/KVR
        public KinectCoreV1(ref KinectBase.MasterSettings settings, bool isGUILaunched, int?kinectNumber = null)   //Why is the kinectNumber nullable if it is requried later?
        {
            if (kinectNumber != null)
            {
                masterSettings = settings;
                dynamic tempSettings = masterSettings.kinectOptionsList[(int)kinectNumber];  //We have to use dynamic because the type of the Kinect settings in the master list isn't defined until runtime
                masterKinectSettings = (KinectV1Settings)tempSettings;

                //Initialize the object pools
                colorImagePool = new KinectBase.ObjectPool <byte[]>(() => new byte[640 * 480 * 4]);
                depthImagePool = new KinectBase.ObjectPool <byte[]>(() => new byte[640 * 480 * 4]);

                //Note: the kinectNumber could be greater than the number of Kinect v1s if there are other types of sensors in use
                //Therefore, we have to find the correct Kinect, if it exists using this loop
                int globalIndex = -1;
                for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
                {
                    if (KinectSensor.KinectSensors[i].DeviceConnectionId == masterSettings.kinectOptionsList[(int)kinectNumber].uniqueKinectID)
                    {
                        globalIndex = i;
                        break;
                    }
                }
                if (globalIndex >= 0)
                {
                    kinect   = KinectSensor.KinectSensors[globalIndex];
                    kinectID = (int)kinectNumber;
                }
                else
                {
                    throw new System.IndexOutOfRangeException("Specified Kinect sensor does not exist");
                }

                if (isGUILaunched)
                {
                    isGUI = true;
                    LaunchKinect();
                }
                else
                {
                    launchKinectDelegate kinectDelegate = LaunchKinect;
                    IAsyncResult         result         = kinectDelegate.BeginInvoke(null, null);
                    kinectDelegate.EndInvoke(result);  //Even though this is blocking, the events should be on a different thread now.
                }
            }
            else
            {
                //TODO: Open the default Kinect?
                throw new NullReferenceException("To create a KinectCore object, the KinectNumber must be valid.");
            }
        }
コード例 #2
0
ファイル: KinectV1Core.cs プロジェクト: vancegroup/KVR
        //Why is the kinectNumber nullable if it is requried later?
        public KinectCoreV1(ref KinectBase.MasterSettings settings, bool isGUILaunched, int? kinectNumber = null)
        {
            if (kinectNumber != null)
            {
                masterSettings = settings;
                dynamic tempSettings = masterSettings.kinectOptionsList[(int)kinectNumber];  //We have to use dynamic because the type of the Kinect settings in the master list isn't defined until runtime
                masterKinectSettings = (KinectV1Settings)tempSettings;

                //Initialize the object pools
                colorImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[640 * 480 * 4]);
                depthImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[640 * 480 * 4]);

                //Note: the kinectNumber could be greater than the number of Kinect v1s if there are other types of sensors in use
                //Therefore, we have to find the correct Kinect, if it exists using this loop
                int globalIndex = -1;
                for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
                {
                    if (KinectSensor.KinectSensors[i].DeviceConnectionId == masterSettings.kinectOptionsList[(int)kinectNumber].uniqueKinectID)
                    {
                        globalIndex = i;
                        break;
                    }
                }
                if (globalIndex >= 0)
                {
                    kinect = KinectSensor.KinectSensors[globalIndex];
                    kinectID = (int)kinectNumber;
                }
                else
                {
                    throw new System.IndexOutOfRangeException("Specified Kinect sensor does not exist");
                }

                if (isGUILaunched)
                {
                    isGUI = true;
                    LaunchKinect();
                }
                else
                {
                    launchKinectDelegate kinectDelegate = LaunchKinect;
                    IAsyncResult result = kinectDelegate.BeginInvoke(null, null);
                    kinectDelegate.EndInvoke(result);  //Even though this is blocking, the events should be on a different thread now.
                }
            }
            else
            {
                //TODO: Open the default Kinect?
                throw new NullReferenceException("To create a KinectCore object, the KinectNumber must be valid.");
            }
        }
コード例 #3
0
        public KinectV1SettingsControl(int kinectNumber, ref KinectBase.MasterSettings settings, KinectBase.IKinectCore kinect)
        {
            if (settings != null)
            {
                if (settings.kinectOptionsList[kinectNumber].version == KinectBase.KinectVersion.KinectV1)
                {
                    masterSettings = settings;
                    dynamic tempSettings = settings.kinectOptionsList[kinectNumber];
                    kinectSettings = (KinectV1Settings)tempSettings;
                    kinectID = kinectNumber;
                    kinectCore = (KinectCoreV1)kinect;
                    kinectCore.AccelerationChanged += kinectCore_AccelerationChanged;
                    uniqueKinectID = kinect.uniqueKinectID;

                    InitializeComponent();

                    this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    this.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                    //This moved to the wrapper
                    //Grid.SetColumn(this, 2);
                    //this.Visibility = System.Windows.Visibility.Collapsed;

                    if (kinectCore.isXbox360Kinect != null && (bool)kinectCore.isXbox360Kinect)
                    {
                        DisableK4WOnlyOptions();
                    }
                }
                else
                {
                    throw new ArgumentException("The provided KinectID is not for a Kinect v1 sensor.");
                }
            }
            else
            {
                throw new ArgumentNullException("settings");
            }
        }
コード例 #4
0
        public KinectV1SettingsControl(int kinectNumber, ref KinectBase.MasterSettings settings, KinectBase.IKinectCore kinect)
        {
            if (settings != null)
            {
                if (settings.kinectOptionsList[kinectNumber].version == KinectBase.KinectVersion.KinectV1)
                {
                    masterSettings = settings;
                    dynamic tempSettings = settings.kinectOptionsList[kinectNumber];
                    kinectSettings = (KinectV1Settings)tempSettings;
                    kinectID       = kinectNumber;
                    kinectCore     = (KinectCoreV1)kinect;
                    kinectCore.AccelerationChanged += kinectCore_AccelerationChanged;
                    uniqueKinectID = kinect.uniqueKinectID;

                    InitializeComponent();

                    this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    this.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                    //This moved to the wrapper
                    //Grid.SetColumn(this, 2);
                    //this.Visibility = System.Windows.Visibility.Collapsed;

                    if (kinectCore.isXbox360Kinect != null && (bool)kinectCore.isXbox360Kinect)
                    {
                        DisableK4WOnlyOptions();
                    }
                }
                else
                {
                    throw new ArgumentException("The provided KinectID is not for a Kinect v1 sensor.");
                }
            }
            else
            {
                throw new ArgumentNullException("settings");
            }
        }
コード例 #5
0
ファイル: KV1Settings.cs プロジェクト: vancegroup/KVR
 //Needed for serialization
 public Settings()
 {
     realSettings = new KinectV1Settings();
 }
コード例 #6
0
ファイル: KV1Settings.cs プロジェクト: vancegroup/KVR
 //Constructor to setup the real KinectV1Settings object
 public Settings(string uniqueID, int kinectNumber)
 {
     realSettings = new KinectV1Settings(uniqueID, kinectNumber);
 }
コード例 #7
0
        public void UpdateGUI(KinectBase.MasterSettings newSettings)
        {
            if (kinectID.HasValue)
            {
                masterSettings = newSettings;
                dynamic tempSettings = masterSettings.kinectOptionsList[kinectID.Value];
                kinectSettings = (KinectV1Settings)tempSettings;

                //Update the color options
                switch (kinectSettings.colorImageMode)
                {
                    case KinectBase.ColorImageFormat.RgbResolution640x480Fps30:
                    {
                        colorResComboBox.SelectedIndex = 0;
                        break;
                    }
                    case KinectBase.ColorImageFormat.RgbResolution1280x960Fps12:
                    {
                        colorResComboBox.SelectedIndex = 1;
                        break;
                    }
                    case KinectBase.ColorImageFormat.InfraredResolution640x480Fps30:
                    {
                        colorResComboBox.SelectedIndex = 2;
                        break;
                    }
                    default:
                    {
                        //If we don't know how to handle a mode, lets just shut it off
                        colorResComboBox.SelectedIndex = 3;
                        break;
                    }
                }

                //Update the skeleton settings
                UseSkeletonCheckBox.IsChecked = kinectSettings.mergeSkeletons;
                UseRawSkeletonCheckBox.IsChecked = kinectSettings.sendRawSkeletons;
                XFormRawSkeletonCheckBox.IsChecked = kinectSettings.transformRawSkeletons;
                SeatedModeCheckBox.IsChecked = kinectSettings.rawSkeletonSettings.isSeatedMode;

                //Update the depth settings
                irOnCheckBox.IsChecked = kinectSettings.irON;
                nearModeCheckBox.IsChecked = kinectSettings.isNearMode;
                switch (kinectSettings.depthImageMode)
                {
                    case KinectBase.DepthImageFormat.Resolution320x240Fps30:
                    {
                        depthResComboBox.SelectedIndex = 1;
                        break;
                    }
                    case KinectBase.DepthImageFormat.Resolution80x60Fps30:
                    {
                        depthResComboBox.SelectedIndex = 2;
                        break;
                    }
                    default:
                    {
                        depthResComboBox.SelectedIndex = 0;
                        break;
                    }
                }

                //Update the audio settings
                SendSoundAngleCheckBox.IsChecked = kinectSettings.sendAudioAngle;
                audioServerTextBox.Text = kinectSettings.audioAngleServerName;
                audioChannelTextBox.Text = kinectSettings.audioAngleChannel.ToString();
                audioBeamSkeletonNumberTextBox.Text = kinectSettings.audioBeamTrackSkeletonNumber.ToString();
                switch (kinectSettings.audioTrackMode)
                {
                    //Note: the enabled/disabled controls don't need to be set manually here because the selected index changed event will still be hit
                    case KinectBase.AudioTrackingMode.Feedback:
                    {
                        audioBeamModeComboBox.SelectedIndex = 1;
                        break;
                    }
                    case KinectBase.AudioTrackingMode.MergedSkeletonX:
                    {
                        audioBeamModeComboBox.SelectedIndex = 2;
                        break;
                    }
                    case KinectBase.AudioTrackingMode.LocalSkeletonX:
                    {
                        audioBeamModeComboBox.SelectedIndex = 3;
                        break;
                    }
                    default:
                    {
                        audioBeamModeComboBox.SelectedIndex = 0;
                        break;
                    }
                }

                //Update the acceleration options
                SendAccelCheckBox.IsChecked = kinectSettings.sendAcceleration;
                accelServerTextBox.Text = kinectSettings.accelerationServerName;
                accelXChannelTextBox.Text = kinectSettings.accelXChannel.ToString();
                accelYChannelTextBox.Text = kinectSettings.accelYChannel.ToString();
                accelZChannelTextBox.Text = kinectSettings.accelZChannel.ToString();

                //Update the position options
                xPosTextBox.Text = kinectSettings.kinectPosition.X.ToString();
                yPosTextBox.Text = kinectSettings.kinectPosition.Y.ToString();
                zPosTextBox.Text = kinectSettings.kinectPosition.Z.ToString();
                yawPosTextBox.Text = kinectSettings.kinectYaw.ToString();
            }
        }
コード例 #8
0
        public void UpdateGUI(KinectBase.MasterSettings newSettings)
        {
            if (kinectID.HasValue)
            {
                masterSettings = newSettings;
                dynamic tempSettings = masterSettings.kinectOptionsList[kinectID.Value];
                kinectSettings = (KinectV1Settings)tempSettings;

                //Update the color options
                switch (kinectSettings.colorImageMode)
                {
                case KinectBase.ColorImageFormat.RgbResolution640x480Fps30:
                {
                    colorResComboBox.SelectedIndex = 0;
                    break;
                }

                case KinectBase.ColorImageFormat.RgbResolution1280x960Fps12:
                {
                    colorResComboBox.SelectedIndex = 1;
                    break;
                }

                case KinectBase.ColorImageFormat.InfraredResolution640x480Fps30:
                {
                    colorResComboBox.SelectedIndex = 2;
                    break;
                }

                default:
                {
                    //If we don't know how to handle a mode, lets just shut it off
                    colorResComboBox.SelectedIndex = 3;
                    break;
                }
                }

                //Update the skeleton settings
                UseSkeletonCheckBox.IsChecked      = kinectSettings.mergeSkeletons;
                UseRawSkeletonCheckBox.IsChecked   = kinectSettings.sendRawSkeletons;
                XFormRawSkeletonCheckBox.IsChecked = kinectSettings.transformRawSkeletons;
                SeatedModeCheckBox.IsChecked       = kinectSettings.rawSkeletonSettings.isSeatedMode;

                //Update the depth settings
                irOnCheckBox.IsChecked     = kinectSettings.irON;
                nearModeCheckBox.IsChecked = kinectSettings.isNearMode;
                switch (kinectSettings.depthImageMode)
                {
                case KinectBase.DepthImageFormat.Resolution320x240Fps30:
                {
                    depthResComboBox.SelectedIndex = 1;
                    break;
                }

                case KinectBase.DepthImageFormat.Resolution80x60Fps30:
                {
                    depthResComboBox.SelectedIndex = 2;
                    break;
                }

                default:
                {
                    depthResComboBox.SelectedIndex = 0;
                    break;
                }
                }

                //Update the audio settings
                SendSoundAngleCheckBox.IsChecked    = kinectSettings.sendAudioAngle;
                audioServerTextBox.Text             = kinectSettings.audioAngleServerName;
                audioChannelTextBox.Text            = kinectSettings.audioAngleChannel.ToString();
                audioBeamSkeletonNumberTextBox.Text = kinectSettings.audioBeamTrackSkeletonNumber.ToString();
                switch (kinectSettings.audioTrackMode)
                {
                //Note: the enabled/disabled controls don't need to be set manually here because the selected index changed event will still be hit
                case KinectBase.AudioTrackingMode.Feedback:
                {
                    audioBeamModeComboBox.SelectedIndex = 1;
                    break;
                }

                case KinectBase.AudioTrackingMode.MergedSkeletonX:
                {
                    audioBeamModeComboBox.SelectedIndex = 2;
                    break;
                }

                case KinectBase.AudioTrackingMode.LocalSkeletonX:
                {
                    audioBeamModeComboBox.SelectedIndex = 3;
                    break;
                }

                default:
                {
                    audioBeamModeComboBox.SelectedIndex = 0;
                    break;
                }
                }

                //Update the acceleration options
                SendAccelCheckBox.IsChecked = kinectSettings.sendAcceleration;
                accelServerTextBox.Text     = kinectSettings.accelerationServerName;
                accelXChannelTextBox.Text   = kinectSettings.accelXChannel.ToString();
                accelYChannelTextBox.Text   = kinectSettings.accelYChannel.ToString();
                accelZChannelTextBox.Text   = kinectSettings.accelZChannel.ToString();

                //Update the position options
                xPosTextBox.Text   = kinectSettings.kinectPosition.X.ToString();
                yPosTextBox.Text   = kinectSettings.kinectPosition.Y.ToString();
                zPosTextBox.Text   = kinectSettings.kinectPosition.Z.ToString();
                yawPosTextBox.Text = kinectSettings.kinectYaw.ToString();
            }
        }