aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Software/PMR/Messages/TCC/DetectionBenchmark.proto6
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Controls/IndexedUniformGrid.cs12
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Graph/WpfGraphController.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/BenchmarkItem.cs95
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureItem.cs17
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj6
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Themes/Generic.xaml8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs103
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml487
-rw-r--r--Software/Visual_Studio/TCC/Benchmarks/benchmarks_rgb_lab.csv111
-rw-r--r--Software/Visual_Studio/TCC/Images/template.bmpbin0 -> 279054 bytes
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs30
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs38
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/ColorDetector.cs19
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/TCC/benchmarks_rgb_lab.csv111
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj12
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.CardDetector/ArucoUtils.cpp2
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cppbin2730 -> 6576 bytes
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.hbin776 -> 1002 bytes
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h3
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/ColorDetection.cpp4
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.c6
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.ColorDetector/PMR/TCC/DetectionBenchmark.pb-c.h6
-rw-r--r--Software/Visual_Studio/Tango.CSV/CsvFileReader.cs2
-rw-r--r--Software/Visual_Studio/Tango.PMR/TCC/DetectionBenchmark.cs70
25 files changed, 920 insertions, 230 deletions
diff --git a/Software/PMR/Messages/TCC/DetectionBenchmark.proto b/Software/PMR/Messages/TCC/DetectionBenchmark.proto
index a512dfa5f..0a6fb42f2 100644
--- a/Software/PMR/Messages/TCC/DetectionBenchmark.proto
+++ b/Software/PMR/Messages/TCC/DetectionBenchmark.proto
@@ -9,7 +9,7 @@ message DetectionBenchmark
int32 Green = 2;
int32 Blue = 3;
- int32 L = 4;
- int32 A = 5;
- int32 B = 6;
+ double L = 4;
+ double A = 5;
+ double B = 6;
} \ No newline at end of file
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>
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
--- /dev/null
+++ b/Software/Visual_Studio/TCC/Images/template.bmp
Binary files 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<DetectionBenchmark> 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<DetectionBenchmark>();
+ }
+ }
+}
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<DetectionBenchmark> _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<CardDetectionResult> Detect(BitmapSource source)
+ public Task<CardDetectionResult> 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<DetectionBenchmark> LoadBenchmarks(String file)
+ {
+ var benchmarks = CsvFile.Read<DetectionBenchmark>(new CsvSource(file)).ToList();
+ return benchmarks;
+ }
+
+ public static void SaveBenchmarks(String file,IEnumerable<DetectionBenchmark> benchmarks)
+ {
+ CsvFile<DetectionBenchmark> csvFile = new CsvFile<DetectionBenchmark>(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 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="CardDetectionConfig.cs" />
<Compile Include="CardDetectionResult.cs" />
<Compile Include="CardDetector.cs" />
<Compile Include="ColorDetector.cs" />
@@ -60,12 +61,19 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+ <None Include="TCC\benchmarks_rgb_lab.csv">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj">
<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>
@@ -96,6 +104,10 @@
<Link>Tango.TCC.LoadTestLib.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="..\Images\template.bmp">
+ <Link>TCC\template.bmp</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
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<cv::Point> 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
--- a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp
+++ b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp
Binary files 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
--- a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.h
+++ b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.h
Binary files 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<Byte>^ 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 {
/// <summary>Field number for the "L" field.</summary>
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 {
/// <summary>Field number for the "A" field.</summary>
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 {
/// <summary>Field number for the "B" field.</summary>
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;
}
}