private void BrowseForUnitVideo() { string filePath = FileBrowser.BroseForVideoFiles(); if (string.IsNullOrWhiteSpace(filePath)) { return; } using (IWhiskerVideo video = ModelResolver.Resolve <IWhiskerVideo>()) { 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(); } } } }
public AnalyserViewModel(Dictionary <int, MouseFrameViewModel> frames, IWhiskerVideo video) { Video = video; Frames = frames; MaxIndex = Frames.Count - 1; bool hasNosePoint = frames[0].Model.Whiskers.Any(x => x.WhiskerId == -1); bool hasOrientationPoint = frames[0].Model.Whiskers.Any(x => x.WhiskerId == 0); bool hasWhiskers = frames[0].Model.Whiskers.Any(x => !x.IsGenericPoint); AnalysisMethods.Add(new None()); if (hasNosePoint) { AnalysisMethods.Add(new NoseDisplacementViewModel(this)); if (hasOrientationPoint) { AnalysisMethods.Add(new HeadOrientationViewModel(this)); if (hasWhiskers) { AnalysisMethods.Add(new WhiskerSpreadViewModel(this)); } } } if (hasWhiskers) { AnalysisMethods.Add(new WhiskerCurvatureViewModel(this)); AnalysisMethods.Add(new WhiskerAngleViewModel(this)); AnalysisMethods.Add(new WhiskerAngularVelocityViewModel(this)); AnalysisMethods.Add(new WhiskerFrequencyViewModel(this)); AnalysisMethods.Add(new WhiskerMeanOffsetViewModel(this)); AnalysisMethods.Add(new WhiskerAmplitudeViewModel(this)); AnalysisMethods.Add(new WhiskerProtractionRetractionViewModel(this)); } if (hasWhiskers || hasNosePoint) { AnalysisMethods.Add(new WhiskerVelocityViewModel(this)); } AnalysisMethods.Add(new AnalyseEverythingViewModel(this)); SelectedMethod = AnalysisMethods.First(); }
public AnalyserViewModel(Dictionary<int, MouseFrameViewModel> frames, IWhiskerVideo video) { Video = video; Frames = frames; MaxIndex = Frames.Count - 1; bool hasNosePoint = frames[0].Model.Whiskers.Any(x => x.WhiskerId == -1); bool hasOrientationPoint = frames[0].Model.Whiskers.Any(x => x.WhiskerId == 0); bool hasWhiskers = frames[0].Model.Whiskers.Any(x => !x.IsGenericPoint); AnalysisMethods.Add(new None()); if (hasNosePoint) { AnalysisMethods.Add(new NoseDisplacementViewModel(this)); if (hasOrientationPoint) { AnalysisMethods.Add(new HeadOrientationViewModel(this)); if (hasWhiskers) { AnalysisMethods.Add(new WhiskerSpreadViewModel(this)); } } } if (hasWhiskers) { AnalysisMethods.Add(new WhiskerCurvatureViewModel(this)); AnalysisMethods.Add(new WhiskerAngleViewModel(this)); AnalysisMethods.Add(new WhiskerAngularVelocityViewModel(this)); AnalysisMethods.Add(new WhiskerFrequencyViewModel(this)); AnalysisMethods.Add(new WhiskerMeanOffsetViewModel(this)); AnalysisMethods.Add(new WhiskerAmplitudeViewModel(this)); AnalysisMethods.Add(new WhiskerProtractionRetractionViewModel(this)); } if (hasWhiskers || hasNosePoint) { AnalysisMethods.Add(new WhiskerVelocityViewModel(this)); } AnalysisMethods.Add(new AnalyseEverythingViewModel(this)); SelectedMethod = AnalysisMethods.First(); }
public ClipSettingsWindowViewModel(IWhiskerVideo video) { IClipSettings clipSettings = ModelResolver.Resolve <IClipSettings>(); clipSettings.ClipFilePath = video.FilePath; clipSettings.StartFrame = 1; int frameCount = video.FrameCount; clipSettings.EndFrame = frameCount < 100 ? frameCount : 100; clipSettings.IncludeNosePoint = true; clipSettings.IncludeOrientationPoint = true; clipSettings.NumberOfPointsPerWhisker = 3; clipSettings.FrameInterval = 1; FrameCount = frameCount; ViewModel = new ClipSettingsViewModel(clipSettings); SelectedNumberOfWhiskers = 4; OriginalFrameRate = video.FrameRate; }
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 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(); }