private void OpenVideo() { string fileLocation; if (string.IsNullOrWhiteSpace(FileLocation)) { fileLocation = FileBrowser.BroseForVideoFiles(); } else { fileLocation = FileLocation; } if (string.IsNullOrWhiteSpace(fileLocation)) { return; } Video.SetVideo(fileLocation); VideoSettings.FileName = fileLocation; VideoSettings.ThresholdValue = ThresholdValue; //VideoSettings. SliderMaximum = Video.FrameCount; Image <Gray, Byte> binaryBackground; IEnumerable <IBoundaryBase> boundaries; VideoSettings.GeneratePreview(Video, out binaryBackground, out boundaries); BinaryBackground = binaryBackground; Image2 = ImageService.ToBitmapSource(BinaryBackground); SliderValue = 0; }
private void BrowseForUnitVideo() { string filePath = FileBrowser.BroseForVideoFiles(); if (string.IsNullOrWhiteSpace(filePath)) { return; } using (IVideo video = ModelResolver.Resolve <IVideo>()) { video.SetVideo(filePath); using (Image <Bgr, Byte> image = video.GetFrameImage()) { Image = image.ToBitmap(); PickUnitsPointsViewModel viewModel = new PickUnitsPointsViewModel(Image); PickUnitsPointsView view = new PickUnitsPointsView() { DataContext = viewModel, }; view.ShowDialog(); if (viewModel.OkPressed) { PixelDistance = viewModel.GetDistance(); } } } }
private void OpenFile(string fileName) { XmlSerializer serializer = new XmlSerializer(typeof(WhiskerTrackerXml)); WhiskerTrackerXml whiskerTracker; using (StreamReader reader = new StreamReader(fileName)) { whiskerTracker = (WhiskerTrackerXml)serializer.Deserialize(reader); } if (!File.Exists(whiskerTracker.ClipSettings.ClipFilePath)) { MessageBoxResult result = MessageBox.Show("File not found, would you like to browse for it?", "File not found", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { whiskerTracker.ClipSettings.ClipFilePath = FileBrowser.BroseForVideoFiles(); if (string.IsNullOrWhiteSpace(whiskerTracker.ClipSettings.ClipFilePath)) { return; } } else { return; } } WorkingFile = fileName; WhiskerVideo = ModelResolver.Resolve <IWhiskerVideo>(); WhiskerVideo.SetVideo(whiskerTracker.ClipSettings.ClipFilePath); m_VideoWidth = (int)WhiskerVideo.Width; m_VideoHeight = (int)WhiskerVideo.Height; FrameCount = WhiskerVideo.FrameCount; GlobalSettings.GlobalSettings.ClipSettings = whiskerTracker.ClipSettings.GetClipSettings(); GlobalSettings.GlobalSettings.ClipSettings.Commit(); GlobalSettings.GlobalSettings.UnitSettings = whiskerTracker.UnitSettings.GetSettings(); GlobalSettings.GlobalSettings.UnitSettings.Commit(); GlobalSettings.GlobalSettings.FrameRateSettings = whiskerTracker.FrameRateSettings.GetSettings(); GlobalSettings.GlobalSettings.FrameRateSettings.Commit(); Image = null; Started = false; VideoSelected = true; ClearUndoActions(); Dictionary <int, MouseFrameViewModel> frames = new Dictionary <int, MouseFrameViewModel>(); foreach (MouseFrameXml mouseFrame in whiskerTracker.Frames) { frames.Add(mouseFrame.IndexNumber, new MouseFrameViewModel(mouseFrame.GetMouseFrame())); } StartPicking(frames); }
private void AddNtgFile() { string fileLocation = FileBrowser.BroseForVideoFiles(); if (string.IsNullOrWhiteSpace(fileLocation)) { return; } ObservableCollection <string> currentList = new ObservableCollection <string>(NtgItemsSource); currentList.Add(fileLocation); NtgItemsSource = currentList; }
private void NewSession() { string fileName = FileBrowser.BroseForVideoFiles(); if (string.IsNullOrWhiteSpace(fileName)) { return; } WhiskerVideo = ModelResolver.Resolve <IWhiskerVideo>(); WhiskerVideo.SetVideo(fileName); m_VideoWidth = (int)WhiskerVideo.Width; m_VideoHeight = (int)WhiskerVideo.Height; FrameCount = WhiskerVideo.FrameCount; ClipSettingsView clipSettingsView = new ClipSettingsView(); ClipSettingsWindowViewModel viewModel = new ClipSettingsWindowViewModel(WhiskerVideo); clipSettingsView.DataContext = viewModel; clipSettingsView.ShowDialog(); if (viewModel.ExitResult != WindowExitResult.Ok) { return; } IClipSettings clipSettings = viewModel.Model; GlobalSettings.GlobalSettings.ClipSettings = clipSettings; GlobalSettings.GlobalSettings.ClipSettings.Commit(); GlobalSettings.GlobalSettings.FrameRateSettings.CurrentFrameRate = WhiskerVideo.FrameRate; GlobalSettings.GlobalSettings.FrameRateSettings.OriginalFrameRate = viewModel.OriginalFrameRate; Image = null; Started = false; VideoSelected = true; StartPicking(); WorkingFile = string.Empty; ClearUndoActions(); }
private void AddTgFile() { string fileLocation = FileBrowser.BroseForVideoFiles(); if (string.IsNullOrWhiteSpace(fileLocation)) { return; } ISingleMouse newFile = ModelResolver.Resolve <ISingleMouse>(); newFile.AddFile(GetSingleFile(fileLocation)); newFile.Name = Path.GetFileNameWithoutExtension(fileLocation); SingleMouseViewModel viewModel = new SingleMouseViewModel(newFile); ObservableCollection <SingleMouseViewModel> currentList = new ObservableCollection <SingleMouseViewModel>(TgItemsSource); currentList.Add(viewModel); TgItemsSource = currentList; }