diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-02 13:54:23 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-02 13:54:23 +0300 |
| commit | 76cbd34eae64052b0ca3d332211d8f00d6da3d63 (patch) | |
| tree | 9932f5d49b3fd34bb5a67bbfc1845d3e284e91cb /Software/Visual_Studio | |
| parent | 1eb4e2409abbcffdab96b5e896cf71850ab13a01 (diff) | |
| download | Tango-76cbd34eae64052b0ca3d332211d8f00d6da3d63.tar.gz Tango-76cbd34eae64052b0ca3d332211d8f00d6da3d63.zip | |
Working on color capture module...
Diffstat (limited to 'Software/Visual_Studio')
11 files changed, 393 insertions, 23 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/App.config index a6a2b7fa9..8b30e609b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/App.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/App.config @@ -1,2 +1,75 @@ <?xml version="1.0" encoding="utf-8"?> -<configuration />
\ No newline at end of file +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorCaptureSettings.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorCaptureSettings.cs new file mode 100644 index 000000000..63ed247ef --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ColorCaptureSettings.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.ColorCapture.Models; +using Tango.Settings; + +namespace Tango.MachineStudio.ColorCapture +{ + public class ColorCaptureSettings : SettingsBase + { + public CaptureConfig Config { get; set; } + + public ColorCaptureSettings() + { + Config = new CaptureConfig(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs new file mode 100644 index 000000000..c1b7d2dcb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Helpers; + +namespace Tango.MachineStudio.ColorCapture.Models +{ + public class CaptureConfig : ExtendedObject + { + private int _columns; + public int Columns + { + get { return _columns; } + set { _columns = value; RaisePropertyChangedAuto(); } + } + + private int _rows; + public int Rows + { + get { return _rows; } + set { _rows = value; RaisePropertyChangedAuto(); } + } + + private int _targetIndex; + public int TargetIndex + { + get { return _targetIndex; } + set { _targetIndex = value; RaisePropertyChangedAuto(); } + } + + private String _samplesFolder; + public String SamplesFolder + { + get { return _samplesFolder; } + set { _samplesFolder = value; RaisePropertyChangedAuto(); } + } + + private String _benchmarksFile; + public String BenchmarksFile + { + get { return _benchmarksFile; } + set { _benchmarksFile = value; RaisePropertyChangedAuto(); } + } + + private String _templateFile; + public String TemplateFile + { + get { return _templateFile; } + set { _templateFile = value; RaisePropertyChangedAuto(); } + } + + public CaptureConfig() + { + Columns = 10; + Rows = 11; + TargetIndex = 89; + SamplesFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "TCC Samples"); + BenchmarksFile = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "TCC", "benchmarks_rgb_lab.csv"); + TemplateFile = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "TCC", "template.bmp"); + } + } +} 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 index f997783ca..66fe7d7af 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,8 +11,21 @@ namespace Tango.MachineStudio.ColorCapture.Models public class CaptureItem { public DateTime Time { get; set; } + + [JsonIgnore] + public String Folder { get; set; } + + [JsonIgnore] + public String Image { get; set; } + public Color CapturedColor { get; set; } public Color ProcessedColor { get; set; } + public Color RefColor { get; set; } + + public double RefL { get; set; } + public double RefA { get; set; } + public double RefB { 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 6bfe0938f..5ec3ae0df 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 @@ -53,6 +53,9 @@ <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> </Reference> + <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> @@ -87,11 +90,13 @@ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="ColorCaptureSettings.cs" /> <Compile Include="ColorLabModule.cs" /> <Compile Include="Controls\ColorMatrixControl.cs" /> <Compile Include="Controls\IndexedUniformGrid.cs" /> <Compile Include="Graph\WpfGraphController.cs" /> <Compile Include="Models\BenchmarkItem.cs" /> + <Compile Include="Models\CaptureConfig.cs" /> <Compile Include="Models\CaptureItem.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> @@ -115,6 +120,7 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> + <None Include="App.config" /> <None Include="packages.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> @@ -146,6 +152,10 @@ <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> <Name>Tango.CSV</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</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/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs index 855d9c0c3..d0d251444 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 @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -30,6 +31,8 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels private CardDetector _cardDetector; private int _sampleCounter; private bool _abort; + private BitmapSource _last_original_source; + private DetectionOutput _last_detection_output; public IVideoCaptureProvider VideoProvider { get; set; } @@ -50,7 +53,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels public BitmapSource DetectedSource { get { return _detectedSource; } - set { _detectedSource = value; RaisePropertyChangedAuto(); } + set { _detectedSource = value; RaisePropertyChangedAuto(); InvokeUI(() => CreateSnapshotCommand.RaiseCanExecuteChanged()); } } private ObservableCollection<Color> _colors; @@ -95,6 +98,8 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels set { _measureB = value; RaisePropertyChangedAuto(); } } + public double DeltaE { get; set; } + public WpfGraphController CaptureDeltaEController { get; set; } public RelayCommand ToggleCameraCommand { get; set; } @@ -108,12 +113,24 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels set { _benchmarks = value; RaisePropertyChangedAuto(); } } + private CaptureConfig _config; + public CaptureConfig Config + { + get { return _config; } + set { _config = value; RaisePropertyChangedAuto(); } + } + public RelayCommand ImportBenchmarksCommand { get; set; } public RelayCommand ExportBenchmarksCommand { get; set; } + public RelayCommand CreateSnapshotCommand { get; set; } + + public RelayCommand<CaptureItem> OpenCaptureItemCommand { get; set; } + public MainViewVM() { + Config = new CaptureConfig(); CaptureItems = new SynchronizedObservableCollection<CaptureItem>(); Benchmarks = new ObservableCollection<BenchmarkItem>(); _cardDetector = new CardDetector(); @@ -124,6 +141,74 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels ImportBenchmarksCommand = new RelayCommand(OpenBenchmarksFile); ExportBenchmarksCommand = new RelayCommand(SaveBenchmarksFile); + CreateSnapshotCommand = new RelayCommand(CreateSnapshot, () => DetectedSource != null); + OpenCaptureItemCommand = new RelayCommand<CaptureItem>(OpenCaptureItem); + } + + private void OpenCaptureItem(CaptureItem item) + { + using (_notification.PushTaskItem("Opening snapshot folder...")) + { + Process.Start("explorer.exe", string.Format("/select,\"{0}\"", item.Image)); + } + } + + private void CreateSnapshot() + { + try + { + DateTime now = DateTime.Now; + + Directory.CreateDirectory(Config.SamplesFolder); + + String sample_folder = Config.SamplesFolder + "\\" + now.ToFileName(); + Directory.CreateDirectory(sample_folder); + + String rectified_file = sample_folder + "\\rectified.bmp"; + DetectedSource.SaveBmpFile(rectified_file); + + String original_file = sample_folder + "\\source.bmp"; + _last_original_source.SaveBmpFile(original_file); + + String means_file = sample_folder + "\\means.bmp"; + var bitmap = ColorDetector.DetectionOutputToImage(new DetectionInput() + { + Columns = Config.Columns, + Rows = Config.Rows, + TargetIndex = Config.TargetIndex + + }, _last_detection_output, 300, 310); + + bitmap.Save(means_file); + + String capture_item_file = sample_folder + "\\info.txt"; + + var rgb = new Lab(MeasureL, _measureA, _measureB).ToRgb(); + Color refColor = Color.FromArgb(255, (byte)rgb.R, (byte)rgb.G, (byte)rgb.B); + + var captureItem = new CaptureItem() + { + Image = rectified_file, + CapturedColor = CapturedColor, + ProcessedColor = ProcessedColor, + RefColor = refColor, + DeltaE = DeltaE, + RefL = MeasureL, + RefA = MeasureA, + RefB = MeasureB, + Time = now, + Folder = sample_folder, + }; + + File.WriteAllText(capture_item_file, captureItem.ToJsonString()); + + CaptureItems.Insert(0, captureItem); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error in color capture snapshot save method."); + _notification.ShowError($"An error occurred while trying to create the snapshot. Please try again.\n{ex.Message}"); + } } private void SaveBenchmarksFile() @@ -170,7 +255,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels private void ImportBenchmarks(String file) { var marks = ColorDetector.LoadBenchmarks(file).ToList(); - var benchmarks = marks.Select(x => BenchmarkItem.FromDetectionBenchmark(x,marks.IndexOf(x))).ToList(); + var benchmarks = marks.Select(x => BenchmarkItem.FromDetectionBenchmark(x, marks.IndexOf(x))).ToList(); Benchmarks = new ObservableCollection<BenchmarkItem>(benchmarks); } @@ -218,7 +303,6 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels } } - double deltaE = 0; private async void OnVideoFrameReceived(object sender, Video.DirectShow.EventArguments.FrameReceivedEventArgs args) { if (_abort) return; @@ -232,6 +316,9 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels if (result.IsDetected) { + _last_original_source = result.Source; + _last_detection_output = result.ColorDetectionOutput; + DetectedSource = result.DetectedBitmap; if (Colors == null) @@ -252,20 +339,12 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels //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, - }); + DeltaE = measureLab.Compare(new Rgb(ProcessedColor.R, ProcessedColor.G, ProcessedColor.B), new CieDe2000Comparison()); }); } } - CaptureDeltaEController.PushData(_sampleCounter++, deltaE); + CaptureDeltaEController.PushData(_sampleCounter++, DeltaE); } public override void OnApplicationReady() 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 54231dfde..5f4f0db07 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 @@ -10,6 +10,7 @@ xmlns:graphX="clr-namespace:RealTimeGraphX.WPF.Surfaces;assembly=RealTimeGraphX.WPF" xmlns:componentsX="clr-namespace:RealTimeGraphX.WPF.Components;assembly=RealTimeGraphX.WPF" xmlns:controls="clr-namespace:Tango.MachineStudio.ColorCapture.Controls" + xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:realtimeGraphX="clr-namespace:RealTimeGraphX.WPF.Surfaces;assembly=RealTimeGraphX.WPF" xmlns:global="clr-namespace:Tango.MachineStudio.ColorCapture" xmlns:local="clr-namespace:Tango.MachineStudio.ColorCapture.Views" @@ -208,11 +209,51 @@ <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"> + <DockPanel DockPanel.Dock="Top" LastChildFill="False"> + <TextBlock VerticalAlignment="Center" DockPanel.Dock="Left" Foreground="{StaticResource AccentColorBrush}" FontWeight="SemiBold" FontSize="16">Snapshots</TextBlock> + <Button Command="{Binding CreateSnapshotCommand}" Height="35" DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" BorderBrush="{StaticResource Accent}" BorderThickness="1"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ChevronDoubleDown" VerticalAlignment="Center" /> + <TextBlock Margin="10 0 0 0">Create Snapshot</TextBlock> + </StackPanel> + </Button> + </DockPanel> + <sharedControls:DoubleClickDataGrid DoubleClickCommand="{Binding OpenCaptureItemCommand}" Style="{StaticResource {x:Type DataGrid}}" ItemsSource="{Binding CaptureItems}" GridLinesVisibility="None" 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.RowStyle> + <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> + <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + <Setter Property="BorderBrush" Value="#202020"></Setter> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Setter Property="BorderThickness" Value="0 0 0 1"></Setter> + <Style.Triggers> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + <Setter Property="Cursor" Value="Hand"></Setter> + </Trigger> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + <Trigger Property="IsFocused" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + </Style.Triggers> + </Style> + </DataGrid.RowStyle> <DataGrid.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + </Style.Triggers> </Style> </DataGrid.CellStyle> <DataGrid.ColumnHeaderStyle> @@ -221,11 +262,29 @@ </Style> </DataGrid.ColumnHeaderStyle> <DataGrid.Columns> + <DataGridTemplateColumn Header="#" Width="50"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Image Width="30" Height="30" Source="{Binding Image}"></Image> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> <DataGridTextColumn Header="TIME" Binding="{Binding Time,StringFormat='HH:mm:ss.fff'}" /> - <DataGridTemplateColumn Header="CAPTURED COLOR"> + <DataGridTemplateColumn Header="REF" Width="80"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> - <Rectangle Width="100"> + <Rectangle Width="60"> + <Rectangle.Fill> + <SolidColorBrush Color="{Binding RefColor}"></SolidColorBrush> + </Rectangle.Fill> + </Rectangle> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="CAPTURED" Width="90"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Rectangle Width="60"> <Rectangle.Fill> <SolidColorBrush Color="{Binding CapturedColor}"></SolidColorBrush> </Rectangle.Fill> @@ -233,10 +292,10 @@ </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> - <DataGridTemplateColumn Header="PROCESSED COLOR"> + <DataGridTemplateColumn Header="PROCESSED" Width="90"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> - <Rectangle Width="100"> + <Rectangle Width="60"> <Rectangle.Fill> <SolidColorBrush Color="{Binding ProcessedColor}"></SolidColorBrush> </Rectangle.Fill> @@ -244,9 +303,13 @@ </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> + + <DataGridTextColumn Header="REF L" Width="70" Binding="{Binding RefL}" /> + <DataGridTextColumn Header="REF A" Width="70" Binding="{Binding RefA}" /> + <DataGridTextColumn Header="REF B" Width="70" Binding="{Binding RefB}" /> <DataGridTextColumn Header="DELTA E" Binding="{Binding DeltaE}" /> </DataGrid.Columns> - </DataGrid> + </sharedControls:DoubleClickDataGrid> </DockPanel> <DockPanel Grid.Column="1" Margin="120 0 60 0"> @@ -303,10 +366,42 @@ </StackPanel> <Grid> - <DataGrid BorderBrush="{StaticResource Accent}" BorderThickness="1" AlternationCount="1000" SelectionMode="Single" SelectionUnit="FullRow" AutoGenerateColumns="False" ItemsSource="{Binding Benchmarks}" Background="{StaticResource LightBackground}"> + <DataGrid BorderBrush="{StaticResource Accent}" BorderThickness="1" AlternationCount="1000" SelectionMode="Single" SelectionUnit="FullRow" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" IsReadOnly="True" GridLinesVisibility="None" ItemsSource="{Binding Benchmarks}" Background="{StaticResource LightBackground}"> + <DataGrid.RowStyle> + <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> + <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + <Setter Property="BorderBrush" Value="#202020"></Setter> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Setter Property="BorderThickness" Value="0 0 0 1"></Setter> + <Style.Triggers> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + <Setter Property="Cursor" Value="Hand"></Setter> + </Trigger> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + <Trigger Property="IsFocused" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + </Style.Triggers> + </Style> + </DataGrid.RowStyle> <DataGrid.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="Foreground" Value="{StaticResource Foreground}"></Setter> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + </Trigger> + </Style.Triggers> </Style> </DataGrid.CellStyle> <DataGrid.ColumnHeaderStyle> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/packages.config index 37e4dd902..d0d0f7914 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/packages.config @@ -7,4 +7,5 @@ <package id="MahApps.Metro" version="1.5.0" targetFramework="net461" /> <package id="MaterialDesignColors" version="1.1.2" targetFramework="net461" /> <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" /> + <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> </packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionResult.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionResult.cs index 821d19330..0cf7f3d67 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionResult.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionResult.cs @@ -11,6 +11,7 @@ namespace Tango.TCC.BL public class CardDetectionResult { public bool IsDetected { get; set; } + public BitmapSource Source { get; set; } public BitmapSource DetectedBitmap { get; set; } public DetectionOutput ColorDetectionOutput { get; set; } } diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs index 5971b4be1..c0f827e1b 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs @@ -52,6 +52,7 @@ namespace Tango.TCC.BL return Task.Factory.StartNew<CardDetectionResult>(() => { CardDetectionResult detectionResult = new CardDetectionResult(); + detectionResult.Source = cloned; Tango.TCC.CardDetector.CardDetection detector = new TCC.CardDetector.CardDetection(); var result = detector.Detect(cloned.ToBytes(PixelFormats.Rgb24), new TCC.CardDetector.CardDetectionConfig() diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs index 8e1b539fb..e22bb0fe3 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs @@ -19,4 +19,14 @@ public static class DateTimeExtensions { return date.ToString("HH:mm:ss.ff"); } + + /// <summary> + /// Returns a string which can be used as a file name. + /// </summary> + /// <param name="date">The date.</param> + /// <returns></returns> + public static String ToFileName(this DateTime date) + { + return string.Format("{0:dd-MM-yyyy HH-mm-ss}", DateTime.Now); + } } |
