コード例 #1
0
ファイル: NetworkKinectCore.cs プロジェクト: vancegroup/KVR
        public NetworkKinectCore(ref MasterSettings settings, bool isGUILaunched, int kinectNumber, string name)
        {
            nkName = name;
            masterSettings = settings;
            dynamic tempSettings = masterSettings.kinectOptionsList[(int)kinectNumber];  //Because of the wrapper, we have to go through a dynamic variable
            masterKinectSettings = (NetworkKinectSettings)tempSettings;
            kinectID = kinectNumber;

            isGUI = isGUILaunched;
            //NOTE: unlike the physical Kinect sensors, network Kinect sensors are not launched on the creation of the core
        }
コード例 #2
0
        //Constructor to setup the real NetworkKinectSettingsControl
        public SettingsControl(int kinectNumber, ref MasterSettings settings, IKinectCore kinect)
        {
            InitializeComponent();
            Grid.SetColumn(this, 2);
            this.Visibility = System.Windows.Visibility.Collapsed;

            Core coreWrapper = (Core)kinect;
            NetworkKinectCore.NetworkKinectCore kinectCore = (NetworkKinectCore.NetworkKinectCore)coreWrapper;
            realControl = new NetworkKinectSettingsControl(kinectNumber, ref settings, kinectCore);
            realControl.Visibility = System.Windows.Visibility.Visible;
            this.MasterGrid.Children.Add((UserControl)realControl);
        }
コード例 #3
0
ファイル: KV1Core.cs プロジェクト: vancegroup/KVR
        //Constructor to setup the real KinectV1Core object
        public Core(ref MasterSettings settings, bool isGUILaunched, int? kinectNumber = null)
        {
            realCore = new KinectCoreV1(ref settings, isGUILaunched, kinectNumber);

            //Subscribe to the events so they can be forwarded
            realCore.SkeletonChanged += realCore_SkeletonChanged;
            realCore.DepthFrameReceived += realCore_DepthFrameReceived;
            realCore.ColorFrameReceived += realCore_ColorFrameReceived;
            realCore.AccelerationChanged += realCore_AccelerationChanged;
            realCore.AudioPositionChanged += realCore_AudioPositionChanged;
            realCore.LogMessageGenerated += realCore_LogMessageGenerated;
        }
コード例 #4
0
ファイル: HelperMethods.cs プロジェクト: tsky1971/KVR
        internal static KinectBase.MasterSettings LoadSettings(string fileName)
        {
            KinectBase.MasterSettings settings     = null;
            XmlSerializer             serializer   = new XmlSerializer(typeof(SerializableSettings));
            SerializableSettings      tempSettings = null;

            FileInfo info = new FileInfo(fileName);

            if (info.Exists)
            {
                using (FileStream file = new FileStream(fileName, FileMode.Open))
                {
                    tempSettings = (SerializableSettings)serializer.Deserialize(file);
                    file.Close();
                    file.Dispose();
                }
            }
            else
            {
                throw new Exception("File does not exist!");
            }

            //Copy the settings from the serializable settings object to the real settings object
            settings = tempSettings.masterSettings;
            settings.kinectOptionsList = new List <IKinectSettings>();
            for (int i = 0; i < tempSettings.kinectV1Settings.Length; i++)
            {
                settings.kinectOptionsList.Add(tempSettings.kinectV1Settings[i]);
            }
            for (int i = 0; i < tempSettings.kinectV2Settings.Length; i++)
            {
                settings.kinectOptionsList.Add(tempSettings.kinectV2Settings[i]);
            }
            for (int i = 0; i < tempSettings.networkKinectSettings.Length; i++)
            {
                settings.kinectOptionsList.Add(tempSettings.networkKinectSettings[i]);
            }

            settings.kinectOptionsList.Sort(new KinectBase.KinectSettingsComparer());

            return(settings);
        }
コード例 #5
0
ファイル: HelperMethods.cs プロジェクト: tsky1971/KVR
        internal static void SaveSettings(string fileName, KinectBase.MasterSettings settings)
        {
            //Create a serializable version of the settings (basically, move the Kinect options from the Master settings to a type specific array)
            List <KinectV1Wrapper.Settings>      kinect1Settings = new List <KinectV1Wrapper.Settings>();
            List <KinectV2Wrapper.Settings>      kinect2Settings = new List <KinectV2Wrapper.Settings>();
            List <NetworkKinectWrapper.Settings> networkSettings = new List <NetworkKinectWrapper.Settings>();

            for (int i = 0; i < settings.kinectOptionsList.Count; i++)
            {
                if (settings.kinectOptionsList[i].version == KinectVersion.KinectV1)
                {
                    kinect1Settings.Add((KinectV1Wrapper.Settings)settings.kinectOptionsList[i]);
                }
                else if (settings.kinectOptionsList[i].version == KinectVersion.KinectV2)
                {
                    kinect2Settings.Add((KinectV2Wrapper.Settings)settings.kinectOptionsList[i]);
                }
                else if (settings.kinectOptionsList[i].version == KinectVersion.NetworkKinect)
                {
                    networkSettings.Add((NetworkKinectWrapper.Settings)settings.kinectOptionsList[i]);
                }
            }
            SerializableSettings serialSettings = new SerializableSettings();

            serialSettings.masterSettings        = settings;
            serialSettings.kinectV1Settings      = kinect1Settings.ToArray();
            serialSettings.kinectV2Settings      = kinect2Settings.ToArray();
            serialSettings.networkKinectSettings = networkSettings.ToArray();

            //Do the actual serialization
            XmlSerializer serializer = new XmlSerializer(typeof(SerializableSettings));

            using (FileStream file = new FileStream(fileName, FileMode.Create))
            {
                serializer.Serialize(file, serialSettings);
                file.Close();
                file.Dispose();
            }
        }
コード例 #6
0
 //Public properties specific to the network Kinect
 //Public methods required by the IKinectSettingsControl interface
 public void UpdateGUI(MasterSettings newSettings)
 {
     realControl.UpdateGUI(newSettings);
 }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: vancegroup/KVR
        private void Window_Initialized(object sender, EventArgs e)
        {
            //Report to the log which Kinect versions are unavaliable
            if (!avaliableDLLs.HasKinectV1)
            {
                HelperMethods.WriteToLog("Warning: Kinect v1 support is unvaliable due to missing DLLs!", this);
            }
            if (!avaliableDLLs.HasKinectV2)
            {
                HelperMethods.WriteToLog("Warning: Kinect v2 support is unvaliable due to missing DLLs!", this);
            }
            if (!avaliableDLLs.HasNetworkedKinect)
            {
                HelperMethods.WriteToLog("Warning: Networked Kinect support is unvaliable due to missing DLLs!", this);
                //Remove the option to add a networked kinect if the dll isn't avaliable
                nkStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                AddNKButton.IsEnabled = false;
            }

            //Setup the timer to update the GUI with the server runtime
            uptimeUpdateTimer = new System.Timers.Timer();
            uptimeUpdateTimer.Interval = 500;
            uptimeUpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(uptimeUpdateTimer_Elapsed);

            KinectBase.MasterSettings tempSettings = new KinectBase.MasterSettings();

            //Create the server core (this does NOT start the server)
            server = new ServerCore(verbose, tempSettings, this);

            //Set all the data for the data grids
            VoiceButtonDataGrid.ItemsSource = server.serverMasterOptions.voiceButtonCommands;
            VoiceTextDataGrid.ItemsSource = server.serverMasterOptions.voiceTextCommands;

            if (startupFile != null && startupFile != "")
            {
                try
                {
                    server.serverMasterOptions = HelperMethods.LoadSettings(startupFile);
                    UpdateGUISettings();
                }
                catch
                {
                    MessageBox.Show("Error: The startup settings file failed to load!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HelperMethods.WriteToLog("Startup settings (" + startupFile + ") failed to load.");
                }
            }

            //TODO: Handle starting Kinects based on the loaded settings file
            //Initialize the data for the available Kinect v1s
            if (avaliableDLLs.HasKinectV1)
            {
                KinectV1Wrapper.StatusEventArgs[] currentStatuses = KinectV1Wrapper.StatusHelper.GetAllKinectsStatus();
                for (int i = 0; i < currentStatuses.Length; i++)
                {
                    AvailableKinectData tempData = new AvailableKinectData();

                    tempData.UniqueID = currentStatuses[i].UniqueKinectID;
                    tempData.Status = currentStatuses[i].Status;
                    tempData.KinectTypeString = GetKinectTypeString(currentStatuses[i].Status, currentStatuses[i].isXBox360Kinect);
                    tempData.kinectType = KinectVersion.KinectV1;

                    if (i == 0 && tempData.Status == KinectStatus.Connected)
                    {
                        tempData.UseKinect = true;
                        tempData.KinectID = 0;
                        server.serverMasterOptions.kinectOptionsList.Add((IKinectSettings)(new KinectV1Wrapper.Settings(tempData.UniqueID, (int)tempData.KinectID)));
                        server.kinects.Add((new KinectV1Wrapper.Core(ref server.serverMasterOptions, true, (int)tempData.KinectID)));
                        tempData.ServerStatus = "Running";
                    }
                    else
                    {
                        tempData.UseKinect = false;
                        tempData.KinectID = null;
                    }
                    tempData.PropertyChanged += useKinect_PropertyChanged;
                    availableKinects.Add(tempData);
                }
            }

            //Initialize the data for the available Kinect v2s
            if (avaliableDLLs.HasKinectV2)
            {
                KinectV2Wrapper.StatusHelper.StartKinectV2Service();
                KinectV2Wrapper.StatusEventArgs[] currentStatuses2 = KinectV2Wrapper.StatusHelper.GetAllKinectsStatus();
                for (int i = 0; i < currentStatuses2.Length; i++)
                {
                    AvailableKinectData tempData = new AvailableKinectData();

                    tempData.UniqueID = currentStatuses2[i].UniqueKinectID;
                    tempData.Status = currentStatuses2[i].Status;
                    tempData.KinectTypeString = "Kinect v2";
                    tempData.kinectType = KinectVersion.KinectV2;
                    //Note: Unlike the Kinect v1, we don't automatically launch a Kinect v2
                    tempData.UseKinect = false;
                    tempData.KinectID = null;
                    tempData.PropertyChanged += useKinect_PropertyChanged;
                    availableKinects.Add(tempData);
                }
            }

            KinectStatusBlock.Text = availableKinects.Count.ToString();
            kinectsAvailableDataGrid.ItemsSource = availableKinects;
            UpdatePageListing();
            GenerateImageSourcePickerLists();

            if (avaliableDLLs.HasKinectV1)
            {
                //Subscribe to the v1 status changed event
                KinectV1Wrapper.StatusHelper v1StatusHelper = new KinectV1Wrapper.StatusHelper();
                v1StatusHelper.StatusChanged += v1StatusHelper_KinectV1StatusChanged;
            }
            if (avaliableDLLs.HasKinectV2)
            {
                //Subscribe to the v2 status changed event
                KinectV2Wrapper.StatusHelper v2StatusHelper = new KinectV2Wrapper.StatusHelper();
                v2StatusHelper.StatusChanged += v2StatusHelper_KinectV2StatusChanged;
            }

            //Populate the skeleton data and set the binding for the data grid
            GenerateSkeletonDataGridData();
            SkeletonSettingsDataGrid.ItemsSource = server.serverMasterOptions.mergedSkeletonOptions.individualSkeletons;

            //Populate and setup the voice recognition lists
            GenerateVoiceRecogEngineList();
            GenerateAudioSourceList();
            VoiceKinectComboBox.SelectedIndex = 0;

            //Set defaults where needed
            FeedbackJointTypeComboBox.SelectedIndex = 0;
            SkelSortModeComboBox.SelectedIndex = 5;

            //Set the items source for the servers display grid
            ServersDataGrid.ItemsSource = configuredServers;

            //Set the initial shader for the depth image
            depthEffect = new Shaders.NoScalingEffect();
            DepthImage.Effect = depthEffect;

            if (startOnLaunch)
            {
                startServerButton_Click(this, new RoutedEventArgs());
            }
        }