private void listBoxResultDataSets_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBoxUserResults.ClearSelected();
            listBoxUserResults.Items.Clear();
            onEvaluationRangeChanged(-1, -1);
            OpenNIRecordingController source = (videoDataSource.Source as OpenNIRecordingController);

            if (source != null)
            {
                source.AdditionalSkeletonInformation = null;
                source.AdditionalSkeletonIDs.Clear();
                source.RequestUpdate(true);
            }

            if (listBoxResultDataSets.SelectedItem == null)
            {
                listBoxUserResults.Enabled = false;
            }
            else
            {
                String resultfilename = Path.Combine(current_take_dir.FullName, (String)listBoxResultDataSets.SelectedItem);
                try
                {
                    using (FileStream file = File.Open(resultfilename, FileMode.Open))
                    {
                        resultDictionary = (ImageDictionary)movementDataSerializer.Deserialize(file);
                    }
                    Dictionary <int, int> userActivities = resultDictionary.GetUserStatistics(null);
                    foreach (int userID in userActivities.Keys)
                    {
                        listBoxUserResults.Items.Add("User " + userID);
                    }

                    if (source != null)
                    {
                        source.AdditionalSkeletonInformation = resultDictionary;
                        onEvaluationRangeChanged(resultDictionary.Keys.Min(),
                                                 resultDictionary.Keys.Max());
                    }

                    listBoxUserResults.Enabled = true;
                }
                catch (Exception ex)
                {
                    listBoxUserResults.ClearSelected();
                    listBoxUserResults.Items.Clear();
                    listBoxUserResults.Enabled = false;
                    MessageBox.Show(this,
                                    "An Error occured loading the results file:\n" + ex.Message,
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
        private void trackBarVideo_ValueChanged(object sender, EventArgs e)
        {
            if (e is KeyEventArgs || e is MouseEventArgs)
            {
                OpenNIRecordingController video_src = videoDisplay.Source as OpenNIRecordingController;

                if (video_src != null)
                {
                    video_src.SeekFrame(trackBarVideo.Value);
                    video_src.RequestUpdate(true);
                }
            }
        }
        private void listBoxUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            OpenNIRecordingController source = (videoDataSource.Source as OpenNIRecordingController);

            if ((sender as ListBox) != null &&
                (sender as ListBox) == listBoxUserResults &&
                source != null)
            {
                source.AdditionalSkeletonIDs.Clear();

                if (listBoxUserResults.SelectedItem != null)
                {
                    int uid_results = parseUserID((String)listBoxUserResults.SelectedItem);
                    source.AdditionalSkeletonIDs.Add(uid_results);
                }
                source.RequestUpdate(true);
            }

            if (listBoxUserResults.SelectedItem != null &&
                listBoxUserTruth.SelectedItem != null)
            {
                // Parse the User IDs from the items.
                int uid_truth   = parseUserID((String)listBoxUserTruth.SelectedItem);
                int uid_results = parseUserID((String)listBoxUserResults.SelectedItem);

                // Put the data into the statistics object.
                statistics.SetData(
                    source.UserLocationInformation,
                    resultDictionary, uid_truth, uid_results,
                    new Statistics.To2DConverter(source.Convert3Dto2D));

                // Initialize
                checkedListBoxBodyParts.Enabled        = true;
                buttonBodyPartsAll.Enabled             = true;
                buttonBodyPartsNone.Enabled            = true;
                mediaSliderConfidenceThreshold.Enabled = true;
                selectAllBodyJoints();
                statistics.Calculate(getActiveJoints(),
                                     mediaSliderConfidenceThreshold.Value * mediaSliderValueFactor,
                                     true, source.CurrentFrame);
            }
            else
            {
                clearBodyJointList();
                checkedListBoxBodyParts.Enabled        = false;
                buttonBodyPartsAll.Enabled             = false;
                buttonBodyPartsNone.Enabled            = false;
                mediaSliderConfidenceThreshold.Enabled = false;
                mediaSliderConfidenceThreshold.Value   = 0;
            }
        }
        private void mediaSliderConfidenceThreshold_ValueChanged(object sender, EventArgs e)
        {
            OpenNIRecordingController video = (videoDataSource.Source as OpenNIRecordingController);

            if (video != null)
            {
                video.ConfidenceThreshold = (double)mediaSliderConfidenceThreshold.Value * mediaSliderValueFactor;
                video.RequestUpdate(true);
            }

            List <SkeletonJoint> enabledJoints = getActiveJoints();

            statistics.Calculate(enabledJoints,
                                 (double)mediaSliderConfidenceThreshold.Value * mediaSliderValueFactor,
                                 true, video.CurrentFrame);
        }
示例#5
0
        /// <summary>
        /// Handle key events.
        /// </summary>
        private void MainWindow_KeyUp(object sender, KeyEventArgs e)
        {
            if (tabControlVideoSources.SelectedTab == tabPageCapture &&
                kinect != null)
            {
                switch (e.KeyData)
                {
                case Keys.D:
                    kinect.ImageOrDepth = false;
                    break;

                case Keys.I:
                    kinect.ImageOrDepth = true;
                    break;

                case Keys.L:
                    kinect.DrawUserInformation = !kinect.DrawUserInformation;
                    break;

                case Keys.S:
                    kinect.DrawSkeletonMesh = !kinect.DrawSkeletonMesh;
                    break;

                case Keys.B:
                    kinect.DrawBackground = !kinect.DrawBackground;
                    break;

                case Keys.A:
                    kinect.DrawSensorData = !kinect.DrawSensorData;
                    break;

                case Keys.H:
                    kinect.DrawUserHighlight = !kinect.DrawUserHighlight;
                    break;
                }
            }
            OpenNIRecordingController playback = videoDisplay.Source as OpenNIRecordingController;

            if (tabControlVideoSources.SelectedTab == tabPageExport &&
                playback != null)
            {
                switch (e.KeyData)
                {
                case Keys.D:
                    playback.ImageOrDepth = false;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    break;

                case Keys.I:
                    playback.ImageOrDepth = true;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    break;

                case Keys.S:
                    playback.DrawSkeletonMesh = !playback.DrawSkeletonMesh;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    //e.Handled = true;
                    break;

                case Keys.B:
                    playback.DrawBackground = !playback.DrawBackground;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    break;

                case Keys.H:
                    playback.DrawUserHighlight = !playback.DrawUserHighlight;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    break;

                case Keys.L:
                    playback.DrawUserInformation = !playback.DrawUserInformation;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    break;

                case Keys.A:
                    playback.DrawSensorData = !playback.DrawSensorData;
                    playback.RequestUpdate(true);
                    e.SuppressKeyPress = true;
                    break;

                case Keys.M:
                    buttonMarkFrame.PerformClick();
                    e.SuppressKeyPress = true;
                    break;

                case Keys.E:
                    buttonExport.PerformClick();
                    e.SuppressKeyPress = true;
                    break;

                case Keys.R:
                    buttonResetMarkers.PerformClick();
                    e.SuppressKeyPress = true;
                    break;

                case Keys.P:
                    buttonPlay.PerformClick();
                    e.SuppressKeyPress = true;
                    break;

                case Keys.Left:
                case Keys.Right:
                case Keys.PageDown:
                case Keys.PageUp:
                    if (!trackBarVideo.Focused)
                    {
                        trackBarVideo.Focus();
                    }
                    break;
                }
            }
        }