Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions DigitDisplay.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitDisplay", "DigitDisplay\DigitDisplay.csproj", "{8E1C0000-6DD5-42E0-8DAD-D75AF1FC249F}"
EndProject
Expand All @@ -13,6 +13,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FunctionalRecognizer", "Fun
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Recognizer", "Recognizer\Recognizer.csproj", "{F15E6F19-7B0D-48A5-B505-7C9658D208CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObservationLoader", "ObservationLoader\ObservationLoader.csproj", "{301EC918-D5E6-4C89-9CD0-84C35FC7413C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -39,8 +41,15 @@ Global
{F15E6F19-7B0D-48A5-B505-7C9658D208CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F15E6F19-7B0D-48A5-B505-7C9658D208CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F15E6F19-7B0D-48A5-B505-7C9658D208CC}.Release|Any CPU.Build.0 = Release|Any CPU
{301EC918-D5E6-4C89-9CD0-84C35FC7413C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{301EC918-D5E6-4C89-9CD0-84C35FC7413C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{301EC918-D5E6-4C89-9CD0-84C35FC7413C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{301EC918-D5E6-4C89-9CD0-84C35FC7413C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC5565F2-8C3B-4A75-97DA-2219CC4C2A83}
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions DigitDisplay/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<appSettings>
<add key="trainingFile" value="train.csv"/>
<add key="dataFile" value="train.csv"/>
<add key="recordCount" value="459"/>
<add key="offset" value="1000"/>
</appSettings>
</configuration>
</configuration>
8 changes: 1 addition & 7 deletions DigitDisplay/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace DigitDisplay
{
Expand Down
24 changes: 13 additions & 11 deletions DigitDisplay/DigitDisplay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DigitDisplay</RootNamespace>
<AssemblyName>DigitDisplay</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -40,6 +41,9 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand All @@ -57,11 +61,8 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ParallelRecognizerControl.xaml.cs">
<DependentUpon>ParallelRecognizerControl.xaml</DependentUpon>
</Compile>
<Compile Include="RecognizerControl.xaml.cs">
<DependentUpon>RecognizerControl.xaml</DependentUpon>
<Compile Include="RecognizerUserControl.xaml.cs">
<DependentUpon>RecognizerUserControl.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
Expand All @@ -76,14 +77,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="ParallelRecognizerControl.xaml">
<Page Include="RecognizerUserControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="RecognizerControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand All @@ -103,6 +100,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -123,6 +121,10 @@
<Project>{ff2cd045-8b57-422c-954a-ab2cbbe6c065}</Project>
<Name>FunctionalRecognizer</Name>
</ProjectReference>
<ProjectReference Include="..\ObservationLoader\ObservationLoader.csproj">
<Project>{301ec918-d5e6-4c89-9cd0-84c35fc7413c}</Project>
<Name>ObservationLoader</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
7 changes: 1 addition & 6 deletions DigitDisplay/ImageHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;

namespace DigitDisplay
Expand Down
60 changes: 31 additions & 29 deletions DigitDisplay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
using DigitLoader;
using Microsoft.FSharp.Core;
using System;
using System;
using DigitLoader;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ObservationLoader;

namespace DigitDisplay
{
public partial class MainWindow : Window
public partial class MainWindow
{
SolidColorBrush redBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 150, 150));
SolidColorBrush whiteBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 255, 255));

public MainWindow()
{
InitializeComponent();
Expand All @@ -29,32 +22,41 @@ private void GoButton_Click(object sender, RoutedEventArgs e)
LeftPanel.Children.Clear();
RightPanel.Children.Clear();

string[] rawData = FileLoader.LoadDataStrings();
var rawData = FileLoader.LoadObservations();

var parallelManhattanRecognizer = new ParallelRecognizerControl(
"Parallel Manhattan Classifier", Recognizer.manhattanClassifier,
var parallelManhattanRecognizer = new RecognizerUserControl(
"Parallel Manhattan Classifier", DispatchManhattanParallelForEach,
rawData);
LeftPanel.Children.Add(parallelManhattanRecognizer);

var manhattanRecognizer = new RecognizerControl(
"Manhattan Classifier", Recognizer.manhattanClassifier,
var manhattanRecognizer = new RecognizerUserControl(
"Manhattan Classifier", DispatchManhattanTasks,
rawData);
RightPanel.Children.Add(manhattanRecognizer);
}

//var euclideanRecognizer = new RecognizerControl(
// "Euclidean Classifier", Recognizer.euclideanClassifier,
// rawData);
//RightPanel.Children.Add(euclideanRecognizer);

//var nullRecognizer = new RecognizerControl(
// "Null Classifier", (FSharpFunc<int[], string>)Recognizer.nullClassifier,
// rawData);
//RightPanel.Children.Add(nullRecognizer);
private static void DispatchManhattanParallelForEach((Observation observation, Action<string> showResult)[] input)
{
var uiContext = SynchronizationContext.Current;
ThreadPool.QueueUserWorkItem(state => Parallel.ForEach(input, current =>
{
var predicted = Recognizer.predict(current.observation.Pixels, Recognizer.manhattanClassifier);
uiContext.Post(_ => current.showResult(predicted), null);
}));
}

//var firstPixelRecognizer = new RecognizerControl(
// "FirstPixel Classifier", (FSharpFunc<int[], string>)Recognizer.firstPixelClassifier,
// rawData);
//LeftPanel.Children.Add(firstPixelRecognizer);
private static void DispatchManhattanTasks((Observation observation, Action<string> showResult)[] input)
{
foreach (var current in input)
{
Task
.Run(() => Recognizer.predict(current.observation.Pixels, Recognizer.manhattanClassifier))
.ContinueWith(t =>
{
current.showResult(t.Result);
},
TaskScheduler.FromCurrentSynchronizationContext());
}
}
}
}
25 changes: 0 additions & 25 deletions DigitDisplay/ParallelRecognizerControl.xaml

This file was deleted.

Loading