├── dxcafe1.png
├── dxcafe2.png
├── ml model.png
├── dxcafe
├── images
│ ├── b.jpg
│ ├── m.jpg
│ ├── y.jpg
│ ├── cafe.jpg
│ ├── cafe.png
│ ├── background.png
│ └── noperson.jpg
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── App.xaml
├── App.xaml.cs
├── App.config
├── packages.config
├── LiveCameraResult.cs
├── ScoredMenu.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── dxcafe.csproj
├── VideoFrameAnalyzer
├── packages.config
├── ConcurrentLogger.cs
├── VideoFrame.cs
├── Properties
│ └── AssemblyInfo.cs
├── VideoFrameAnalyzer.csproj
└── FrameGrabber.cs
├── ServiceHelpers
├── app.config
├── packages.config
├── ErrorTrackingHelper.cs
├── Properties
│ └── AssemblyInfo.cs
├── CoreUtil.cs
├── PhotoEvent.cs
├── EmotionServiceHelper.cs
├── ServiceHelpers.csproj
├── BingSearchHelper.cs
├── TextAnalyticsHelper.cs
├── FaceListManager.cs
├── FaceServiceHelper.cs
└── ImageAnalyzer.cs
├── readme.md
├── .gitattributes
├── .gitignore
└── dxcafe.sln
/dxcafe1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe1.png
--------------------------------------------------------------------------------
/dxcafe2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe2.png
--------------------------------------------------------------------------------
/ml model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/ml model.png
--------------------------------------------------------------------------------
/dxcafe/images/b.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/b.jpg
--------------------------------------------------------------------------------
/dxcafe/images/m.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/m.jpg
--------------------------------------------------------------------------------
/dxcafe/images/y.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/y.jpg
--------------------------------------------------------------------------------
/dxcafe/images/cafe.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/cafe.jpg
--------------------------------------------------------------------------------
/dxcafe/images/cafe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/cafe.png
--------------------------------------------------------------------------------
/dxcafe/images/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/background.png
--------------------------------------------------------------------------------
/dxcafe/images/noperson.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/options/dxcafe/master/dxcafe/images/noperson.jpg
--------------------------------------------------------------------------------
/dxcafe/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/VideoFrameAnalyzer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/dxcafe/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dxcafe/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace dxcafe
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ServiceHelpers/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/dxcafe/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ServiceHelpers/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dxcafe/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/dxcafe/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace dxcafe.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # DXCafe : *Cognitive Kiosk*
2 | *This application was developed during Korea DX ISV Team Hackfest of Microsoft Korea.*
3 |
4 | I have developed this applications using a variety of Microsoft technologies based on the intent of the event,
5 |
6 | ## The scenarios is:
7 | * DXCafe is a café that sells a variety of coffees.
8 | * Behind the existing ordering method, Now, the customer can order a coffee DXCafe kiosk system.
9 | * This automatically, recognize the user's face, and recommend the menu based on the previous order history.
10 | * When the day ends, the order list is delivered to the manager.
11 |
12 | ## This application was developed using the following technologies:
13 | * Client Application: Use **WPF**.
14 | * Face Recognition: Use **Cognitive Service** to distinguish users face compared to previously registered faces.
15 | * Menu Recommendation: Use the learned **Azure ML** expectation Model using the user's previous order information.
16 | * REST API Hosting : **Azure App Service** is used to execute Azure ML service
17 | * Ordering Information: Workflow is configured using **Microsoft PowerApp** and **Microsoft Flow**.
18 |
19 | ## Screenshot
20 |
21 | 
22 | 
23 |
24 | ## Azure ML Expectation Model
25 | 
26 |
--------------------------------------------------------------------------------
/dxcafe/LiveCameraResult.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using System;
35 | using System.Collections.Generic;
36 | using System.Linq;
37 | using System.Text;
38 | using System.Threading.Tasks;
39 |
40 | namespace dxcafe
41 | {
42 | // Class to hold all possible result types.
43 | public class LiveCameraResult
44 | {
45 | public Microsoft.ProjectOxford.Face.Contract.Face[] Faces { get; set; } = null;
46 | public Microsoft.ProjectOxford.Emotion.Contract.Scores[] EmotionScores { get; set; } = null;
47 | public string[] CelebrityNames { get; set; } = null;
48 | public Microsoft.ProjectOxford.Vision.Contract.Tag[] Tags { get; set; } = null;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ServiceHelpers/ErrorTrackingHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using System;
35 | using System.Collections.Generic;
36 | using System.Linq;
37 | using System.Text;
38 | using System.Threading.Tasks;
39 |
40 | namespace ServiceHelpers
41 | {
42 | public static class ErrorTrackingHelper
43 | {
44 | // callbacks for exception tracking
45 | public static Action TrackException { get; set; }
46 | = (exception, message) => { };
47 |
48 | // callbacks for blocking UI error message
49 | public static Func GenericApiCallExceptionHandler { get; set; }
50 | = (ex, errorTitle) => Task.FromResult(0);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/dxcafe/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("dxcafe")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("dxcafe")]
15 | [assembly: AssemblyCopyright("Copyright © 2016")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/ServiceHelpers/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using System.Resources;
35 | using System.Reflection;
36 | using System.Runtime.CompilerServices;
37 | using System.Runtime.InteropServices;
38 |
39 | // General Information about an assembly is controlled through the following
40 | // set of attributes. Change these attribute values to modify the information
41 | // associated with an assembly.
42 | [assembly: AssemblyTitle("ServiceHelpers")]
43 | [assembly: AssemblyDescription("")]
44 | [assembly: AssemblyConfiguration("")]
45 | [assembly: AssemblyCompany("")]
46 | [assembly: AssemblyProduct("ServiceHelpers")]
47 | [assembly: AssemblyCopyright("Copyright © 2016")]
48 | [assembly: AssemblyTrademark("")]
49 | [assembly: AssemblyCulture("")]
50 | [assembly: NeutralResourcesLanguage("en")]
51 |
52 | // Version information for an assembly consists of the following four values:
53 | //
54 | // Major Version
55 | // Minor Version
56 | // Build Number
57 | // Revision
58 | //
59 | // You can specify all the values or you can default the Build and Revision Numbers
60 | // by using the '*' as shown below:
61 | // [assembly: AssemblyVersion("1.0.*")]
62 | [assembly: AssemblyVersion("1.0.0.0")]
63 | [assembly: AssemblyFileVersion("1.0.0.0")]
64 |
--------------------------------------------------------------------------------
/VideoFrameAnalyzer/ConcurrentLogger.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using System;
35 | using System.Collections.Concurrent;
36 | using System.Threading;
37 | using System.Threading.Tasks;
38 |
39 | namespace VideoFrameAnalyzer
40 | {
41 | public static class ConcurrentLogger
42 | {
43 | private readonly static SemaphoreSlim s_printMutex = new SemaphoreSlim(1);
44 | private readonly static BlockingCollection s_messageQueue = new BlockingCollection();
45 |
46 | public static void WriteLine(string message)
47 | {
48 | var timestamp = DateTime.Now;
49 | // Push the message on the queue
50 | s_messageQueue.Add(timestamp.ToString("o") + ": " + message);
51 | // Start a new task that will dequeue one message and print it. The tasks will not
52 | // necessarily run in order, but since each task just takes the oldest message and
53 | // prints it, the messages will print in order.
54 | Task.Run(async () =>
55 | {
56 | // Wait to get access to the queue.
57 | await s_printMutex.WaitAsync();
58 | try
59 | {
60 | string msg = s_messageQueue.Take();
61 | Console.WriteLine(msg);
62 | }
63 | finally
64 | {
65 | s_printMutex.Release();
66 | }
67 | });
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/dxcafe/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace dxcafe.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("dxcafe.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/VideoFrameAnalyzer/VideoFrame.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using System;
35 | using OpenCvSharp;
36 |
37 | namespace VideoFrameAnalyzer
38 | {
39 | /// Metadata for a VideoFrame.
40 | public struct VideoFrameMetadata
41 | {
42 | public DateTime Timestamp;
43 | public int Index;
44 | }
45 |
46 | /// A video frame produced by the .
47 | /// This class encapsulates the image, any metadata, and also allows the user to attach
48 | /// some arbitrary data to each frame as it flows through the pipeline.
49 | public class VideoFrame
50 | {
51 | /// Constructor.
52 | /// The image captured by the camera.
53 | /// The metadata.
54 | public VideoFrame(Mat image, VideoFrameMetadata metadata)
55 | {
56 | Image = image;
57 | Metadata = metadata;
58 | }
59 |
60 | /// Gets the image for the frame.
61 | /// The image.
62 | public Mat Image { get; }
63 |
64 | /// Gets the frame's metadata.
65 | /// The metadata.
66 | public VideoFrameMetadata Metadata { get; }
67 |
68 | /// Gets or sets the frame's "user data".
69 | /// Any additional data that the user would like to attach to a video frame.
70 | public object UserData { get; set; } = null;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/VideoFrameAnalyzer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using System.Reflection;
35 | using System.Runtime.CompilerServices;
36 | using System.Runtime.InteropServices;
37 |
38 | // General Information about an assembly is controlled through the following
39 | // set of attributes. Change these attribute values to modify the information
40 | // associated with an assembly.
41 | [assembly: AssemblyTitle("VideoFrameAnalyzer")]
42 | [assembly: AssemblyDescription("")]
43 | [assembly: AssemblyConfiguration("")]
44 | [assembly: AssemblyCompany("")]
45 | [assembly: AssemblyProduct("VideoFrameAnalyzer")]
46 | [assembly: AssemblyCopyright("Copyright \u00A9 2016")]
47 | [assembly: AssemblyTrademark("")]
48 | [assembly: AssemblyCulture("")]
49 |
50 | // Setting ComVisible to false makes the types in this assembly not visible
51 | // to COM components. If you need to access a type in this assembly from
52 | // COM, set the ComVisible attribute to true on that type.
53 | [assembly: ComVisible(false)]
54 |
55 | // The following GUID is for the ID of the typelib if this project is exposed to COM
56 | [assembly: Guid("bec7da78-c953-4a72-924f-2749d1f9f18b")]
57 |
58 | // Version information for an assembly consists of the following four values:
59 | //
60 | // Major Version
61 | // Minor Version
62 | // Build Number
63 | // Revision
64 | //
65 | // You can specify all the values or you can default the Build and Revision Numbers
66 | // by using the '*' as shown below:
67 | // [assembly: AssemblyVersion("1.0.*")]
68 | [assembly: AssemblyVersion("1.0.0.0")]
69 | [assembly: AssemblyFileVersion("1.0.0.0")]
70 |
--------------------------------------------------------------------------------
/ServiceHelpers/CoreUtil.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using Microsoft.ProjectOxford.Common;
35 | using Microsoft.ProjectOxford.Face;
36 | using System;
37 | using System.Collections.Generic;
38 | using System.IO;
39 | using System.Linq;
40 | using System.Threading.Tasks;
41 | using Microsoft.ProjectOxford.Face.Contract;
42 | using Microsoft.ProjectOxford.Emotion.Contract;
43 |
44 | namespace ServiceHelpers
45 | {
46 | public class CoreUtil
47 | {
48 | public static uint MinDetectableFaceCoveragePercentage = 0;
49 |
50 | public static bool IsFaceBigEnoughForDetection(int faceHeight, int imageHeight)
51 | {
52 | if (imageHeight == 0)
53 | {
54 | // sometimes we don't know the size of the image, so we assume the face is big enough
55 | return true;
56 | }
57 |
58 | double faceHeightPercentage = 100 * ((double)faceHeight / imageHeight);
59 |
60 | return faceHeightPercentage >= MinDetectableFaceCoveragePercentage;
61 | }
62 |
63 | public static Emotion FindFaceClosestToRegion(IEnumerable emotion, FaceRectangle region)
64 | {
65 | return emotion?.Where(e => CoreUtil.AreFacesPotentiallyTheSame(e.FaceRectangle, region))
66 | .OrderBy(e => Math.Abs(region.Left - e.FaceRectangle.Left) + Math.Abs(region.Top - e.FaceRectangle.Top)).FirstOrDefault();
67 | }
68 |
69 | public static bool AreFacesPotentiallyTheSame(Rectangle face1, FaceRectangle face2)
70 | {
71 | return AreFacesPotentiallyTheSame((int)face1.Left, (int)face1.Top, (int)face1.Width, (int)face1.Height, face2.Left, face2.Top, face2.Width, face2.Height);
72 | }
73 |
74 | public static bool AreFacesPotentiallyTheSame(int face1X, int face1Y, int face1Width, int face1Height,
75 | int face2X, int face2Y, int face2Width, int face2Height)
76 | {
77 | double distanceThresholdFactor = 1;
78 | double sizeThresholdFactor = 0.5;
79 |
80 | // See if faces are close enough from each other to be considered the "same"
81 | if (Math.Abs(face1X - face2X) <= face1Width * distanceThresholdFactor &&
82 | Math.Abs(face1Y - face2Y) <= face1Height * distanceThresholdFactor)
83 | {
84 | // See if faces are shaped similarly enough to be considered the "same"
85 | if (Math.Abs(face1Width - face2Width) <= face1Width * sizeThresholdFactor &&
86 | Math.Abs(face1Height - face2Height) <= face1Height * sizeThresholdFactor)
87 | {
88 | return true;
89 | }
90 | }
91 |
92 | return false;
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/dxcafe.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dxcafe", "dxcafe\dxcafe.csproj", "{98D40BAC-E627-4402-8835-8B2B20B6BA3B}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceHelpers", "ServiceHelpers\ServiceHelpers.csproj", "{5D9320AF-A9E4-48E3-89BC-9F7F0954B298}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VideoFrameAnalyzer", "VideoFrameAnalyzer\VideoFrameAnalyzer.csproj", "{BEC7DA78-C953-4A72-924F-2749D1F9F18B}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0C2579C4-B143-402A-83B1-590F61AA2F03}"
13 | ProjectSection(SolutionItems) = preProject
14 | readme.md = readme.md
15 | EndProjectSection
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Debug|ARM = Debug|ARM
21 | Debug|x64 = Debug|x64
22 | Debug|x86 = Debug|x86
23 | Release|Any CPU = Release|Any CPU
24 | Release|ARM = Release|ARM
25 | Release|x64 = Release|x64
26 | Release|x86 = Release|x86
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|ARM.ActiveCfg = Debug|Any CPU
32 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|ARM.Build.0 = Debug|Any CPU
33 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|x64.ActiveCfg = Debug|Any CPU
34 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|x64.Build.0 = Debug|Any CPU
35 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|x86.ActiveCfg = Debug|Any CPU
36 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Debug|x86.Build.0 = Debug|Any CPU
37 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
38 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|Any CPU.Build.0 = Release|Any CPU
39 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|ARM.ActiveCfg = Release|Any CPU
40 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|ARM.Build.0 = Release|Any CPU
41 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|x64.ActiveCfg = Release|Any CPU
42 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|x64.Build.0 = Release|Any CPU
43 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|x86.ActiveCfg = Release|Any CPU
44 | {98D40BAC-E627-4402-8835-8B2B20B6BA3B}.Release|x86.Build.0 = Release|Any CPU
45 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|ARM.ActiveCfg = Debug|Any CPU
48 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|ARM.Build.0 = Debug|Any CPU
49 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|x64.ActiveCfg = Debug|Any CPU
50 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|x64.Build.0 = Debug|Any CPU
51 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|x86.ActiveCfg = Debug|Any CPU
52 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Debug|x86.Build.0 = Debug|Any CPU
53 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|Any CPU.ActiveCfg = Release|Any CPU
54 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|Any CPU.Build.0 = Release|Any CPU
55 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|ARM.ActiveCfg = Release|Any CPU
56 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|ARM.Build.0 = Release|Any CPU
57 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|x64.ActiveCfg = Release|Any CPU
58 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|x64.Build.0 = Release|Any CPU
59 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|x86.ActiveCfg = Release|Any CPU
60 | {5D9320AF-A9E4-48E3-89BC-9F7F0954B298}.Release|x86.Build.0 = Release|Any CPU
61 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
62 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|Any CPU.Build.0 = Debug|Any CPU
63 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|ARM.ActiveCfg = Debug|Any CPU
64 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|ARM.Build.0 = Debug|Any CPU
65 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|x64.ActiveCfg = Debug|Any CPU
66 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|x64.Build.0 = Debug|Any CPU
67 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|x86.ActiveCfg = Debug|Any CPU
68 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Debug|x86.Build.0 = Debug|Any CPU
69 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|Any CPU.ActiveCfg = Release|Any CPU
70 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|Any CPU.Build.0 = Release|Any CPU
71 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|ARM.ActiveCfg = Release|Any CPU
72 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|ARM.Build.0 = Release|Any CPU
73 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|x64.ActiveCfg = Release|Any CPU
74 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|x64.Build.0 = Release|Any CPU
75 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|x86.ActiveCfg = Release|Any CPU
76 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}.Release|x86.Build.0 = Release|Any CPU
77 | EndGlobalSection
78 | GlobalSection(SolutionProperties) = preSolution
79 | HideSolutionNode = FALSE
80 | EndGlobalSection
81 | EndGlobal
82 |
--------------------------------------------------------------------------------
/VideoFrameAnalyzer/VideoFrameAnalyzer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {BEC7DA78-C953-4A72-924F-2749D1F9F18B}
9 | Library
10 | Properties
11 | VideoFrameAnalyzer
12 | VideoFrameAnalyzer
13 | v4.5.2
14 | 512
15 |
16 |
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
38 | True
39 |
40 |
41 | ..\packages\OpenCvSharp3-AnyCPU.3.1.0.20160622\lib\net45\OpenCvSharp.dll
42 | True
43 |
44 |
45 | ..\packages\OpenCvSharp3-AnyCPU.3.1.0.20160622\lib\net45\OpenCvSharp.Blob.dll
46 | True
47 |
48 |
49 | ..\packages\OpenCvSharp3-AnyCPU.3.1.0.20160622\lib\net45\OpenCvSharp.Extensions.dll
50 | True
51 |
52 |
53 | ..\packages\OpenCvSharp3-AnyCPU.3.1.0.20160622\lib\net45\OpenCvSharp.UserInterface.dll
54 | True
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
82 |
83 |
84 |
85 |
92 |
--------------------------------------------------------------------------------
/dxcafe/ScoredMenu.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json.Linq;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net.Http;
6 | using System.Net.Http.Headers;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace dxcafe
11 | {
12 | public class ScoredMenu
13 | {
14 | public ScoredMenu(double americano, double cafeRatte, double cafuChinno, double espresso, string topScoredMenu)
15 | {
16 | Americano = americano;
17 | CafeRatte = cafeRatte;
18 | CafuChino = cafuChinno;
19 | Espresso = espresso;
20 | TopScoredMenu = topScoredMenu;
21 | }
22 |
23 | public SortedDictionary GetSortedMenuList()
24 | {
25 |
26 | SortedDictionary sortedMenuList = new SortedDictionary();
27 | sortedMenuList.Add("Americano", Americano);
28 | sortedMenuList.Add("Cafe Latte", CafeRatte);
29 | sortedMenuList.Add("Cappucino", CafuChino);
30 | sortedMenuList.Add("Espresso", Espresso);
31 | return sortedMenuList;
32 | }
33 |
34 | public static ScoredMenu Empty
35 | {
36 | get
37 | {
38 | return new ScoredMenu(0, 0, 0, 0, "unknown");
39 | }
40 | }
41 |
42 | public double Americano { get; private set; }
43 | public double CafeRatte { get; private set; }
44 | public double CafuChino { get; private set; }
45 | public double Espresso { get; private set; }
46 |
47 | public string TopScoredMenu { get; private set; }
48 | }
49 | public enum Gender
50 | {
51 | Male,
52 | Femail
53 | }
54 | public static class MenuRecommender
55 | {
56 | public static async Task GetTopScoredMenu(string name, int age, Gender gender)
57 | {
58 | ScoredMenu menuScore = ScoredMenu.Empty;
59 |
60 | var scoreRequest = new
61 | {
62 | Inputs = new Dictionary>>() {
63 | {
64 | "input1",
65 | new List>(){new Dictionary(){
66 | {
67 | "name", name
68 | },
69 | {
70 | "age", age.ToString()
71 | },
72 | {
73 | "date", ""
74 | },
75 | {
76 | "gender", gender == Gender.Male ? "M" : "F"
77 | },
78 | {
79 | "prodcts", ""
80 | },
81 | }
82 | }
83 | },
84 | },
85 | GlobalParameters = new Dictionary()
86 | {
87 | }
88 | };
89 |
90 | using (var client = new System.Net.Http.HttpClient())
91 | {
92 | const string apiKey = "6EwIb5Om7prnsvyGpIXjsNnBzryfC5/tBcVEK/K+gxAtq9rF6Nt182fG9V6IW/Kn2iaxACcJGk0jmaDGh2cc7g=="; // Replace this with the API key for the web service
93 | client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
94 | client.BaseAddress = new Uri("https://japaneast.services.azureml.net/subscriptions/123d6582561440979417b9712cc9255b/services/866a9f6da9374e799256415921ff6656/execute?api-version=2.0&format=swagger");
95 | // WARNING: The 'await' statement below can result in a deadlock
96 | // if you are calling this code from the UI thread of an ASP.Net application.
97 | // One way to address this would be to call ConfigureAwait(false)
98 | // so that the execution does not attempt to resume on the original context.
99 | // For instance, replace code such as:
100 | // result = await DoSomeTask()
101 | // with the following:
102 | // result = await DoSomeTask().ConfigureAwait(false)
103 |
104 | HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest);
105 |
106 | if (response.IsSuccessStatusCode)
107 | {
108 | string result = await response.Content.ReadAsStringAsync();
109 | JObject o = JObject.Parse(result);
110 | var obj = o["Results"]["output1"][0];
111 |
112 | menuScore = new ScoredMenu(
113 | americano: obj["Scored Probabilities for Class \"Americano\""].Value(),
114 | cafeRatte: obj["Scored Probabilities for Class \"cafe ratte\""].Value(),
115 | cafuChinno: obj["Scored Probabilities for Class \"cafu chino\""].Value(),
116 | espresso: obj["Scored Probabilities for Class \"Espresso\""].Value(),
117 | topScoredMenu: obj["Scored Labels"].Value()
118 | );
119 | }
120 | }
121 |
122 | return menuScore;
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/ServiceHelpers/PhotoEvent.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using Microsoft.ProjectOxford.Emotion.Contract;
35 | using Newtonsoft.Json;
36 | using System;
37 | using System.Collections.Generic;
38 | using System.Linq;
39 | using System.Text;
40 | using System.Threading.Tasks;
41 |
42 | namespace ServiceHelpers
43 | {
44 | public class AgeGenderInfo
45 | {
46 | public double Age { get; set; }
47 | public string Gender { get; set; }
48 | }
49 |
50 | public class FaceInfo
51 | {
52 | public AgeGenderInfo AgeGenderInfo { get; set; }
53 | public Scores Emotion { get; set; }
54 | public string Name { get; set; }
55 | public string UniqueId { get; set; }
56 | }
57 |
58 | public class PhotoEvent
59 | {
60 | private static readonly JsonSerializerSettings jsonSettings = new JsonSerializerSettings()
61 | {
62 | // Stream Analytics will readjust all dates to UTC time so dont specify the timezone to preserve the localtime
63 | DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
64 | };
65 |
66 | public FaceInfo[] FaceInfo { get; set; }
67 | public DateTime LocalTime { get; set; }
68 |
69 | public string ToJson()
70 | {
71 | return JsonConvert.SerializeObject(this, jsonSettings);
72 | }
73 |
74 | public PhotoEvent(ImageAnalyzer capture)
75 | {
76 | LocalTime = DateTime.Now;
77 |
78 | List faceInfoList = new List();
79 |
80 | if (capture.DetectedFaces != null)
81 | {
82 | foreach (var detectedFace in capture.DetectedFaces)
83 | {
84 | FaceInfo faceInfo = new FaceInfo();
85 |
86 | // Check if we have age/gender for this face.
87 | if (detectedFace.FaceAttributes != null)
88 | {
89 | faceInfo.AgeGenderInfo = new AgeGenderInfo { Age = detectedFace.FaceAttributes.Age, Gender = detectedFace.FaceAttributes.Gender };
90 | }
91 |
92 | // Check if we identified this face. If so send the name along.
93 | if (capture.IdentifiedPersons != null)
94 | {
95 | var matchingPerson = capture.IdentifiedPersons.FirstOrDefault(p => p.FaceId == detectedFace.FaceId);
96 | if (matchingPerson != null)
97 | {
98 | faceInfo.Name = matchingPerson.Person.Name;
99 | }
100 | }
101 |
102 | // Check if we have emotion for this face. If so send it along.
103 | if (capture.DetectedEmotion != null)
104 | {
105 | Emotion matchingEmotion = CoreUtil.FindFaceClosestToRegion(capture.DetectedEmotion, detectedFace.FaceRectangle);
106 | if (matchingEmotion != null)
107 | {
108 | faceInfo.Emotion = matchingEmotion.Scores;
109 | }
110 | }
111 |
112 | // Check if we have an unique Id for this face. If so send it along.
113 | if (capture.SimilarFaceMatches != null)
114 | {
115 | var matchingPerson = capture.SimilarFaceMatches.FirstOrDefault(p => p.Face.FaceId == detectedFace.FaceId);
116 | if (matchingPerson != null)
117 | {
118 | faceInfo.UniqueId = matchingPerson.SimilarPersistedFace.PersistedFaceId.ToString("N").Substring(0, 4);
119 | }
120 | }
121 |
122 | faceInfoList.Add(faceInfo);
123 | }
124 | }
125 | else if (capture.DetectedEmotion != null)
126 | {
127 | // If we are here we only have emotion. No age/gender or id.
128 | faceInfoList.AddRange(capture.DetectedEmotion.Select(emotion => new FaceInfo { Emotion = emotion.Scores }));
129 | }
130 |
131 | this.FaceInfo = faceInfoList.ToArray();
132 | }
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/dxcafe/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ServiceHelpers/EmotionServiceHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft. All rights reserved.
3 | // Licensed under the MIT license.
4 | //
5 | // Microsoft Cognitive Services: http://www.microsoft.com/cognitive
6 | //
7 | // Microsoft Cognitive Services Github:
8 | // https://github.com/Microsoft/Cognitive
9 | //
10 | // Copyright (c) Microsoft Corporation
11 | // All rights reserved.
12 | //
13 | // MIT License:
14 | // Permission is hereby granted, free of charge, to any person obtaining
15 | // a copy of this software and associated documentation files (the
16 | // "Software"), to deal in the Software without restriction, including
17 | // without limitation the rights to use, copy, modify, merge, publish,
18 | // distribute, sublicense, and/or sell copies of the Software, and to
19 | // permit persons to whom the Software is furnished to do so, subject to
20 | // the following conditions:
21 | //
22 | // The above copyright notice and this permission notice shall be
23 | // included in all copies or substantial portions of the Software.
24 | //
25 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 | //
33 |
34 | using Microsoft.ProjectOxford.Common;
35 | using Microsoft.ProjectOxford.Emotion;
36 | using Microsoft.ProjectOxford.Emotion.Contract;
37 | using System;
38 | using System.Collections.Generic;
39 | using System.IO;
40 | using System.Net.Http;
41 | using System.Threading.Tasks;
42 |
43 | namespace ServiceHelpers
44 | {
45 | public class EmotionData
46 | {
47 | public string EmotionName { get; set; }
48 | public float EmotionScore { get; set; }
49 | }
50 |
51 | public static class EmotionServiceHelper
52 | {
53 | public static int RetryCountOnQuotaLimitError = 6;
54 | public static int RetryDelayOnQuotaLimitError = 500;
55 |
56 | private static EmotionServiceClient emotionClient { get; set; }
57 |
58 | static EmotionServiceHelper()
59 | {
60 | InitializeEmotionService();
61 | }
62 |
63 | public static Action Throttled;
64 |
65 | private static string apiKey;
66 | public static string ApiKey
67 | {
68 | get { return apiKey; }
69 | set
70 | {
71 | var changed = apiKey != value;
72 | apiKey = value;
73 | if (changed)
74 | {
75 | InitializeEmotionService();
76 | }
77 | }
78 | }
79 |
80 | private static void InitializeEmotionService()
81 | {
82 | emotionClient = new EmotionServiceClient(apiKey);
83 | }
84 |
85 | private static async Task RunTaskWithAutoRetryOnQuotaLimitExceededError(Func> action)
86 | {
87 | int retriesLeft = FaceServiceHelper.RetryCountOnQuotaLimitError;
88 | int delay = FaceServiceHelper.RetryDelayOnQuotaLimitError;
89 |
90 | TResponse response = default(TResponse);
91 |
92 | while (true)
93 | {
94 | try
95 | {
96 | response = await action();
97 | break;
98 | }
99 | catch (ClientException exception) when (exception.HttpStatus == (System.Net.HttpStatusCode)429 && retriesLeft > 0)
100 | {
101 | ErrorTrackingHelper.TrackException(exception, "Emotion API throttling error");
102 | if (retriesLeft == 1 && Throttled != null)
103 | {
104 | Throttled();
105 | }
106 |
107 | await Task.Delay(delay);
108 | retriesLeft--;
109 | delay *= 2;
110 | continue;
111 | }
112 | }
113 |
114 | return response;
115 | }
116 |
117 | private static async Task RunTaskWithAutoRetryOnQuotaLimitExceededError(Func action)
118 | {
119 | await RunTaskWithAutoRetryOnQuotaLimitExceededError