diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-02 11:58:55 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-02 11:58:55 +0300 |
| commit | 1eb4e2409abbcffdab96b5e896cf71850ab13a01 (patch) | |
| tree | 51b3a09c95c040ce864ccf4920a0b4696108da41 /Software/Visual_Studio/MachineStudio | |
| parent | 05baf6a0dda66fdc1b66d3f769e709f88b540e1d (diff) | |
| download | Tango-1eb4e2409abbcffdab96b5e896cf71850ab13a01.tar.gz Tango-1eb4e2409abbcffdab96b5e896cf71850ab13a01.zip | |
Working on color capture module...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
8 files changed, 556 insertions, 174 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Controls/IndexedUniformGrid.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Controls/IndexedUniformGrid.cs index af34e038d..93a5c07ab 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Controls/IndexedUniformGrid.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Controls/IndexedUniformGrid.cs @@ -16,7 +16,7 @@ namespace Tango.MachineStudio.ColorCapture.Controls set { SetValue(ColumnsProperty, value); } } public static readonly DependencyProperty ColumnsProperty = - DependencyProperty.Register("Columns", typeof(int), typeof(IndexedUniformGrid), new PropertyMetadata(0)); + DependencyProperty.Register("Columns", typeof(int), typeof(IndexedUniformGrid), new PropertyMetadata(0, (d, e) => (d as IndexedUniformGrid).Init())); public int Rows { @@ -24,7 +24,7 @@ namespace Tango.MachineStudio.ColorCapture.Controls set { SetValue(RowsProperty, value); } } public static readonly DependencyProperty RowsProperty = - DependencyProperty.Register("Rows", typeof(int), typeof(IndexedUniformGrid), new PropertyMetadata(0)); + DependencyProperty.Register("Rows", typeof(int), typeof(IndexedUniformGrid), new PropertyMetadata(0, (d, e) => (d as IndexedUniformGrid).Init())); public IndexedUniformGrid() { @@ -33,6 +33,14 @@ namespace Tango.MachineStudio.ColorCapture.Controls private void IndexedUniformGrid_Loaded(object sender, RoutedEventArgs e) { + Init(); + } + + private void Init() + { + ColumnDefinitions.Clear(); + RowDefinitions.Clear(); + for (int i = 0; i < Columns; i++) { ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs index dd32cde93..63ce7035e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs @@ -19,7 +19,7 @@ namespace Tango.MachineStudio.ColorCapture.Graph AddDataSeries(new WpfDataSeries() { StrokeThickness = 1, - Stroke = Colors.Black, + Stroke = Colors.DodgerBlue, }); var renderer = new GraphScrollingRenderer<WpfDataSeries, DoubleDataPoint, DoubleDataPoint>() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/BenchmarkItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/BenchmarkItem.cs new file mode 100644 index 000000000..d7d33e437 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/BenchmarkItem.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.Core; +using Tango.PMR.TCC; + +namespace Tango.MachineStudio.ColorCapture.Models +{ + public class BenchmarkItem : ExtendedObject + { + private int _Red; + public int Red + { + get { return _Red; } + set { _Red = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Color)); } + } + + private int _Green; + public int Green + { + get { return _Green; } + set { _Green = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Color)); } + } + + private int _Blue; + public int Blue + { + get { return _Blue; } + set { _Blue = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(Color)); } + } + + private double _L; + public double L + { + get { return _L; } + set { _L = value; RaisePropertyChangedAuto(); } + } + + private double _A; + public double A + { + get { return _A; } + set { _A = value; RaisePropertyChangedAuto(); } + } + + private double _B; + public double B + { + get { return _B; } + set { _B = value; RaisePropertyChangedAuto(); } + } + + public int Index { get; private set; } + + public Color Color + { + get { return Color.FromArgb(255, (byte)Red, (byte)Green, (byte)Blue); } + } + + public static BenchmarkItem FromDetectionBenchmark(DetectionBenchmark benchmark, int index) + { + BenchmarkItem item = new BenchmarkItem(); + + item.Red = benchmark.Red; + item.Green = benchmark.Green; + item.Blue = benchmark.Blue; + + item.L = benchmark.L; + item.A = benchmark.A; + item.B = benchmark.B; + + item.Index = index; + + return item; + } + + public DetectionBenchmark ToDetectionBenchmark() + { + DetectionBenchmark item = new DetectionBenchmark(); + + item.Red = Red; + item.Green = Green; + item.Blue = Blue; + + item.L = L; + item.A = A; + item.B = B; + + return item; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs new file mode 100644 index 000000000..f997783ca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.MachineStudio.ColorCapture.Models +{ + public class CaptureItem + { + public DateTime Time { get; set; } + public Color CapturedColor { get; set; } + public Color ProcessedColor { get; set; } + public double DeltaE { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj index 4d0c0fae5..6bfe0938f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj @@ -91,6 +91,8 @@ <Compile Include="Controls\ColorMatrixControl.cs" /> <Compile Include="Controls\IndexedUniformGrid.cs" /> <Compile Include="Graph\WpfGraphController.cs" /> + <Compile Include="Models\BenchmarkItem.cs" /> + <Compile Include="Models\CaptureItem.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> @@ -140,6 +142,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.CSV\Tango.CSV.csproj"> + <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> + <Name>Tango.CSV</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.PMR\Tango.PMR.csproj"> <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> <Name>Tango.PMR</Name> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Themes/Generic.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Themes/Generic.xaml index 0a2ebbca8..87a3f1bf2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Themes/Generic.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Themes/Generic.xaml @@ -30,10 +30,10 @@ </ItemsControl.ItemTemplate> </ItemsControl> <controls:IndexedUniformGrid Columns="{TemplateBinding Columns}" Rows="{TemplateBinding Rows}"> - <Image Source="Images/topLeft.bmp" Stretch="Fill" Grid.Column="0" Grid.Row="0" /> - <Image Source="Images/topRight.bmp" Stretch="Fill" Grid.Column="{TemplateBinding Columns}" Grid.Row="0" /> - <Image Source="Images/bottomLeft.bmp" Stretch="Fill" Grid.Column="0" Grid.Row="{TemplateBinding Rows}" /> - <Image Source="Images/bottomRight.bmp" Stretch="Fill" Grid.Column="{TemplateBinding Columns}" Grid.Row="{TemplateBinding Rows}" /> + <Image Source="/Tango.MachineStudio.ColorCapture;component/Images/topLeft.bmp" Stretch="Fill" Grid.Column="0" Grid.Row="0" /> + <Image Source="/Tango.MachineStudio.ColorCapture;component/Images/topRight.bmp" Stretch="Fill" Grid.Column="{TemplateBinding Columns}" Grid.Row="0" /> + <Image Source="/Tango.MachineStudio.ColorCapture;component/Images/bottomLeft.bmp" Stretch="Fill" Grid.Column="0" Grid.Row="{TemplateBinding Rows}" /> + <Image Source="/Tango.MachineStudio.ColorCapture;component/Images/bottomRight.bmp" Stretch="Fill" Grid.Column="{TemplateBinding Columns}" Grid.Row="{TemplateBinding Rows}" /> </controls:IndexedUniformGrid> </Grid> </Border> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs index f21c403de..855d9c0c3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs @@ -1,5 +1,6 @@ using ColorMine.ColorSpaces; using ColorMine.ColorSpaces.Comparisons; +using Microsoft.Win32; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -9,11 +10,15 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Windows.Media.Imaging; +using Tango.Core; using Tango.Core.Commands; +using Tango.CSV; using Tango.MachineStudio.ColorCapture.Graph; +using Tango.MachineStudio.ColorCapture.Models; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.Video; +using Tango.PMR.TCC; using Tango.TCC.BL; using Tango.Video.DirectCapture; @@ -24,6 +29,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels private INotificationProvider _notification; private CardDetector _cardDetector; private int _sampleCounter; + private bool _abort; public IVideoCaptureProvider VideoProvider { get; set; } @@ -89,18 +95,83 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels set { _measureB = value; RaisePropertyChangedAuto(); } } - public WpfGraphController CaptureDeltaEController { get; set; } public RelayCommand ToggleCameraCommand { get; set; } + public SynchronizedObservableCollection<CaptureItem> CaptureItems { get; set; } + + private ObservableCollection<BenchmarkItem> _benchmarks; + public ObservableCollection<BenchmarkItem> Benchmarks + { + get { return _benchmarks; } + set { _benchmarks = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ImportBenchmarksCommand { get; set; } + + public RelayCommand ExportBenchmarksCommand { get; set; } + public MainViewVM() { + CaptureItems = new SynchronizedObservableCollection<CaptureItem>(); + Benchmarks = new ObservableCollection<BenchmarkItem>(); _cardDetector = new CardDetector(); ToggleCameraCommand = new RelayCommand(ToggleCamera); CaptureDeltaEController = new WpfGraphController(); CaptureDeltaEController.Range.AutoY = true; CaptureDeltaEController.Range.MaximumX = 1000; + + ImportBenchmarksCommand = new RelayCommand(OpenBenchmarksFile); + ExportBenchmarksCommand = new RelayCommand(SaveBenchmarksFile); + } + + private void SaveBenchmarksFile() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "CSV Files|*.csv"; + if (dlg.ShowDialog().Value) + { + try + { + ExportBenchmarks(dlg.FileName); + _notification.ShowInfo("Benchmarks successfully saved."); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to export the benchmark file.\n{ex.FlattenMessage()}"); + } + } + } + + private void OpenBenchmarksFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "CSV Files|*.csv"; + if (dlg.ShowDialog().Value) + { + try + { + ImportBenchmarks(dlg.FileName); + _notification.ShowInfo("Benchmarks successfully loaded."); + } + catch (Exception ex) + { + _notification.ShowError($"An error occurred while trying to import the benchmark file.\n{ex.FlattenMessage()}"); + } + } + } + + private void ExportBenchmarks(String file) + { + ColorDetector.SaveBenchmarks(file, Benchmarks.ToList().Select(x => x.ToDetectionBenchmark())); + } + + private void ImportBenchmarks(String file) + { + var marks = ColorDetector.LoadBenchmarks(file).ToList(); + var benchmarks = marks.Select(x => BenchmarkItem.FromDetectionBenchmark(x,marks.IndexOf(x))).ToList(); + Benchmarks = new ObservableCollection<BenchmarkItem>(benchmarks); } public MainViewVM(IVideoCaptureProvider videoProvider, INotificationProvider notificationProvider) : this() @@ -116,10 +187,17 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels { if (SelectedVideoDevice.IsStarted) { + _abort = true; SelectedVideoDevice.Stop(); + ProcessedColor = System.Windows.Media.Colors.Transparent; + CapturedColor = System.Windows.Media.Colors.Transparent; + Colors = null; + DetectedSource = null; + CaptureDeltaEController.Clear(); } else { + _abort = false; SelectedVideoDevice.Resolution = new Resolution(1280, 720); SelectedVideoDevice.Start(); } @@ -143,9 +221,14 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels double deltaE = 0; private async void OnVideoFrameReceived(object sender, Video.DirectShow.EventArguments.FrameReceivedEventArgs args) { + if (_abort) return; + if (_cardDetector.CanDetect) { - var result = await _cardDetector.Detect(args.BitmapSource); + var result = await _cardDetector.Detect(args.BitmapSource, new CardDetectionConfig() + { + Benchmarks = Benchmarks.ToList().Select(x => x.ToDetectionBenchmark()).ToList(), + }); if (result.IsDetected) { @@ -166,11 +249,19 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels CapturedColor = Color.FromArgb(255, (byte)result.ColorDetectionOutput.RawColor.R, (byte)result.ColorDetectionOutput.RawColor.G, (byte)result.ColorDetectionOutput.RawColor.B); ProcessedColor = Color.FromArgb(255, (byte)result.ColorDetectionOutput.ProcessedColor.R, (byte)result.ColorDetectionOutput.ProcessedColor.G, (byte)result.ColorDetectionOutput.ProcessedColor.B); - }); - //calculate delta E. - Lab measureLab = new Lab(MeasureL, MeasureA, MeasureB); - deltaE = measureLab.Compare(new Rgb(ProcessedColor.R, ProcessedColor.G, ProcessedColor.B), new CieDe2000Comparison()); + //calculate delta E. + Lab measureLab = new Lab(MeasureL, MeasureA, MeasureB); + deltaE = measureLab.Compare(new Rgb(ProcessedColor.R, ProcessedColor.G, ProcessedColor.B), new CieDe2000Comparison()); + + CaptureItems.Insert(0, new CaptureItem() + { + CapturedColor = CapturedColor, + ProcessedColor = ProcessedColor, + DeltaE = deltaE, + Time = DateTime.Now, + }); + }); } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml index 259e3160e..54231dfde 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml @@ -14,186 +14,351 @@ xmlns:global="clr-namespace:Tango.MachineStudio.ColorCapture" xmlns:local="clr-namespace:Tango.MachineStudio.ColorCapture.Views" mc:Ignorable="d" - d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - <Grid Margin="20"> - <Grid.RowDefinitions> - <RowDefinition Height="247*"/> - <RowDefinition Height="113*"/> - </Grid.RowDefinitions> - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="1*"/> - </Grid.ColumnDefinitions> + d:DesignHeight="1080" d:DesignWidth="1920" Background="#202020" Foreground="#BBBBBB" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <SolidColorBrush x:Key="Foreground" Color="#BBBBBB" /> + <SolidColorBrush x:Key="Background" Color="#202020" /> + <SolidColorBrush x:Key="Accent" Color="{StaticResource AccentColor}" /> + <SolidColorBrush x:Key="Red" Color="#FF5F5F" /> + <SolidColorBrush x:Key="Green" Color="#68E46E" /> + <SolidColorBrush x:Key="Blue" Color="#64B8EC" /> + <SolidColorBrush x:Key="BorderBrush" Color="#3E3E3E" /> + <SolidColorBrush x:Key="LightBackground" Color="#303030" /> + </UserControl.Resources> - <Border RenderOptions.BitmapScalingMode="Fant"> + <Grid Margin="20"> + <TabControl Background="{StaticResource Background}" Foreground="{StaticResource Foreground}"> + <TabControl.Resources> + <Style TargetType="TabPanel"> + <Setter Property="HorizontalAlignment" Value="Center"/> + </Style> + <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"> + <Setter Property="Padding" Value="20,2"></Setter> + </Style> + </TabControl.Resources> + <TabItem Header="CAPTURE" Foreground="{StaticResource Foreground}"> + <TabItem.HeaderTemplate> + <DataTemplate> + <TextBlock Text="{Binding}" FontSize="25" VerticalAlignment="Center"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TabItem},Path=IsSelected}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource Accent}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </TabItem.HeaderTemplate> <Grid> - <DockPanel> - <DockPanel DockPanel.Dock="Bottom" Margin="60 0" TextElement.FontSize="25"> - <TextBlock VerticalAlignment="Center">Capture Device</TextBlock> - <Button DockPanel.Dock="Right" Command="{Binding ToggleCameraCommand}" CommandParameter="{Binding}" Style="{StaticResource MaterialDesignFloatingActionMiniButton}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="60" Height="60" Padding="0"> - <materialDesign:PackIcon Width="40" Height="40"> - <materialDesign:PackIcon.Style> - <Style TargetType="materialDesign:PackIcon"> - <Setter Property="Kind" Value="Play"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="True"> - <Setter Property="Kind" Value="Stop"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="False"> - <Setter Property="Kind" Value="Play"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </materialDesign:PackIcon.Style> - </materialDesign:PackIcon> - </Button> - <ComboBox FontWeight="SemiBold" Margin="20 0 20 0" ItemsSource="{Binding VideoProvider.AvailableCaptureDevices}" SelectedItem="{Binding SelectedVideoDevice}" DisplayMemberPath="Device"></ComboBox> - </DockPanel> + <Grid.RowDefinitions> + <RowDefinition Height="600"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="800"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> - <Border BorderThickness="3" BorderBrush="#202020" Margin="40"> - <Image Source="{Binding SelectedVideoDevice.VideoSource,Mode=OneWay,IsAsync=True}" Stretch="Fill"> - <Image.Style> - <Style TargetType="Image"> - <Setter Property="Visibility" Value="Hidden"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="True"> - <Setter Property="Visibility" Value="Visible"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="False"> - <Setter Property="Visibility" Value="Hidden"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </Image.Style> - </Image> + <Border RenderOptions.BitmapScalingMode="Fant"> + <Grid> + <DockPanel> + <DockPanel DockPanel.Dock="Top" TextElement.FontSize="16"> + <TextBlock VerticalAlignment="Center" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold">Capture Device</TextBlock> + <Button DockPanel.Dock="Right" Command="{Binding ToggleCameraCommand}" CommandParameter="{Binding}" Style="{StaticResource MaterialDesignFlatButton}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="50" Height="50" Padding="0"> + <materialDesign:PackIcon Width="40" Height="40"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="Play"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="True"> + <Setter Property="Kind" Value="Stop"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="False"> + <Setter Property="Kind" Value="Play"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </Button> + <ComboBox FontWeight="SemiBold" Margin="20 0" ItemsSource="{Binding VideoProvider.AvailableCaptureDevices}" SelectedItem="{Binding SelectedVideoDevice}" DisplayMemberPath="Device" BorderBrush="{StaticResource Foreground}"></ComboBox> + </DockPanel> + + <Border Padding="2" Background="{StaticResource LightBackground}" BorderThickness="1" BorderBrush="{StaticResource Accent}" Margin="0 10 0 0"> + <Image Source="{Binding SelectedVideoDevice.VideoSource,Mode=OneWay,IsAsync=True}" Stretch="Fill"> + <Image.Style> + <Style TargetType="Image"> + <Setter Property="Visibility" Value="Hidden"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding SelectedVideoDevice.IsStarted}" Value="False"> + <Setter Property="Visibility" Value="Hidden"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Image.Style> + </Image> + </Border> + </DockPanel> + </Grid> </Border> - </DockPanel> - </Grid> - </Border> - <Grid Grid.Column="1"> - <Grid.RowDefinitions> - <RowDefinition Height="180*"/> - <RowDefinition Height="130*"/> - </Grid.RowDefinitions> - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="1*"/> - </Grid.ColumnDefinitions> + <Grid Grid.Column="1" Margin="200 60 0 0" HorizontalAlignment="Left"> + <Grid.RowDefinitions> + <RowDefinition Height="180*"/> + <RowDefinition Height="130*"/> + </Grid.RowDefinitions> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="500"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> - <Border Margin="0 40 0 0" VerticalAlignment="Top" Width="300" Height="310" BorderThickness="3" BorderBrush="#202020"> - <Image Source="{Binding DetectedSource,Mode=OneWay,IsAsync=True}" Stretch="Fill"></Image> - </Border> + <TextBlock Margin="0 -20 0 0" FontWeight="SemiBold" Foreground="{StaticResource Accent}">Rectified Image</TextBlock> + <Border Padding="2" Background="{StaticResource LightBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300" Height="310" BorderThickness="1" BorderBrush="{StaticResource Accent}"> + <Image Source="{Binding DetectedSource,Mode=OneWay,IsAsync=True}" Stretch="Fill"></Image> + </Border> - <Border Margin="0 40 0 0" VerticalAlignment="Top" Width="300" Height="310" BorderThickness="3" BorderBrush="#202020" Grid.Column="1"> - <controls:ColorMatrixControl Colors="{Binding Colors,Mode=OneWay}" Columns="10" Rows="11" /> - </Border> - </Grid> + <TextBlock Grid.Column="1" Margin="0 -20 0 0" FontWeight="SemiBold" Foreground="{StaticResource Accent}">Calculated Averages</TextBlock> + <Border Padding="2" HorizontalAlignment="Left" Grid.Column="1" VerticalAlignment="Top" Width="300" Height="310" BorderThickness="1" BorderBrush="{StaticResource Accent}"> + <controls:ColorMatrixControl Colors="{Binding Colors,Mode=OneWay}" Columns="10" Rows="11" Background="{StaticResource LightBackground}" /> + </Border> + </Grid> - <Grid Grid.Row="1"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="1*"/> - </Grid.ColumnDefinitions> + <Grid Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="500"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> - <Grid Width="300" Height="190" VerticalAlignment="Top"> - <DockPanel> - <TextBlock DockPanel.Dock="Top" FontSize="20">Captured Color</TextBlock> - <DockPanel Margin="0 10 0 0" TextElement.FontSize="20"> - <UniformGrid DockPanel.Dock="Right" Rows="3" Margin="10 0 0 0" Width="55"> - <TextBlock><Run Text="R:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding CapturedColor.R,Mode=OneWay}"></Run></TextBlock> - <TextBlock><Run Text="G:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding CapturedColor.G,Mode=OneWay}"></Run></TextBlock> - <TextBlock><Run Text="B:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding CapturedColor.B,Mode=OneWay}"></Run></TextBlock> - </UniformGrid> - <Border BorderThickness="1" BorderBrush="#202020"> - <Border.Background> - <SolidColorBrush Color="{Binding CapturedColor,Mode=OneWay}" /> - </Border.Background> - </Border> - </DockPanel> - </DockPanel> + <Grid Height="120" VerticalAlignment="Top" HorizontalAlignment="Left"> + <DockPanel> + <TextBlock Margin="0 10 0 0" DockPanel.Dock="Top" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold" FontSize="16">Captured Color</TextBlock> + <DockPanel Margin="0 5 0 0" TextElement.FontSize="16"> + <UniformGrid DockPanel.Dock="Right" Rows="3" Margin="10 0 0 0" Width="55"> + <TextBlock Foreground="{StaticResource Red}"><Run Text="R:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding CapturedColor.R,Mode=OneWay}"></Run></TextBlock> + <TextBlock Foreground="{StaticResource Green}"><Run Text="G:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding CapturedColor.G,Mode=OneWay}"></Run></TextBlock> + <TextBlock Foreground="{StaticResource Blue}"><Run Text="B:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding CapturedColor.B,Mode=OneWay}"></Run></TextBlock> + </UniformGrid> + <Border Padding="2" Width="300" BorderThickness="1" BorderBrush="{StaticResource Accent}" Background="{StaticResource LightBackground}"> + <Rectangle> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding CapturedColor,Mode=OneWay}" /> + </Rectangle.Fill> + </Rectangle> + </Border> + </DockPanel> + </DockPanel> + </Grid> + + <Grid Height="120" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="1"> + <DockPanel> + <TextBlock Margin="0 10 0 0" DockPanel.Dock="Top" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold" FontSize="16">Processed Color</TextBlock> + <DockPanel Margin="0 5 0 0" TextElement.FontSize="16"> + <UniformGrid DockPanel.Dock="Right" Rows="3" Margin="10 0 0 0" Width="55"> + <TextBlock Foreground="{StaticResource Red}"><Run Text="R:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding ProcessedColor.R,Mode=OneWay}"></Run></TextBlock> + <TextBlock Foreground="{StaticResource Green}"><Run Text="G:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding ProcessedColor.G,Mode=OneWay}"></Run></TextBlock> + <TextBlock Foreground="{StaticResource Blue}"><Run Text="B:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding ProcessedColor.B,Mode=OneWay}"></Run></TextBlock> + </UniformGrid> + <Border Padding="2" Width="300" BorderThickness="1" BorderBrush="{StaticResource Accent}" Background="{StaticResource LightBackground}"> + <Rectangle> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding ProcessedColor,Mode=OneWay}" /> + </Rectangle.Fill> + </Rectangle> + </Border> + </DockPanel> + </DockPanel> + </Grid> + + <DockPanel VerticalAlignment="Bottom" Grid.ColumnSpan="2" TextElement.FontSize="16"> + <TextBlock HorizontalAlignment="Center" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold" FontSize="16">Delta E Reference Point</TextBlock> + <UniformGrid Columns="3" Margin="20 0 70 0"> + <DockPanel> + <TextBlock FontWeight="SemiBold">L:</TextBlock> + <mahapps:NumericUpDown BorderBrush="{StaticResource BorderBrush}" MinWidth="120" HorizontalContentAlignment="Left" Value="{Binding MeasureL,UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="100" Margin="5 0 0 0" HasDecimals="True" HideUpDownButtons="True" Background="{StaticResource LightBackground}" FontSize="16" Foreground="{StaticResource Accent}" BorderThickness="1" /> + </DockPanel> + + <DockPanel> + <TextBlock Margin="20 0 0 0" FontWeight="SemiBold">A:</TextBlock> + <mahapps:NumericUpDown BorderBrush="{StaticResource BorderBrush}" MinWidth="120" HorizontalContentAlignment="Left" Value="{Binding MeasureA,UpdateSourceTrigger=PropertyChanged}" Minimum="-127" Maximum="128" Margin="5 0 0 0" HasDecimals="True" HideUpDownButtons="True" Background="{StaticResource LightBackground}" FontSize="16" Foreground="{StaticResource Accent}" BorderThickness="1" /> + </DockPanel> + + <DockPanel> + <TextBlock Margin="20 0 0 0" FontWeight="SemiBold">B:</TextBlock> + <mahapps:NumericUpDown BorderBrush="{StaticResource BorderBrush}" MinWidth="120" HorizontalContentAlignment="Left" Value="{Binding MeasureB,UpdateSourceTrigger=PropertyChanged}" Minimum="-127" Maximum="128" Margin="5 0 0 0" HasDecimals="True" HideUpDownButtons="True" Background="{StaticResource LightBackground}" FontSize="16" Foreground="{StaticResource Accent}" BorderThickness="1" /> + </DockPanel> + </UniformGrid> + </DockPanel> + </Grid> + </Grid> </Grid> - <Grid Width="300" Height="190" VerticalAlignment="Top" Grid.Column="1"> - <DockPanel> - <TextBlock DockPanel.Dock="Top" FontSize="20">Processed Color</TextBlock> - <DockPanel Margin="0 10 0 0" TextElement.FontSize="20"> - <UniformGrid DockPanel.Dock="Right" Rows="3" Margin="10 0 0 0" Width="55"> - <TextBlock><Run Text="R:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding ProcessedColor.R,Mode=OneWay}"></Run></TextBlock> - <TextBlock><Run Text="G:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding ProcessedColor.G,Mode=OneWay}"></Run></TextBlock> - <TextBlock><Run Text="B:"></Run> <Run FontWeight="SemiBold" FontStyle="Italic" Text="{Binding ProcessedColor.B,Mode=OneWay}"></Run></TextBlock> - </UniformGrid> - <Border BorderThickness="1" BorderBrush="#202020"> - <Border.Background> - <SolidColorBrush Color="{Binding ProcessedColor,Mode=OneWay}" /> - </Border.Background> - </Border> + <Grid Grid.Row="1" Margin="0 40 0 0"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="800"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + <DockPanel> + <TextBlock DockPanel.Dock="Top" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold" FontSize="16">Measures</TextBlock> + <DataGrid ItemsSource="{Binding CaptureItems}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" IsReadOnly="True" Margin="0 10 0 0" Background="{StaticResource LightBackground}" Grid.ColumnSpan="2" TextElement.Foreground="Gainsboro" BorderBrush="{StaticResource Accent}" BorderThickness="1"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.ColumnHeaderStyle> + <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}"> + <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + </Style> + </DataGrid.ColumnHeaderStyle> + <DataGrid.Columns> + <DataGridTextColumn Header="TIME" Binding="{Binding Time,StringFormat='HH:mm:ss.fff'}" /> + <DataGridTemplateColumn Header="CAPTURED COLOR"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Rectangle Width="100"> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding CapturedColor}"></SolidColorBrush> + </Rectangle.Fill> + </Rectangle> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="PROCESSED COLOR"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Rectangle Width="100"> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding ProcessedColor}"></SolidColorBrush> + </Rectangle.Fill> + </Rectangle> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTextColumn Header="DELTA E" Binding="{Binding DeltaE}" /> + </DataGrid.Columns> + </DataGrid> </DockPanel> - </DockPanel> - </Grid> - </Grid> - </Grid> - </Grid> - <Grid Grid.Row="1" Margin="0 10 0 0"> - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"/> - <ColumnDefinition Width="1*"/> - </Grid.ColumnDefinitions> - <DockPanel> - <TextBlock DockPanel.Dock="Top">HISTORY</TextBlock> - <DataGrid Margin="0 10 0 0" Background="Transparent" Grid.ColumnSpan="2"> - <DataGrid.Columns> - <DataGridTextColumn Header="TIME" /> - <DataGridTextColumn Header="CAPTURED COLOR" /> - <DataGridTextColumn Header="PROCESSED COLOR" /> - </DataGrid.Columns> - </DataGrid> - </DockPanel> + <DockPanel Grid.Column="1" Margin="120 0 60 0"> + <TextBlock HorizontalAlignment="Center" Margin="0 0 0 0" DockPanel.Dock="Top" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold" FontSize="16">Delta E Distance</TextBlock> + <Grid> + <Border Margin="0 10 0 0" Padding="20 0 20 0" BorderThickness="1" BorderBrush="#202020"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="55"/> + <ColumnDefinition Width="438*"/> + </Grid.ColumnDefinitions> - <DockPanel Grid.Column="1" Margin="75 0 110 0"> - <Grid DockPanel.Dock="Top" TextElement.FontSize="20" Margin="0 0 0 10"> - <DockPanel> - <TextBlock HorizontalAlignment="Center">Delta E Reference Point</TextBlock> - <StackPanel Orientation="Horizontal" Margin="20 0 0 0"> - <TextBlock FontWeight="SemiBold">L:</TextBlock> - <mahapps:NumericUpDown MinWidth="120" HorizontalContentAlignment="Left" Value="{Binding MeasureL,UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="100" Margin="5 0 0 0" HasDecimals="True" HideUpDownButtons="True" Background="Transparent" BorderThickness="1" /> + <Border Margin="0 1 0 2"> + <componentsX:GraphAxisControl Orientation="Vertical" Foreground="{StaticResource Accent}" FontSize="12" Surface="{Binding ElementName=Graph}" StringFormat="Δ 0.00;-#" /> + </Border> + <Border Grid.Column="1" BorderThickness="1" BorderBrush="{StaticResource Accent}" Margin="1 0 0 0" Background="{StaticResource LightBackground}"> + <Grid> - <TextBlock Margin="20 0 0 0" FontWeight="SemiBold">A:</TextBlock> - <mahapps:NumericUpDown MinWidth="120" HorizontalContentAlignment="Left" Value="{Binding MeasureA,UpdateSourceTrigger=PropertyChanged}" Minimum="-127" Maximum="128" Margin="5 0 0 0" HasDecimals="True" HideUpDownButtons="True" Background="Transparent" BorderThickness="1" /> + <componentsX:GraphGridLines Foreground="#3E3E3E" /> - <TextBlock Margin="20 0 0 0" FontWeight="SemiBold">B:</TextBlock> - <mahapps:NumericUpDown MinWidth="120" HorizontalContentAlignment="Left" Value="{Binding MeasureB,UpdateSourceTrigger=PropertyChanged}" Minimum="-127" Maximum="128" Margin="5 0 0 0" HasDecimals="True" HideUpDownButtons="True" Background="Transparent" BorderThickness="1" /> - </StackPanel> - </DockPanel> + <graphX:WpfGraphSurface x:Name="Graph"></graphX:WpfGraphSurface> + </Grid> + </Border> + </Grid> + </Border> + </Grid> + </DockPanel> + </Grid> </Grid> - <Grid> - <Border Padding="20" BorderThickness="1" BorderBrush="#202020"> - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="55"/> - <ColumnDefinition Width="438*"/> - </Grid.ColumnDefinitions> + </Grid> + </TabItem> + <TabItem Header="BENCHMARKS" Foreground="{StaticResource Foreground}"> + <TabItem.HeaderTemplate> + <DataTemplate> + <TextBlock Text="{Binding}" FontSize="25" VerticalAlignment="Center"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TabItem},Path=IsSelected}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource Accent}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </TabItem.HeaderTemplate> - <Border Margin="0 1 0 2"> - <componentsX:GraphAxisControl Orientation="Vertical" FontSize="10" Surface="{Binding ElementName=Graph}" StringFormat="Δ 0.00;-#" /> - </Border> - <Border Grid.Column="1" BorderThickness="1" BorderBrush="Silver" Margin="1 0 0 0"> - <Grid> + <Grid Margin="0 20 20 20"> + <DockPanel> + <StackPanel Margin="0 10 0 0" HorizontalAlignment="Right" Orientation="Horizontal" DockPanel.Dock="Bottom"> + <Button Command="{Binding ImportBenchmarksCommand}" Style="{StaticResource MaterialDesignFlatButton}" BorderBrush="{StaticResource Accent}" BorderThickness="1" Height="45" MinWidth="150">IMPORT</Button> + <Button Command="{Binding ExportBenchmarksCommand}" Margin="10 0 0 0" Style="{StaticResource MaterialDesignFlatButton}" BorderBrush="{StaticResource Accent}" BorderThickness="1" Height="45" MinWidth="150">EXPORT</Button> + </StackPanel> - <componentsX:GraphGridLines Foreground="Silver" /> + <Grid> + <DataGrid BorderBrush="{StaticResource Accent}" BorderThickness="1" AlternationCount="1000" SelectionMode="Single" SelectionUnit="FullRow" AutoGenerateColumns="False" ItemsSource="{Binding Benchmarks}" Background="{StaticResource LightBackground}"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.ColumnHeaderStyle> + <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}"> + <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + </Style> + </DataGrid.ColumnHeaderStyle> + <DataGrid.Columns> - <graphX:WpfGraphSurface x:Name="Graph"></graphX:WpfGraphSurface> - </Grid> - </Border> - </Grid> - </Border> - </Grid> - </DockPanel> - </Grid> - </Grid> + <DataGridTextColumn Width="100" Header="#" Binding="{Binding Index}"></DataGridTextColumn> + <DataGridTextColumn Header="RED" Binding="{Binding Red}"></DataGridTextColumn> + <DataGridTextColumn Header="GREEN" Binding="{Binding Green}"></DataGridTextColumn> + <DataGridTextColumn Header="BLUE" Binding="{Binding Blue}"></DataGridTextColumn> + + <DataGridTextColumn Header="L" Binding="{Binding L}"></DataGridTextColumn> + <DataGridTextColumn Header="A" Binding="{Binding A}"></DataGridTextColumn> + <DataGridTextColumn Header="B" Binding="{Binding B}"></DataGridTextColumn> + + <DataGridTemplateColumn Header="#" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Rectangle Width="200" HorizontalAlignment="Right"> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding Color}"></SolidColorBrush> + </Rectangle.Fill> + </Rectangle> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </Grid> + </DockPanel> + </Grid> + </TabItem> + <TabItem Header="CONFIGURATION" Foreground="{StaticResource Foreground}"> + <TabItem.HeaderTemplate> + <DataTemplate> + <TextBlock Text="{Binding}" FontSize="25" VerticalAlignment="Center"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TabItem},Path=IsSelected}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource Accent}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </TabItem.HeaderTemplate> + </TabItem> + </TabControl> </Grid> </UserControl> |
