From 1eb4e2409abbcffdab96b5e896cf71850ab13a01 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 2 Apr 2019 11:58:55 +0300 Subject: Working on color capture module... --- .../Controls/IndexedUniformGrid.cs | 12 +- .../Graph/WpfGraphController.cs | 2 +- .../Models/BenchmarkItem.cs | 95 ++++ .../Models/CaptureItem.cs | 17 + .../Tango.MachineStudio.ColorCapture.csproj | 6 + .../Themes/Generic.xaml | 8 +- .../ViewModels/MainViewVM.cs | 103 ++++- .../Views/MainView.xaml | 497 ++++++++++++++------- .../TCC/Benchmarks/benchmarks_rgb_lab.csv | 111 +++++ Software/Visual_Studio/TCC/Images/template.bmp | Bin 0 -> 279054 bytes .../TCC/Tango.TCC.BL/CardDetectionConfig.cs | 30 ++ .../Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs | 38 +- .../TCC/Tango.TCC.BL/ColorDetector.cs | 19 + .../TCC/Tango.TCC.BL/TCC/benchmarks_rgb_lab.csv | 111 +++++ .../TCC/Tango.TCC.BL/Tango.TCC.BL.csproj | 12 + .../TCC/Tango.TCC.CardDetector/ArucoUtils.cpp | 2 - .../TCC/Tango.TCC.CardDetector/CardDetection.cpp | Bin 2730 -> 6576 bytes .../TCC/Tango.TCC.CardDetector/CardDetection.h | Bin 776 -> 1002 bytes .../Tango.TCC.CardDetector/CardDetectionConfig.h | 3 + .../TCC/Tango.TCC.ColorDetector/ColorDetection.cpp | 4 +- .../PMR/TCC/DetectionBenchmark.pb-c.c | 6 +- .../PMR/TCC/DetectionBenchmark.pb-c.h | 6 +- Software/Visual_Studio/Tango.CSV/CsvFileReader.cs | 2 + .../Tango.PMR/TCC/DetectionBenchmark.cs | 70 +-- 24 files changed, 922 insertions(+), 232 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/BenchmarkItem.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs create mode 100644 Software/Visual_Studio/TCC/Benchmarks/benchmarks_rgb_lab.csv create mode 100644 Software/Visual_Studio/TCC/Images/template.bmp create mode 100644 Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs create mode 100644 Software/Visual_Studio/TCC/Tango.TCC.BL/TCC/benchmarks_rgb_lab.csv (limited to 'Software/Visual_Studio') 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() 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 @@ + + Code @@ -140,6 +142,10 @@ {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + {e4927038-348d-4295-aaf4-861c58cb3943} Tango.PMR 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 @@ - - - - + + + + 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 CaptureItems { get; set; } + + private ObservableCollection _benchmarks; + public ObservableCollection Benchmarks + { + get { return _benchmarks; } + set { _benchmarks = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ImportBenchmarksCommand { get; set; } + + public RelayCommand ExportBenchmarksCommand { get; set; } + public MainViewVM() { + CaptureItems = new SynchronizedObservableCollection(); + Benchmarks = new ObservableCollection(); _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(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}"> + 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}"> + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + - - - Capture Device - - - - - - - - - - + + + + + + + + + + + + + + + Capture Device + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - Captured Color - - - - - - - - - - + Rectified Image + + - - - - - - Processed Color - - - - - - - - - - + Calculated Averages + + - - - - - - - - - - - - - - - HISTORY - - - - - - - - - - - - - Delta E Reference Point - - L: - - - A: - - - B: - - - - - - - + + + - - + + - - - - - + + + Captured Color + + + + + + + + + + + + + + + + - + + + Processed Color + + + + + + + + + + + + + + + + - - - + + Delta E Reference Point + + + L: + + + + + A: + + + + + B: + + + + - + + + + + + + + + + + Measures + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Delta E Distance + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/TCC/Benchmarks/benchmarks_rgb_lab.csv b/Software/Visual_Studio/TCC/Benchmarks/benchmarks_rgb_lab.csv new file mode 100644 index 000000000..141397cd4 --- /dev/null +++ b/Software/Visual_Studio/TCC/Benchmarks/benchmarks_rgb_lab.csv @@ -0,0 +1,111 @@ +Red,Green,Blue,L,A,B +0,0,0,0,0,0 +169,169,169,71.12,0.133333333,-0.051666667 +112,112,112,52.7025,-1.2625,0.225 +198,198,198,79.77166667,0.398333333,-1.038333333 +83,83,83,42.17166667,-1.261666667,-0.135 +226,226,226,87.19833333,0.988333333,-2.736666667 +54,54,54,33.112,-1.636,1.224 +255,255,255,94.06833333,1.695,-4.553333333 +26,26,26,24.80833333,-1.2,1.33 +0,0,0,0,0,0 +26,26,26,24.05,-1.5425,1.7175 +179,45,131,46.21333333,53.01666667,-15.06166667 +237,72,35,55.83,49.84666667,47.51333333 +54,70,61,36.79333333,-7.683333333,4.253333333 +38,58,111,30.57833333,8.741666667,-28.87166667 +212,132,66,63.97,19.78,39.89666667 +72,107,66,45.735,-19.39833333,17.27666667 +142,76,97,46.27333333,27.43,-0.658333333 +97,95,162,46.68166667,15.74333333,-30.815 +140,140,140,61.34833333,1.033333333,-0.151666667 +255,255,255,93.77333333,1.765,-4.411666667 +158,154,201,67.955,11.27333333,-20.06 +255,236,0,87.50166667,-12.59166667,78.655 +255,182,4,75.95833333,9.428333333,67.96333333 +243,107,33,61.09,39,52.50833333 +235,35,65,51.09833333,62.24166667,27.82333333 +106,55,134,36.80166667,32.49333333,-30.18666667 +255,185,59,76.87166667,9.426666667,57.305 +243,157,192,74.25,30.54,-7.908333333 +169,169,169,70.22333333,0.92,0.1 +54,54,54,30.775,-0.525,0.32 +116,59,54,39.87,20.87,12.47 +65,108,99,47.85833333,-15.3,1.538333333 +140,76,119,46.595,29.31666667,-10.93333333 +53,59,81,32.97333333,2.943333333,-12.37833333 +138,75,128,46.22333333,30.45666667,-15.91666667 +137,180,113,68.87833333,-23.25666667,27.84333333 +0,158,179,61.18,-20.86,-16.83833333 +113,207,244,78.175,-12.04333333,-22.53833333 +112,112,112,51.61,-0.502,-0.136 +226,226,226,87.13333333,1.495,-3.138333333 +184,50,46,45.52833333,42.72833333,29.61 +238,99,157,62.11,50.415,-7.06 +42,86,65,39.50666667,-17.82333333,8.103333333 +90,176,65,63.03166667,-42.46666667,43.37333333 +233,34,35,50.54666667,60.89166667,42.66 +190,230,250,86.84666667,-4.345,-12.96333333 +17,57,134,32.005,14.47333333,-34.95666667 +0,162,227,63.635,-10.44333333,-33.42166667 +198,198,198,79.01,1.025,-0.918333333 +83,83,83,42.464,-1.92,0.73 +0,172,198,64.285,-21.78166667,-20.35333333 +255,249,205,92.19333333,-3.3,13.94333333 +142,153,81,63.36833333,-13.99,33.38 +230,136,63,66.125,23.97666667,44.36833333 +141,76,111,45.82333333,28.36666667,-7.24 +231,22,127,52.11333333,66.82,-3.993333333 +190,157,147,68.685,10.07166667,7.398333333 +81,180,118,65.39166667,-38.2,21.53333333 +83,83,83,40.794,-0.94,-0.32 +198,198,198,79.14666667,0.791666667,-1.766666667 +234,31,101,52.21833333,64.01666667,8.343333333 +255,203,59,81.59333333,1.206666667,60.66833333 +252,173,144,76.00166667,19.22,17.49833333 +237,73,123,58.05833333,54.47333333,3.016666667 +206,138,159,66.82333333,23.78333333,-2.453333333 +143,76,82,45.865,25.65,7.266666667 +0,129,159,52.54833333,-15.35166667,-20.88666667 +0,130,198,54.21666667,-3.341666667,-36.37833333 +226,226,226,86.78666667,1.36,-2.605 +112,112,112,51.81,-0.583333333,-0.52 +0,152,77,56.07833333,-46.975,31.68 +0,164,72,58.71666667,-49.065,37.25166667 +137,75,137,45.86333333,31.94666667,-19.99 +167,210,173,79.54,-16.565,10.95166667 +59,109,116,47.90833333,-11.37166667,-8.108333333 +141,166,82,66.06833333,-20.29,37.86166667 +186,134,159,63.88,20.75166667,-5.778333333 +202,209,33,78.01833333,-18.415,67.03833333 +54,54,54,32.25,-1.4925,1.52 +169,169,169,71.545,-0.0625,-0.33 +244,110,79,62.268,39.444,32.43 +140,178,84,68.00333333,-25.05166667,39.31166667 +131,124,169,57.03833333,10.89833333,-19.545 +255,240,90,88.664,-11.328,60.484 +35,110,154,47.93333333,-5.69,-27.08833333 +0,125,73,48.08833333,-39.07333333,20.28 +0,86,159,38.855,7.425,-39.47166667 +138,190,85,69.98666667,-29.77333333,41.79833333 +255,255,255,93.715,1.663333333,-4.443333333 +140,140,140,61.934,-0.202,-0.038 +249,207,225,85.474,13.868,-6.676 +0,155,119,57.845,-37.60333333,9.745 +93,167,88,61.77166667,-35.645,29.3 +245,234,143,88.21833333,-8.618333333,37.94666667 +0,183,236,68.89666667,-15.51,-31.53166667 +81,60,92,34.46833333,13.13166667,-14.09 +255,245,153,90.20666667,-7.895,34.44333333 +70,108,81,46.88666667,-18.28333333,11.555 +26,26,26,23.2425,-0.405,0.9525 +0,0,0,0,0,0 +255,255,255,94.11333333,1.658333333,-4.575 +54,54,54,32.195,-1.735,1.2575 +226,226,226,86.62833333,1.258333333,-2.736666667 +83,83,83,40.4025,-0.7875,-1.06 +198,198,198,79.255,1.036666667,-1.23 +112,112,112,51.55,-0.24,-1.1725 +169,169,169,70.695,0.278333333,-0.368333333 +140,140,140,61.43833333,0.363333333,-0.338333333 +0,0,0,0,0,0 diff --git a/Software/Visual_Studio/TCC/Images/template.bmp b/Software/Visual_Studio/TCC/Images/template.bmp new file mode 100644 index 000000000..f54788af9 Binary files /dev/null and b/Software/Visual_Studio/TCC/Images/template.bmp differ diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs new file mode 100644 index 000000000..84acbd777 --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.TCC; + +namespace Tango.TCC.BL +{ + public class CardDetectionConfig + { + public List Benchmarks { get; set; } + public int DesiredBitmapWidth { get; set; } + public int DesiredBitmapHeight { get; set; } + public int Columns { get; set; } + public int Rows { get; set; } + public int TargetIndex { get; set; } + public byte[] TemplateBitmapBytes { get; set; } + + public CardDetectionConfig() + { + DesiredBitmapWidth = 300; + DesiredBitmapHeight = 310; + Columns = 10; + Rows = 11; + TargetIndex = 89; + Benchmarks = new List(); + } + } +} diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs index d10e99b81..5971b4be1 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs @@ -1,11 +1,13 @@ using Google.Protobuf; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Windows.Media.Imaging; +using Tango.Core.Helpers; using Tango.PMR.TCC; namespace Tango.TCC.BL @@ -13,6 +15,8 @@ namespace Tango.TCC.BL public class CardDetector { private ColorDetector _colorDetector; + private static byte[] _defaultTemplate; + private static List _defaultBenchmarks; private bool _canDetect; public bool CanDetect @@ -23,11 +27,17 @@ namespace Tango.TCC.BL public CardDetector() { + if (_defaultTemplate == null) + { + _defaultTemplate = File.ReadAllBytes(AssemblyHelper.GetCurrentAssemblyFolder() + "\\TCC\\template.bmp"); + _defaultBenchmarks = ColorDetector.LoadBenchmarks(AssemblyHelper.GetCurrentAssemblyFolder() + "\\TCC\\benchmarks_rgb_lab.csv").ToList(); + } + CanDetect = true; _colorDetector = new ColorDetector(); } - public Task Detect(BitmapSource source) + public Task Detect(BitmapSource source, CardDetectionConfig config) { if (!CanDetect) { @@ -46,8 +56,9 @@ namespace Tango.TCC.BL Tango.TCC.CardDetector.CardDetection detector = new TCC.CardDetector.CardDetection(); var result = detector.Detect(cloned.ToBytes(PixelFormats.Rgb24), new TCC.CardDetector.CardDetectionConfig() { - DesiredBitmapWidth = 300, - DesiredBitmapHeight = 310, + DesiredBitmapWidth = config.DesiredBitmapWidth, + DesiredBitmapHeight = config.DesiredBitmapHeight, + TemplateBitmap = config.TemplateBitmapBytes != null ? config.TemplateBitmapBytes : _defaultTemplate.ToArray(), }); if (result.IsDetected) @@ -55,14 +66,25 @@ namespace Tango.TCC.BL detectionResult.IsDetected = true; detectionResult.DetectedBitmap = result.DetectedBitmap.ToBitmapSource(); - detectionResult.ColorDetectionOutput = _colorDetector.Detect(new DetectionInput() + var input = new DetectionInput() { Bitmap = ByteString.CopyFrom(detectionResult.DetectedBitmap.ToBmpBytes()), - Columns = 10, - Rows = 11, - TargetIndex = 89, + Columns = config.Columns, + Rows = config.Rows, + TargetIndex = config.TargetIndex, RequestColorMatrix = true, - }); + }; + + if (config.Benchmarks.Count > 0) + { + input.Benchmarks.AddRange(config.Benchmarks); + } + else + { + input.Benchmarks.AddRange(_defaultBenchmarks); + } + + detectionResult.ColorDetectionOutput = _colorDetector.Detect(input); } CanDetect = true; diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/ColorDetector.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/ColorDetector.cs index e3c80cb20..a41124c42 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/ColorDetector.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/ColorDetector.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using System.Web.Hosting; using Tango.Core.Helpers; +using Tango.CSV; using Tango.PMR; using Tango.PMR.TCC; @@ -152,6 +153,24 @@ namespace Tango.TCC.BL return index == 1 || index == columns || index == columns * rows || index == (columns * rows) - columns + 1; } + public static IEnumerable LoadBenchmarks(String file) + { + var benchmarks = CsvFile.Read(new CsvSource(file)).ToList(); + return benchmarks; + } + + public static void SaveBenchmarks(String file,IEnumerable benchmarks) + { + CsvFile csvFile = new CsvFile(new CsvDestination(file)); + + foreach (var item in benchmarks) + { + csvFile.Append(item); + } + + csvFile.Dispose(); + } + public void Dispose() { if (!_isDisposed) diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/TCC/benchmarks_rgb_lab.csv b/Software/Visual_Studio/TCC/Tango.TCC.BL/TCC/benchmarks_rgb_lab.csv new file mode 100644 index 000000000..141397cd4 --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/TCC/benchmarks_rgb_lab.csv @@ -0,0 +1,111 @@ +Red,Green,Blue,L,A,B +0,0,0,0,0,0 +169,169,169,71.12,0.133333333,-0.051666667 +112,112,112,52.7025,-1.2625,0.225 +198,198,198,79.77166667,0.398333333,-1.038333333 +83,83,83,42.17166667,-1.261666667,-0.135 +226,226,226,87.19833333,0.988333333,-2.736666667 +54,54,54,33.112,-1.636,1.224 +255,255,255,94.06833333,1.695,-4.553333333 +26,26,26,24.80833333,-1.2,1.33 +0,0,0,0,0,0 +26,26,26,24.05,-1.5425,1.7175 +179,45,131,46.21333333,53.01666667,-15.06166667 +237,72,35,55.83,49.84666667,47.51333333 +54,70,61,36.79333333,-7.683333333,4.253333333 +38,58,111,30.57833333,8.741666667,-28.87166667 +212,132,66,63.97,19.78,39.89666667 +72,107,66,45.735,-19.39833333,17.27666667 +142,76,97,46.27333333,27.43,-0.658333333 +97,95,162,46.68166667,15.74333333,-30.815 +140,140,140,61.34833333,1.033333333,-0.151666667 +255,255,255,93.77333333,1.765,-4.411666667 +158,154,201,67.955,11.27333333,-20.06 +255,236,0,87.50166667,-12.59166667,78.655 +255,182,4,75.95833333,9.428333333,67.96333333 +243,107,33,61.09,39,52.50833333 +235,35,65,51.09833333,62.24166667,27.82333333 +106,55,134,36.80166667,32.49333333,-30.18666667 +255,185,59,76.87166667,9.426666667,57.305 +243,157,192,74.25,30.54,-7.908333333 +169,169,169,70.22333333,0.92,0.1 +54,54,54,30.775,-0.525,0.32 +116,59,54,39.87,20.87,12.47 +65,108,99,47.85833333,-15.3,1.538333333 +140,76,119,46.595,29.31666667,-10.93333333 +53,59,81,32.97333333,2.943333333,-12.37833333 +138,75,128,46.22333333,30.45666667,-15.91666667 +137,180,113,68.87833333,-23.25666667,27.84333333 +0,158,179,61.18,-20.86,-16.83833333 +113,207,244,78.175,-12.04333333,-22.53833333 +112,112,112,51.61,-0.502,-0.136 +226,226,226,87.13333333,1.495,-3.138333333 +184,50,46,45.52833333,42.72833333,29.61 +238,99,157,62.11,50.415,-7.06 +42,86,65,39.50666667,-17.82333333,8.103333333 +90,176,65,63.03166667,-42.46666667,43.37333333 +233,34,35,50.54666667,60.89166667,42.66 +190,230,250,86.84666667,-4.345,-12.96333333 +17,57,134,32.005,14.47333333,-34.95666667 +0,162,227,63.635,-10.44333333,-33.42166667 +198,198,198,79.01,1.025,-0.918333333 +83,83,83,42.464,-1.92,0.73 +0,172,198,64.285,-21.78166667,-20.35333333 +255,249,205,92.19333333,-3.3,13.94333333 +142,153,81,63.36833333,-13.99,33.38 +230,136,63,66.125,23.97666667,44.36833333 +141,76,111,45.82333333,28.36666667,-7.24 +231,22,127,52.11333333,66.82,-3.993333333 +190,157,147,68.685,10.07166667,7.398333333 +81,180,118,65.39166667,-38.2,21.53333333 +83,83,83,40.794,-0.94,-0.32 +198,198,198,79.14666667,0.791666667,-1.766666667 +234,31,101,52.21833333,64.01666667,8.343333333 +255,203,59,81.59333333,1.206666667,60.66833333 +252,173,144,76.00166667,19.22,17.49833333 +237,73,123,58.05833333,54.47333333,3.016666667 +206,138,159,66.82333333,23.78333333,-2.453333333 +143,76,82,45.865,25.65,7.266666667 +0,129,159,52.54833333,-15.35166667,-20.88666667 +0,130,198,54.21666667,-3.341666667,-36.37833333 +226,226,226,86.78666667,1.36,-2.605 +112,112,112,51.81,-0.583333333,-0.52 +0,152,77,56.07833333,-46.975,31.68 +0,164,72,58.71666667,-49.065,37.25166667 +137,75,137,45.86333333,31.94666667,-19.99 +167,210,173,79.54,-16.565,10.95166667 +59,109,116,47.90833333,-11.37166667,-8.108333333 +141,166,82,66.06833333,-20.29,37.86166667 +186,134,159,63.88,20.75166667,-5.778333333 +202,209,33,78.01833333,-18.415,67.03833333 +54,54,54,32.25,-1.4925,1.52 +169,169,169,71.545,-0.0625,-0.33 +244,110,79,62.268,39.444,32.43 +140,178,84,68.00333333,-25.05166667,39.31166667 +131,124,169,57.03833333,10.89833333,-19.545 +255,240,90,88.664,-11.328,60.484 +35,110,154,47.93333333,-5.69,-27.08833333 +0,125,73,48.08833333,-39.07333333,20.28 +0,86,159,38.855,7.425,-39.47166667 +138,190,85,69.98666667,-29.77333333,41.79833333 +255,255,255,93.715,1.663333333,-4.443333333 +140,140,140,61.934,-0.202,-0.038 +249,207,225,85.474,13.868,-6.676 +0,155,119,57.845,-37.60333333,9.745 +93,167,88,61.77166667,-35.645,29.3 +245,234,143,88.21833333,-8.618333333,37.94666667 +0,183,236,68.89666667,-15.51,-31.53166667 +81,60,92,34.46833333,13.13166667,-14.09 +255,245,153,90.20666667,-7.895,34.44333333 +70,108,81,46.88666667,-18.28333333,11.555 +26,26,26,23.2425,-0.405,0.9525 +0,0,0,0,0,0 +255,255,255,94.11333333,1.658333333,-4.575 +54,54,54,32.195,-1.735,1.2575 +226,226,226,86.62833333,1.258333333,-2.736666667 +83,83,83,40.4025,-0.7875,-1.06 +198,198,198,79.255,1.036666667,-1.23 +112,112,112,51.55,-0.24,-1.1725 +169,169,169,70.695,0.278333333,-0.368333333 +140,140,140,61.43833333,0.363333333,-0.338333333 +0,0,0,0,0,0 diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj b/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj index bb82e8c5d..df87e66b8 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj @@ -51,6 +51,7 @@ + @@ -60,12 +61,19 @@ + + PreserveNewest + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + {e4927038-348d-4295-aaf4-861c58cb3943} Tango.PMR @@ -96,6 +104,10 @@ Tango.TCC.LoadTestLib.dll PreserveNewest + + TCC\template.bmp + PreserveNewest + diff --git a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/ArucoUtils.cpp b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/ArucoUtils.cpp index 76923a5c6..52721368a 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/ArucoUtils.cpp +++ b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/ArucoUtils.cpp @@ -81,8 +81,6 @@ Mat ArucoUtils::applyHomography(Mat image, vector vertices, Size dest pts_dst.push_back(Point2f(destination_size.width - 1, destination_size.height - 1)); pts_dst.push_back(Point2f(0, destination_size.height - 1)); - Mat im_temp = image.clone(); - Mat tform = findHomography(vertices, pts_dst); warpPerspective(image, im_dst, tform, destination_size); return im_dst; diff --git a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp index 546c228db..63b2f59a6 100644 Binary files a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp and b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp differ diff --git a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.h b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.h index db8f51406..c240a2502 100644 Binary files a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.h and b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.h differ diff --git a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h index f014c2159..a6e104b53 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h +++ b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h @@ -1,5 +1,7 @@ #pragma once +using namespace System; + namespace Tango { namespace TCC @@ -11,6 +13,7 @@ namespace Tango CardDetectionConfig(); property double DesiredBitmapWidth; property double DesiredBitmapHeight; + property cli::array^ TemplateBitmap; }; } } diff --git a/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/ColorDetection.cpp b/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/ColorDetection.cpp index 5a7734c0e..fe92c0f4c 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/ColorDetection.cpp +++ b/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/ColorDetection.cpp @@ -462,7 +462,7 @@ size_t ColorDetection::DetectColorNew(uint8_t * input_buffer, size_t input_buffe detectionOutput->colormatrix[i] = initDetectionColor(means[i].val[2], means[i].val[1], means[i].val[0]); } } - + //Put original target color. detectionOutput->rawcolor = initDetectionColor(target_mean.val[2], target_mean.val[1], target_mean.val[0]); @@ -471,7 +471,7 @@ size_t ColorDetection::DetectColorNew(uint8_t * input_buffer, size_t input_buffe detectionInput->benchmarks[0]->l; //Put processed target color. - detectionOutput->processedcolor = initDetectionColor(255, 0, 0); + detectionOutput->processedcolor = initDetectionColor(target_mean.val[2] + 10, target_mean.val[1] + 10, target_mean.val[0] + 10); detectionOutput->has_number = true; detectionOutput->number = detectionInput->number + 10; diff --git a/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.c b/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.c index afc3c7302..91e8dee86 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.c +++ b/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.c @@ -94,7 +94,7 @@ static const ProtobufCFieldDescriptor detection_benchmark__field_descriptors[6] "L", 4, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, + PROTOBUF_C_TYPE_DOUBLE, offsetof(DetectionBenchmark, has_l), offsetof(DetectionBenchmark, l), NULL, @@ -106,7 +106,7 @@ static const ProtobufCFieldDescriptor detection_benchmark__field_descriptors[6] "A", 5, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, + PROTOBUF_C_TYPE_DOUBLE, offsetof(DetectionBenchmark, has_a), offsetof(DetectionBenchmark, a), NULL, @@ -118,7 +118,7 @@ static const ProtobufCFieldDescriptor detection_benchmark__field_descriptors[6] "B", 6, PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, + PROTOBUF_C_TYPE_DOUBLE, offsetof(DetectionBenchmark, has_b), offsetof(DetectionBenchmark, b), NULL, diff --git a/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.h b/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.h index d7368eed8..b7f5c863d 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.h +++ b/Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.h @@ -33,11 +33,11 @@ struct _DetectionBenchmark protobuf_c_boolean has_blue; int32_t blue; protobuf_c_boolean has_l; - int32_t l; + double l; protobuf_c_boolean has_a; - int32_t a; + double a; protobuf_c_boolean has_b; - int32_t b; + double b; }; #define DETECTION_BENCHMARK__INIT \ { PROTOBUF_C_MESSAGE_INIT (&detection_benchmark__descriptor) \ diff --git a/Software/Visual_Studio/Tango.CSV/CsvFileReader.cs b/Software/Visual_Studio/Tango.CSV/CsvFileReader.cs index 1ae9404a7..6d1deded2 100644 --- a/Software/Visual_Studio/Tango.CSV/CsvFileReader.cs +++ b/Software/Visual_Studio/Tango.CSV/CsvFileReader.cs @@ -273,6 +273,8 @@ namespace Tango.CSV return (s) => String.IsNullOrEmpty(s) ? 0 : Int32.Parse(s); if (propertyType == typeof(DateTime)) return (s) => String.IsNullOrEmpty(s) ? DateTimeZero : DateTime.Parse(s); + else if (propertyType == typeof(Double)) + return (s) => String.IsNullOrEmpty(s) ? 0.0 : Double.Parse(s); else throw new NotImplementedException(); } diff --git a/Software/Visual_Studio/Tango.PMR/TCC/DetectionBenchmark.cs b/Software/Visual_Studio/Tango.PMR/TCC/DetectionBenchmark.cs index a7e2d47ae..cd106db9a 100644 --- a/Software/Visual_Studio/Tango.PMR/TCC/DetectionBenchmark.cs +++ b/Software/Visual_Studio/Tango.PMR/TCC/DetectionBenchmark.cs @@ -24,8 +24,8 @@ namespace Tango.PMR.TCC { string.Concat( "ChhEZXRlY3Rpb25CZW5jaG1hcmsucHJvdG8SDVRhbmdvLlBNUi5UQ0MiXwoS", "RGV0ZWN0aW9uQmVuY2htYXJrEgsKA1JlZBgBIAEoBRINCgVHcmVlbhgCIAEo", - "BRIMCgRCbHVlGAMgASgFEgkKAUwYBCABKAUSCQoBQRgFIAEoBRIJCgFCGAYg", - "ASgFQhkKF2NvbS50d2luZS50YW5nby5wbXIudGNjYgZwcm90bzM=")); + "BRIMCgRCbHVlGAMgASgFEgkKAUwYBCABKAESCQoBQRgFIAEoARIJCgFCGAYg", + "ASgBQhkKF2NvbS50d2luZS50YW5nby5wbXIudGNjYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { @@ -108,9 +108,9 @@ namespace Tango.PMR.TCC { /// Field number for the "L" field. public const int LFieldNumber = 4; - private int l_; + private double l_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int L { + public double L { get { return l_; } set { l_ = value; @@ -119,9 +119,9 @@ namespace Tango.PMR.TCC { /// Field number for the "A" field. public const int AFieldNumber = 5; - private int a_; + private double a_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int A { + public double A { get { return a_; } set { a_ = value; @@ -130,9 +130,9 @@ namespace Tango.PMR.TCC { /// Field number for the "B" field. public const int BFieldNumber = 6; - private int b_; + private double b_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int B { + public double B { get { return b_; } set { b_ = value; @@ -167,9 +167,9 @@ namespace Tango.PMR.TCC { if (Red != 0) hash ^= Red.GetHashCode(); if (Green != 0) hash ^= Green.GetHashCode(); if (Blue != 0) hash ^= Blue.GetHashCode(); - if (L != 0) hash ^= L.GetHashCode(); - if (A != 0) hash ^= A.GetHashCode(); - if (B != 0) hash ^= B.GetHashCode(); + if (L != 0D) hash ^= L.GetHashCode(); + if (A != 0D) hash ^= A.GetHashCode(); + if (B != 0D) hash ^= B.GetHashCode(); return hash; } @@ -192,17 +192,17 @@ namespace Tango.PMR.TCC { output.WriteRawTag(24); output.WriteInt32(Blue); } - if (L != 0) { - output.WriteRawTag(32); - output.WriteInt32(L); + if (L != 0D) { + output.WriteRawTag(33); + output.WriteDouble(L); } - if (A != 0) { - output.WriteRawTag(40); - output.WriteInt32(A); + if (A != 0D) { + output.WriteRawTag(41); + output.WriteDouble(A); } - if (B != 0) { - output.WriteRawTag(48); - output.WriteInt32(B); + if (B != 0D) { + output.WriteRawTag(49); + output.WriteDouble(B); } } @@ -218,14 +218,14 @@ namespace Tango.PMR.TCC { if (Blue != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Blue); } - if (L != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(L); + if (L != 0D) { + size += 1 + 8; } - if (A != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); + if (A != 0D) { + size += 1 + 8; } - if (B != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(B); + if (B != 0D) { + size += 1 + 8; } return size; } @@ -244,13 +244,13 @@ namespace Tango.PMR.TCC { if (other.Blue != 0) { Blue = other.Blue; } - if (other.L != 0) { + if (other.L != 0D) { L = other.L; } - if (other.A != 0) { + if (other.A != 0D) { A = other.A; } - if (other.B != 0) { + if (other.B != 0D) { B = other.B; } } @@ -275,16 +275,16 @@ namespace Tango.PMR.TCC { Blue = input.ReadInt32(); break; } - case 32: { - L = input.ReadInt32(); + case 33: { + L = input.ReadDouble(); break; } - case 40: { - A = input.ReadInt32(); + case 41: { + A = input.ReadDouble(); break; } - case 48: { - B = input.ReadInt32(); + case 49: { + B = input.ReadDouble(); break; } } -- cgit v1.3.1