1
+ // <snippet_using>
1
2
using Microsoft . Azure . CognitiveServices . ContentModerator ;
2
3
using Microsoft . Azure . CognitiveServices . ContentModerator . Models ;
3
4
using Newtonsoft . Json ;
4
5
using System ;
5
6
using System . Collections . Generic ;
6
7
using System . IO ;
7
8
using System . Threading ;
8
-
9
+ // </snippet_using>
9
10
10
11
namespace ImageModeration
11
12
{
12
13
class Program
13
14
{
14
15
static void Main ( string [ ] args )
15
16
{
17
+ // <snippet_main>
16
18
// Create an object to store the image moderation results.
17
19
List < EvaluationData > evaluationData = new List < EvaluationData > ( ) ;
18
20
@@ -43,14 +45,18 @@ static void Main(string[] args)
43
45
outputWriter . Flush ( ) ;
44
46
outputWriter . Close ( ) ;
45
47
}
48
+ // </snippet_main>
46
49
}
47
50
51
+ // <snippet_fields>
48
52
//The name of the file that contains the image URLs to evaluate.
49
53
private static string ImageUrlFile = "ImageFiles.txt" ;
50
54
51
55
///The name of the file to contain the output from the evaluation.
52
56
private static string OutputFile = "ModerationOutput.json" ;
57
+ // </snippet_fields>
53
58
59
+ // <snippet_evaluate>
54
60
// Evaluates an image using the Image Moderation APIs.
55
61
private static EvaluationData EvaluateImage (
56
62
ContentModeratorClient client , string imageUrl )
@@ -78,8 +84,10 @@ private static EvaluationData EvaluateImage(
78
84
79
85
return imageData ;
80
86
}
87
+ // </snippet_evaluate>
81
88
}
82
89
90
+ // <snippet_client>
83
91
// Wraps the creation and configuration of a Content Moderator client.
84
92
public static class Clients
85
93
{
@@ -103,7 +111,9 @@ public static ContentModeratorClient NewClient()
103
111
return client ;
104
112
}
105
113
}
114
+ // </snippet_client>
106
115
116
+ // <snippet_dataclass>
107
117
// Contains the image moderation results for an image,
108
118
// including text and face detection results.
109
119
public class EvaluationData
@@ -120,4 +130,5 @@ public class EvaluationData
120
130
// The face detection results;
121
131
public FoundFaces FaceDetection ;
122
132
}
133
+ // </snippet_dataclass>
123
134
}
0 commit comments