private void OnSelectRightImageClicked(object sender, RoutedEventArgs e) { if (LoadImage(ref rightImage_, RightImage, RightImagePreview)) { disparityMapGenerator_.SetRightImage(rightImage_); ApplicationSettings.Default.RightImage = rightImage_; ApplicationSettings.Default.Save(); } }
public MainWindow() { if (Debugger.IsAttached) { ApplicationSettings.Default.Reset(); } InitializeComponent(); disparityMapGeneratorTypes_ = (Native.OpenCvDisparityMapGeneratorType[])Enum.GetValues(typeof(Native.OpenCvDisparityMapGeneratorType)); var disparityMapGeneratorTypeName = ApplicationSettings.Default.DisparityMapGeneratorType; DisparityMapGeneratorType.ItemsSource = disparityMapGeneratorTypes_; if (String.IsNullOrEmpty(disparityMapGeneratorTypeName) == false) { var selectedIndex = Array.FindIndex(disparityMapGeneratorTypes_, (type) => type.ToString() == disparityMapGeneratorTypeName); if (selectedIndex != -1) { DisparityMapGeneratorType.SelectedIndex = selectedIndex; } } if (DisparityMapGeneratorType.SelectedIndex == -1) { DisparityMapGeneratorType.SelectedIndex = 0; ApplicationSettings.Default.DisparityMapGeneratorType = disparityMapGeneratorTypes_[0].ToString(); ApplicationSettings.Default.Save(); } disparityMapGenerator_ = (new Native.OpenCvDisparityMapGeneratorBuilder()).SetType(disparityMapGeneratorTypes_[DisparityMapGeneratorType.SelectedIndex]).Build(); LoadNativeConfiguration(); if (String.IsNullOrEmpty(ApplicationSettings.Default.LeftImage) == false) { try { LoadImage(ref leftImage_, ApplicationSettings.Default.LeftImage, LeftImage, LeftImagePreview); disparityMapGenerator_.SetLeftImage(leftImage_); } catch (Exception exception) { } } if (String.IsNullOrEmpty(ApplicationSettings.Default.RightImage) == false) { try { LoadImage(ref rightImage_, ApplicationSettings.Default.RightImage, RightImage, RightImagePreview); disparityMapGenerator_.SetRightImage(rightImage_); } catch (Exception exception) { } } }
private void SelectedAlgorithmChanged(object sender, SelectionChangedEventArgs e) { if (StereoMatcherConfiguration.GuiConfiguration == null) { return; } if (disparityMapGeneratorTypes_[DisparityMapGeneratorType.SelectedIndex] != StereoMatcherConfiguration.GuiConfiguration.Type) { disparityMapGenerator_ = (new Native.OpenCvDisparityMapGeneratorBuilder()).SetType(disparityMapGeneratorTypes_[DisparityMapGeneratorType.SelectedIndex]).Build(); if (String.IsNullOrEmpty(leftImage_) == false) { disparityMapGenerator_.SetLeftImage(leftImage_); } if (String.IsNullOrEmpty(rightImage_) == false) { disparityMapGenerator_.SetRightImage(rightImage_); } LoadNativeConfiguration(); ApplicationSettings.Default.DisparityMapGeneratorType = disparityMapGeneratorTypes_[DisparityMapGeneratorType.SelectedIndex].ToString(); ApplicationSettings.Default.Save(); } }