Skip to content

Commit 629f182

Browse files
committed
update visual recognition parameters and add update check to example
1 parent ee49cde commit 629f182

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

examples/IBM.WatsonDeveloperCloud.VisualRecognition.v3.Example/VisualRecognitionServiceExample.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Collections.Generic;
2323
using System.Threading;
2424
using System.Threading.Tasks;
25+
using Newtonsoft.Json;
2526

2627
namespace IBM.WatsonDeveloperCloud.VisualRecognition.v3.Example
2728
{
@@ -62,6 +63,10 @@ public VisualRecognitionServiceExample(string apikey)
6263
IsClassifierReady(_createdClassifierId);
6364
autoEvent.WaitOne();
6465
UpdateClassifier();
66+
IsClassifierReady(_createdClassifierId);
67+
autoEvent.WaitOne();
68+
ClassifyWithClassifier();
69+
GetClassifiersVerbose();
6570
DeleteClassifier();
6671

6772
Console.WriteLine("\n\nOperation complete");
@@ -99,6 +104,18 @@ private void ClassifyPost()
99104
}
100105
}
101106

107+
private void ClassifyWithClassifier()
108+
{
109+
string[] classifierIDs = { _createdClassifierId };
110+
using (FileStream fs = File.OpenRead(_localGiraffeFilePath))
111+
{
112+
Console.WriteLine(string.Format("\nCalling Classify(\"{0}\")...", _localTurtleFilePath));
113+
var result = _visualRecognition.Classify((fs as Stream).ReadAllBytes(), Path.GetFileName(_localTurtleFilePath), "image/jpeg", classifierIDs: classifierIDs);
114+
115+
Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
116+
}
117+
}
118+
102119
private void DetectFacesGet()
103120
{
104121
Console.WriteLine(string.Format("\nCalling DetectFaces(\"{0}\")...", _faceUrl));

src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public ClassifyPost Classify(byte[] imageData = null, string imageDataName = nul
151151
{
152152
var parametersContent = new StringContent(parameters, Encoding.UTF8, HttpMediaType.TEXT_PLAIN);
153153
parametersContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
154-
formData.Add(parametersContent);
154+
formData.Add(parametersContent, "parameters");
155155
}
156156

157157
result = this.Client.PostAsync($"{ this.Endpoint}{PATH_CLASSIFY}")

0 commit comments

Comments
 (0)