Skip to content

Feature/vision #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 77 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
bdbce2c
Initial code comit from the February 2018 MR+AI hackfest
ActiveNick Feb 21, 2018
c24dd50
Added README and diagram
ActiveNick Feb 21, 2018
00dbaef
Adding ARM Template to create Mobile App with code deployment from gi…
dacoppet Mar 16, 2018
8ab6e00
Fix template url for Azure Deploy Button and Code deploy
dacoppet Mar 16, 2018
b77c382
Fix Dependencies issues and update Read me with badge
dacoppet Mar 26, 2018
83e24aa
Fixing Kudu - Deploy
dacoppet Mar 27, 2018
8f0630d
Cleaning and refactoring Server
dacoppet Apr 19, 2018
daff41f
Backup - adding mobile table bindidng in frunction
dacoppet Apr 20, 2018
4d1d5fc
Refactoring
dacoppet Apr 20, 2018
133ac17
Updating arm template - adding luis, funtions and storage
dacoppet Apr 20, 2018
ec9bb50
Fixing ARM Template :
dacoppet Apr 26, 2018
c8303a1
Add default value to improve UX
dacoppet Apr 26, 2018
054e4fa
Adding default settings
dacoppet Apr 26, 2018
1a7aa81
Merge pull request #5 from dacoppet/feature/LUIScache
ActiveNick May 1, 2018
c5e0275
LUIS cache instructions & ARM template tweak.
ActiveNick May 2, 2018
9ecfd58
Disabled auto-deploy of App Service project from ARM template.
ActiveNick Jun 7, 2018
87c5856
LUIS Cache folder reorg
ActiveNick Jun 7, 2018
0895aa4
LUIS Caching folder fix
ActiveNick Jun 7, 2018
b53f4c4
ARM template fix for new folder structure
ActiveNick Jun 7, 2018
8ff8541
Another ARM fix
ActiveNick Jun 7, 2018
56182b4
Path update in README
ActiveNick Jun 7, 2018
aa302d7
Updated instructions, added solution for client.
ActiveNick Jun 7, 2018
52c6282
Merge pull request #11 from Microsoft/develop
jbienzms Jun 11, 2018
2ade853
Fixing ARM Template :
dacoppet Jun 14, 2018
52706f5
Merge pull request #12 from dacoppet/feature/LUIScache
ActiveNick Jun 14, 2018
77d1823
Tweaked LUIS Cache Service test client UI.
ActiveNick Jun 14, 2018
96ef3fd
Updated .NET Core for UWP dependency version
ActiveNick Jun 14, 2018
65c59ae
Fixed luis endpoing to https in ARM template
ActiveNick Jun 14, 2018
4e35c67
Fix https and luis api url
dacoppet Jun 15, 2018
e0b0ca0
Fixing app settings
dacoppet Jun 15, 2018
ba8afe6
merge
dacoppet Jun 15, 2018
42a9439
Merge pull request #14 from dacoppet/feature/LUIScache
ActiveNick Jun 15, 2018
da688c2
Finalized README instructions + fixed a bug for LUIS deployments not …
ActiveNick Jun 18, 2018
05f44aa
Fixing .gitignore conflicts
ActiveNick Jun 18, 2018
0a2fe1e
Merge branch 'master' into feature/LUIScache
ActiveNick Jun 18, 2018
adee9cf
Merge pull request #15 from Microsoft/feature/LUIScache
ActiveNick Jun 18, 2018
95e9e7d
Switched LUIS cachine service repo source to master in ARM template.
ActiveNick Jun 18, 2018
0f0d8b6
Added Unity Text-to-Speech sample.
ActiveNick Jun 19, 2018
a3d0d94
Merge pull request #16 from Microsoft/feature/TextToSpeech
ActiveNick Jun 19, 2018
5168285
Update README.md
ActiveNick Jun 19, 2018
da4f9e1
Added Unity sample with Azure Storage
ActiveNick Jun 21, 2018
327dda4
Merge pull request #17 from Microsoft/feature/azurestorage
ActiveNick Jun 21, 2018
de5f10e
Update README.md
ActiveNick Jun 21, 2018
c59bed9
Added Vision Scripts
MichaelMilstead Aug 8, 2018
69c421f
Fixed predictionResult problem
MichaelMilstead Aug 8, 2018
03d772e
Added Plugin Folder
MichaelMilstead Aug 8, 2018
fed469d
Added small guide
MichaelMilstead Aug 8, 2018
5fc9c9d
Removed refs to sampleprogram in Detector class
MichaelMilstead Aug 9, 2018
7a63d05
fixed readme
MichaelMilstead Aug 9, 2018
11b6f17
Lib change and readme update
MichaelMilstead Aug 10, 2018
02d2e8a
Detector updated to throw exception on offline try
MichaelMilstead Aug 10, 2018
c3e30e8
Test
MichaelMilstead Aug 10, 2018
0e34206
Switched curly braces format
MichaelMilstead Aug 10, 2018
0ad87bd
Made readme markdown
MichaelMilstead Aug 13, 2018
753b917
Added namespace
MichaelMilstead Aug 13, 2018
5777b11
Merged Detector/Options into VisionManager
MichaelMilstead Aug 13, 2018
4ef2501
Fixed PredictionResult threshold
MichaelMilstead Aug 13, 2018
f487a45
VisionManager update
MichaelMilstead Aug 13, 2018
7f3315b
Fixed README
MichaelMilstead Aug 14, 2018
b7a775c
Removed metafiles
MichaelMilstead Aug 14, 2018
6b8dbb4
Fixed vision scripts/added a prefab
MichaelMilstead Aug 29, 2018
66eef9c
Made packaging.bat file
MichaelMilstead Aug 29, 2018
15e510c
Started Readme
MichaelMilstead Aug 29, 2018
51f20ca
Adding updated visionScripts
MichaelMilstead Aug 30, 2018
24b5210
Fixed Secret Helper and VisionObject prefab
MichaelMilstead Aug 31, 2018
8ddf3f7
Treasure Hunt demo added
MichaelMilstead Aug 31, 2018
876929e
Added README
MichaelMilstead Aug 31, 2018
4bebc38
Added link to standalone demo
MichaelMilstead Aug 31, 2018
636b623
Save
MichaelMilstead Sep 1, 2018
a670f9a
fix textureReader
MichaelMilstead Sep 1, 2018
d029798
No more FindGameObject
MichaelMilstead Sep 2, 2018
82301e6
Took out my custom vision keys
MichaelMilstead Sep 2, 2018
113cca2
Slowed down demo
MichaelMilstead Sep 3, 2018
96cf80c
Removed Unneeded lib
MichaelMilstead Sep 4, 2018
c16ba49
Removed unneeded directory from plugins
MichaelMilstead Sep 4, 2018
fed7a06
Fixed missing script in prefab problem
MichaelMilstead Sep 4, 2018
9d5ab5f
Removed AndroidBuild from sample
MichaelMilstead Sep 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ FakesAssemblies/
*.opt
mixedreality-azure-samples.sln
mixedreality-azure-samples.csproj
mixedreality-azure-samples.Player.csproj
mixedreality-azure-samples.Player.csproj
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ This project is organized into 3 key areas:
Concise projects that demonstrate a capability quickly and don't have external dependencies. These samples can be downloaded independently and tested quickly with little or no server setup.

Samples:
- [Custom Vision with Windows ML in Hololens](https://github.com/meulta/mixedreality-azure-samples/tree/master/Standalone-Samples/WindowsML-CustomVision-Hololens)
- [Custom Vision with Windows ML in HoloLens](https://github.com/meulta/mixedreality-azure-samples/tree/master/Standalone-Samples/WindowsML-CustomVision-Hololens)
- [Unity with Custom Vision Treasure Hunt Demo for Hololens, Android, and iOS](https://github.com/Microsoft/mixedreality-azure-samples/tree/master/Standalone-Samples/VisionTreasureHunt)
- [Unity with Cognitive Services Text-to-Speech](https://github.com/Microsoft/mixedreality-azure-samples/tree/master/Standalone-Samples/Unity-Text-to-Speech)
- [Unity with Azure Storage](https://github.com/Microsoft/mixedreality-azure-samples/tree/master/Standalone-Samples/AzureStorageDemoUnity3D)


### Solutions (Coming soon)
### Solutions
Also demonstrate a capability but require additional setup. Solutions, for example, may require deploying an Azure workload like a bot, a function, or a database.


Solutions:
- [LUIS Caching Service](https://github.com/Microsoft/mixedreality-azure-samples/tree/master/Solutions/LUIS-CachingService): Reusable solution that showcases how to cache results from LUIS in Cognitive Services.

### Reference Architectures ###
Are a *set of capabilities* that have all been designed to work together. For example, Speech Recognition may be used on its own but it is also designed to work with Language Understanding.

**Modules**
- [LUIS for XR](Reference-Architecture/Client/MixedReality-Azure-Unity/Assets/MixedRealityAzure/LUIS) - A powerful Natural Language replacement for voice commands.
- [LUIS for XR](Reference-Architecture/Client/MixedReality-Azure-Unity/Assets/MixedRealityAzure/LUIS): A powerful Natural Language replacement for voice commands.


## Contributing
Expand Down

Large diffs are not rendered by default.

1,186 changes: 605 additions & 581 deletions Reference-Architecture/Client/MixedReality-Azure-Unity/Assembly-CSharp.csproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using Microsoft.Cognitive.LUIS;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_SourcePrefab: {fileID: 0}
m_RootGameObject: {fileID: 1033717228754310}
m_IsPrefabAsset: 1
--- !u!1 &1033717228754310
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4197923332607632}
- component: {fileID: 114818391866690084}
m_Layer: 0
m_Name: VisionObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4197923332607632
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1033717228754310}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114818391866690084
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1033717228754310}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 937c7d20bf0f1bb4f84585c327bd443e, type: 3}
m_Name:
m_EditorClassIdentifier:
useOffline: 0
useSDK: 0
useCustomVision: 1
predictionConfidenceThreshold: 0.5
customVisionURL:
customVisionPredictionKey:
customVisionProjectID:
customVisionTrainingKey:
visionURL:
visionKey:

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1>Computer Vision and Custom Vision for XR</h1>
<h3>Add image classification and object recognition to your AR application!</h3>

<h2>How To Use</h2>
(See the Vision Treasure Hunt demo in /Standalone-Samples for an example)

1: Add the Unity Package "MR-Vision-x.x.x" to your Unity project.
</br> You'll find that in this Github Repository under MixedReality-Azure-Unity/UnityPackages

2: Add the VisionObject prefab to your scene.
</br>That's under Assets/MixedRealityAzure/Vision after you've added the package.

3: In the inspector for your scene's VisionObject, set your project information for Custom Vision, Computer Vision, or both!

4: Get a reference to the VisionManager script component with something like:
</br>VisionManager visionManager = GetComponent<VisionManager>();

5: Get an image as a byte[] formatted as a .png, .jpg, .bmp, or any other format accepted by CustomVision/ComputerVision.
</br> There are examples of how to do this using Hololens, using ARKit on iOS, or using ARCore for Android, in the Standalone Sample ""

6: Send your image for prediction and get the result by calling:
</br>PredictionResult result = await visionManager.SendImageAsync(imageData); //imageData is the byte[] in this example

7: Do whatever you like with the PredictionResult.
</br>It contains a list of Predictions for the image, where each Prediction has a name, confidence, and bounding box information if available.

Now you have image classification in your app!

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//Class to store each prediction of a PredictionResult in a nice format
namespace Microsoft.MR.Vision
{
public class Prediction
{
public string name { get; set; }
public float confidence { get; set; }
public float[] boundingBoxInfo = null;// holds info about the bounding box, in fractions of the image (Left, Top, Width, Height)
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

//Class to hold all the information of the results of an image prediction, for later use:
namespace Microsoft.MR.Vision
{
public class PredictionResult
{
public string jsonResultsString { get; set; }
public List<Prediction> predictions;//list to hold all predictions for a given image
public int indexOfHighestConfidence;
public float minConfidence;

public PredictionResult(float confidenceThreshold)
{
predictions = new List<Prediction>();
minConfidence = confidenceThreshold;
}

//turns the json string into a list of distinct Prediction objects:
public void JsonStringToPredictionList()
{
if (jsonResultsString != null)
{
JObject obj = JsonConvert.DeserializeObject<JObject>(this.jsonResultsString);

//get the predicted classes into a JToken:
List<JProperty> subProperties = obj.Properties().ToList();
bool isUsingCustomVision = true;
JProperty property = null;
try
{
property = subProperties.Find(p => p.Name == "predictions");
if (property == null)
{
property = subProperties.Find(p => p.Name == "categories");
isUsingCustomVision = false;
}
}
catch (Exception ex)
{
Debug.Log(ex.ToString());
}

JToken resultJToken = property.Value;

//make sure there are some classes:
if (resultJToken.Count() == 0)
{
return;
}
//add the predictions to the prediction list:
//also keep track of which has highest confidence:
for (int i = 0; i < resultJToken.Count(); i++)
{
if (isUsingCustomVision)
{
Prediction thisPrediction = new Prediction();
thisPrediction.name = resultJToken[i].Value<string>("tagName");
thisPrediction.confidence = resultJToken[i].Value<float>("probability");
if (thisPrediction.confidence < minConfidence)
{
//skip this prediction:
continue;
}

if (resultJToken[i].Value<JToken>("boundingBox") != null)
{
SetupBoundingBox(thisPrediction, resultJToken[i].Value<JToken>("boundingBox"));
}
predictions.Add(thisPrediction);
if (thisPrediction.confidence > predictions[indexOfHighestConfidence].confidence)
{
indexOfHighestConfidence = predictions.Count - 1;//set this new prediction as highest confidence
}
}
else
{
//using Computer Vision format:
Prediction thisPrediction = new Prediction();
thisPrediction.name = resultJToken[i].Value<string>("name");
thisPrediction.confidence = resultJToken[i].Value<float>("score");
if (thisPrediction.confidence < minConfidence)
{
//skip this prediction:
continue;
}
predictions.Add(thisPrediction);
if (thisPrediction.confidence > predictions[indexOfHighestConfidence].confidence)
{
indexOfHighestConfidence = predictions.Count - 1;//set this new prediction as highest confidence
}
}
}
}
}

//set up the corner points of bounding boxes, so that they can be shown later:
public void SetupBoundingBox(Prediction thisPrediction, JToken boundingBoxToken)
{
//box values are the fraction of the image:
thisPrediction.boundingBoxInfo = new float[4];
thisPrediction.boundingBoxInfo[0] = boundingBoxToken.Value<float>("left");
thisPrediction.boundingBoxInfo[1] = boundingBoxToken.Value<float>("top");
thisPrediction.boundingBoxInfo[2] = boundingBoxToken.Value<float>("width");
thisPrediction.boundingBoxInfo[3] = boundingBoxToken.Value<float>("height");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading