Skip to content

Commit a39dbbd

Browse files
committed
reorganize sections so that snippet method stays together
1 parent b2f8a69 commit a39dbbd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

articles/cognitive-services/Face/QuickStarts/csharp-sdk.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ The following code prints the match details to the console:
171171

172172
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_find_similar_print)]
173173

174-
## Create and train a person group
174+
## Identify a face
175+
176+
The Identify operation takes an image of a person (or multiple people) and looks to find the identity of each face in the image. It compares each detected face to a **PersonGroup**, a database of different **Person** objects whose facial features are known. In order to do the Identify operation, you first need to create and train a **PersonGroup**
177+
178+
### Create and train a person group
175179

176180
The following code creates a **PersonGroup** with six different **Person** objects. It associates each **Person** with a set of example images, and then it trains to recognize each person by their facial characteristics. **Person** and **PersonGroup** objects are used in the Verify, Identify, and Group operations.
177181

@@ -183,35 +187,28 @@ The code later in this section will specify a recognition model to extract data
183187

184188
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_detect_models)]
185189

186-
### Create PersonGroup
190+
#### Create PersonGroup
187191

188192
Declare a string variable at the root of your class to represent the ID of the **PersonGroup** you'll create.
189193

190194
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_persongroup_declare)]
191195

192-
In a new method, add the following code. This code associates the names of persons with their example images.
196+
In a new method, add the following code. This method will carry out the Identify operation. The first block of code associates the names of persons with their example images.
193197

194198
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_persongroup_files)]
195199

196200
Next, add the following code to create a **Person** object for each person in the Dictionary and add the face data from the appropriate images. Each **Person** object is associated with the same **PersonGroup** through its unique ID string. Remember to pass the variables `client`, `url`, and `RECOGNITION_MODEL1` into this method.
197201

198202
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_persongroup_create)]
199203

200-
### Train PersonGroup
204+
#### Train PersonGroup
201205

202206
Once you've extracted face data from your images and sorted it into different **Person** objects, you must train the **PersonGroup** to identify the visual features associated with each of its **Person** objects. The following code calls the asynchronous **train** method and polls the results, printing the status to the console.
203207

204208
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_persongroup_train)]
205209

206210
This **Person** group and its associated **Person** objects are now ready to be used in the Verify, Identify, or Group operations.
207211

208-
## Identify a face
209-
210-
The Identify operation takes an image of a person (or multiple people) and looks to find the identity of each face in the image. It compares each detected face to a **PersonGroup**, a database of different **Person** objects whose facial features are known.
211-
212-
> [!IMPORTANT]
213-
> In order to run this example, you must first run the code in [Create and train a person group](#create-and-train-a-person-group). The variables used in that section—`client`, `url`, and `RECOGNITION_MODEL1`—must also be available here.
214-
215212
### Get a test image
216213

217214
Notice that the code for [Create and train a person group](#create-and-train-a-person-group) defines a variable `sourceImageFileName`. This variable corresponds to the source image—the image that contains people to identify.
@@ -222,7 +219,7 @@ The following code takes the source image and creates a list of all the faces de
222219

223220
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_identify_sources)]
224221

225-
The next code snippet calls the Identify operation and prints the results to the console. Here, the service attempts to match each face from the source image to a **Person** in the given **PersonGroup**.
222+
The next code snippet calls the **IdentifyAsync** operation and prints the results to the console. Here, the service attempts to match each face from the source image to a **Person** in the given **PersonGroup**. This closes out your Identify method.
226223

227224
[!code-csharp[](~/cognitive-services-dotnet-sdk-samples/documentation-samples/quickstarts/Face/Program.cs?name=snippet_identify)]
228225

0 commit comments

Comments
 (0)