Example #1
0
        private void AnalyzeGaitButton_Click(object sender, RoutedEventArgs e)
        {
            AnalysisVideo vid = (AnalysisVideo)GaitListBox.SelectedItem; //get the selected video

            if (vid != null)
            {
                string gaitVideoPath = vid.Path; //extract necessary info from the video
                string gaitVideoName = gaitVideoPath.Substring(gaitVideoPath.LastIndexOf("\\") + 1, gaitVideoPath.LastIndexOf(".") - gaitVideoPath.LastIndexOf("\\"));
                string gaitTempPath  = gaitVideoPath.Substring(0, gaitVideoPath.LastIndexOf("\\")) + "\\temp-" + gaitVideoName;
                var    files         = Directory.EnumerateFiles(gaitTempPath);
                var    file          = ""; //might crash
                foreach (var currentImg in files)
                {
                    if (currentImg.Contains(".png"))
                    {
                        file = currentImg;
                        break;
                    }
                }
                BarInteraction();

                // Check if Gait data is saved from before
                string stateFolder = gaitVideoPath.Substring(0, gaitVideoPath.LastIndexOf("\\")) + "\\gaitsavedstate";
                if (Directory.Exists(stateFolder) && File.Exists(stateFolder + "\\inputParams.txt"))
                {
                    GaitWindow gaitWindow = new GaitWindow(gaitVideoPath, gaitVideoName, gaitTempPath);
                    if (gaitWindow.ShowDialog() == true)
                    {
                        SyncUI();
                    }
                    EnableInteraction();
                }
                else //input params not saved, ask the user for'em
                {
                    MeasureWindow window = new MeasureWindow(file, stateFolder); //spawn a window through which the user will give us the treadmill speed and a real world reference (for distance measurements)
                    if (window.ShowDialog() == true)
                    {
                        double realWorldMultiplier = window.getSinglePixelSize();
                        float  treadmillSpeed      = float.Parse(window.TreadmillSpeedTextBox.Text);
                        bool   isFreeRun           = false;
                        if ((bool)window.AnalysisTypeRadioFreeWalking.IsChecked)
                        {
                            isFreeRun = true;
                        }

                        GaitWindow gaitWindow = new GaitWindow(realWorldMultiplier, treadmillSpeed, gaitVideoPath, gaitVideoName, gaitTempPath, isFreeRun);
                        if (gaitWindow.ShowDialog() == true)
                        {
                            SyncUI();
                        }
                        EnableInteraction();
                    }
                    else
                    {
                        EnableInteraction();
                    }
                }
            }
        }
Example #2
0
        // Adjust Settings Button
        private void GaitAdjustSettingsButton_Click(object sender, RoutedEventArgs e)
        {
            string stateFolder = GaitVideoPath.Substring(0, GaitVideoPath.LastIndexOf("\\")) + "\\gaitsavedstate";

            string gaitVideoName = GaitVideoPath.Substring(GaitVideoPath.LastIndexOf("\\") + 1, GaitVideoPath.LastIndexOf(".") - GaitVideoPath.LastIndexOf("\\"));
            string gaitTempPath  = GaitVideoPath.Substring(0, GaitVideoPath.LastIndexOf("\\")) + "\\temp-" + gaitVideoName;
            var    files         = Directory.EnumerateFiles(gaitTempPath);
            var    file          = ""; //might crash

            foreach (var currentImg in files)
            {
                if (currentImg.Contains(".png"))
                {
                    file = currentImg;
                    break;
                }
            }
            BarInteraction();

            MeasureWindow window = new MeasureWindow(file, stateFolder); //spawn the same settings window as before

            if (window.ShowDialog() == true)
            {
                RealWorldMultiplier = window.getSinglePixelSize();
                TreadmillSpeed      = float.Parse(window.TreadmillSpeedTextBox.Text);
                if ((bool)window.AnalysisTypeRadioFreeWalking.IsChecked)
                {
                    IsFreeRun = true;
                }
                else
                {
                    IsFreeRun = false;
                }

                SetStaticData();
                UpdateFrame(false);
                EnableInteraction();
            }
            else
            {
                EnableInteraction();
            }
        }