Skip to content

Commit 1cad71e

Browse files
authored
Merge pull request #141 from watson-developer-cloud/hotfix-hackathon
Hotfix hackathon
2 parents 675e369 + 5db3118 commit 1cad71e

File tree

4 files changed

+32
-65
lines changed

4 files changed

+32
-65
lines changed

Examples/ServiceExamples/Scripts/ExampleVisualRecognition.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
public class ExampleVisualRecognition : MonoBehaviour
2626
{
2727
private VisualRecognition m_VisualRecognition = new VisualRecognition();
28-
private string m_classifierName = "Apples_OptionalParams";
29-
private string m_classifierID = "ApplesClassifierNameWithSpaces_73100404";
30-
private string m_classifierToDelete = "unitytestclassifier2b_37849361";
28+
private string m_classifierName = "unity-test-classifier-example";
29+
private string m_classifierID = "unitytestclassifierexample_487365485";
30+
private string m_classifierToDelete = "unitytestclassifierexample_263072401";
3131
private string m_imageURL = "https://upload.wikimedia.org/wikipedia/commons/e/e9/Official_portrait_of_Barack_Obama.jpg";
3232
private string m_imageTextURL = "http://i.stack.imgur.com/ZS6nH.png";
3333

@@ -65,37 +65,37 @@ void Start()
6565

6666
//// Classify get
6767
//Log.Debug("ExampleVisualRecognition", "Attempting to get classify via URL");
68-
//if (!m_VisualRecognition.Classify(m_imageURL, OnClassify))
68+
//if (!m_VisualRecognition.Classify(OnClassify, m_imageURL))
6969
// Log.Debug("ExampleVisualRecognition", "Classify image failed!");
7070

7171
//// Classify post image
72-
//Log.Debug("ExampleVisualRecognition", "Attempting to classify via image on file system");
73-
//string imagesPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/obama.jpg";
74-
//string[] owners = { "IBM", "me" };
75-
//string[] classifierIDs = { "default" };
76-
//if (!m_VisualRecognition.Classify(OnClassify, imagesPath, owners, classifierIDs, 0.5f))
77-
// Log.Debug("ExampleVisualRecognition", "Classify image failed!");
72+
Log.Debug("ExampleVisualRecognition", "Attempting to classify via image on file system");
73+
string imagesPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/giraffe_to_classify.jpg";
74+
string[] owners = { "IBM", "me" };
75+
string[] classifierIDs = { "default", m_classifierID };
76+
if (!m_VisualRecognition.Classify(imagesPath, OnClassify, owners, classifierIDs, 0.5f))
77+
Log.Debug("ExampleVisualRecognition", "Classify image failed!");
7878

7979
//// Detect faces get
8080
//Log.Debug("ExampleVisualRecognition", "Attempting to detect faces via URL");
81-
//if (!m_VisualRecognition.DetectFaces(m_imageURL, OnDetectFaces))
81+
//if (!m_VisualRecognition.DetectFaces(OnDetectFaces, m_imageURL))
8282
// Log.Debug("ExampleVisualRecogntiion", "Detect faces failed!");
8383

8484
//// Detect faces post image
8585
//Log.Debug("ExampleVisualRecognition", "Attempting to detect faces via image");
8686
//string faceExamplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/obama.jpg";
87-
//if (!m_VisualRecognition.DetectFaces(OnDetectFaces, faceExamplePath))
87+
//if (!m_VisualRecognition.DetectFaces(faceExamplePath, OnDetectFaces))
8888
// Log.Debug("ExampleVisualRecognition", "Detect faces failed!");
8989

9090
//// Recognize text get
9191
//Log.Debug("ExampleVisualRecognition", "Attempting to recognizeText via URL");
92-
//if (!m_VisualRecognition.RecognizeText(m_imageTextURL, OnRecognizeText))
92+
//if (!m_VisualRecognition.RecognizeText(OnRecognizeText, m_imageTextURL))
9393
// Log.Debug("ExampleVisualRecognition", "Recognize text failed!");
9494

9595
//// Recognize text post image
9696
//Log.Debug("ExampleVisualRecognition", "Attempting to recognizeText via image");
9797
//string textExamplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/from_platos_apology.png";
98-
//if (!m_VisualRecognition.RecognizeText(OnRecognizeText, textExamplePath))
98+
//if (!m_VisualRecognition.RecognizeText(textExamplePath, OnRecognizeText))
9999
// Log.Debug("ExampleVisualRecognition", "Recognize text failed!");
100100
}
101101

@@ -170,11 +170,14 @@ private void OnClassify(ClassifyTopLevelMultiple classify, string data)
170170
foreach (ClassifyTopLevelSingle image in classify.images)
171171
{
172172
Log.Debug("ExampleVisualRecognition", "\tsource_url: " + image.source_url + ", resolved_url: " + image.resolved_url);
173-
foreach (ClassifyPerClassifier classifier in image.classifiers)
173+
if (image.classifiers != null && image.classifiers.Length > 0)
174174
{
175-
Log.Debug("ExampleVisualRecognition", "\t\tclassifier_id: " + classifier.classifier_id + ", name: " + classifier.name);
176-
foreach (ClassResult classResult in classifier.classes)
177-
Log.Debug("ExampleVisualRecognition", "\t\t\tclass: " + classResult.m_class + ", score: " + classResult.score + ", type_hierarchy: " + classResult.type_hierarchy);
175+
foreach (ClassifyPerClassifier classifier in image.classifiers)
176+
{
177+
Log.Debug("ExampleVisualRecognition", "\t\tclassifier_id: " + classifier.classifier_id + ", name: " + classifier.name);
178+
foreach (ClassResult classResult in classifier.classes)
179+
Log.Debug("ExampleVisualRecognition", "\t\t\tclass: " + classResult.m_class + ", score: " + classResult.score + ", type_hierarchy: " + classResult.type_hierarchy);
180+
}
178181
}
179182
}
180183
}

Examples/ServiceExamples/ServiceExamples.unity

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RenderSettings:
3737
m_ReflectionIntensity: 1
3838
m_CustomReflection: {fileID: 0}
3939
m_Sun: {fileID: 0}
40-
m_IndirectSpecularColor: {r: 0.3735644, g: 0.38112032, b: 0.35887682, a: 1}
40+
m_IndirectSpecularColor: {r: 0.3735645, g: 0.38112062, b: 0.35887584, a: 1}
4141
--- !u!157 &3
4242
LightmapSettings:
4343
m_ObjectHideFlags: 0
@@ -593,7 +593,7 @@ GameObject:
593593
m_Icon: {fileID: 0}
594594
m_NavMeshLayer: 0
595595
m_StaticEditorFlags: 0
596-
m_IsActive: 0
596+
m_IsActive: 1
597597
--- !u!114 &1713392458
598598
MonoBehaviour:
599599
m_ObjectHideFlags: 0
@@ -633,7 +633,7 @@ GameObject:
633633
m_Icon: {fileID: 0}
634634
m_NavMeshLayer: 0
635635
m_StaticEditorFlags: 0
636-
m_IsActive: 1
636+
m_IsActive: 0
637637
--- !u!114 &1740459832
638638
MonoBehaviour:
639639
m_ObjectHideFlags: 0
@@ -658,47 +658,6 @@ Transform:
658658
m_Children: []
659659
m_Father: {fileID: 0}
660660
m_RootOrder: 1
661-
--- !u!1 &1979050314
662-
GameObject:
663-
m_ObjectHideFlags: 0
664-
m_PrefabParentObject: {fileID: 0}
665-
m_PrefabInternal: {fileID: 0}
666-
serializedVersion: 4
667-
m_Component:
668-
- 4: {fileID: 1979050316}
669-
- 114: {fileID: 1979050315}
670-
m_Layer: 0
671-
m_Name: ExampleDialog
672-
m_TagString: Untagged
673-
m_Icon: {fileID: 0}
674-
m_NavMeshLayer: 0
675-
m_StaticEditorFlags: 0
676-
m_IsActive: 0
677-
--- !u!114 &1979050315
678-
MonoBehaviour:
679-
m_ObjectHideFlags: 0
680-
m_PrefabParentObject: {fileID: 0}
681-
m_PrefabInternal: {fileID: 0}
682-
m_GameObject: {fileID: 1979050314}
683-
m_Enabled: 1
684-
m_EditorHideFlags: 0
685-
m_Script: {fileID: 11500000, guid: e8b52562568714a48a89536c62fb978e, type: 3}
686-
m_Name:
687-
m_EditorClassIdentifier:
688-
m_DialogID: 61343031353936302d333963322d346436622d393537312d333863373461656366666664
689-
--- !u!4 &1979050316
690-
Transform:
691-
m_ObjectHideFlags: 0
692-
m_PrefabParentObject: {fileID: 0}
693-
m_PrefabInternal: {fileID: 0}
694-
m_GameObject: {fileID: 1979050314}
695-
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
696-
m_LocalPosition: {x: 0, y: 1, z: -10}
697-
m_LocalScale: {x: 1, y: 1, z: 1}
698-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
699-
m_Children: []
700-
m_Father: {fileID: 0}
701-
m_RootOrder: 2
702661
--- !u!1 &2004886371
703662
GameObject:
704663
m_ObjectHideFlags: 0

Scripts/Editor/ConfigEditor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ private class ServiceSetup
5252
URL ="https://console.ng.bluemix.net/catalog/speech-to-text/", ServiceID="SpeechToTextV1" },
5353
new ServiceSetup() { ServiceName = "Text To Speech", ServiceAPI = "text-to-speech/api",
5454
URL ="https://console.ng.bluemix.net/catalog/text-to-speech/", ServiceID="TextToSpeechV1" },
55-
new ServiceSetup() { ServiceName = "Dialog", ServiceAPI = "dialog/api",
56-
URL ="https://console.ng.bluemix.net/catalog/dialog/", ServiceID="DialogV1" },
5755
new ServiceSetup() { ServiceName = "Language Translation (to be deprecated)", ServiceAPI = "language-translation/api",
5856
URL ="https://console.ng.bluemix.net/catalog/services/language-translation/", ServiceID="LanguageTranslationV1" },
5957
//new ServiceSetup() { ServiceName = "Language Translator", ServiceAPI = "language-translator/api",

Scripts/Services/VisualRecognition/VisualRecognition.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,14 @@ public class VisualRecognition : IWatsonService
224224
req.Headers["Content-Type"] = "application/x-www-form-urlencoded";
225225
req.Headers["Accept-Language"] = acceptLanguage;
226226

227-
if(imageData != null)
227+
if (owners != default(string[]))
228+
req.Parameters["owners"] = string.Join(",", owners);
229+
if (classifierIDs != default(string[]))
230+
req.Parameters["classifier_ids"] = string.Join(",", classifierIDs);
231+
if (threshold != default(float))
232+
req.Parameters["threshold"] = threshold;
233+
234+
if (imageData != null)
228235
req.Send = imageData;
229236

230237
return connector.Send(req);

0 commit comments

Comments
 (0)