【发布时间】:2019-10-05 04:36:12
【问题描述】:
我需要开发一个将 Angular 与 Azure 人脸 API 结合使用的人脸识别系统。但是,Azure Face API 的文档是用 C# 编写的。谁能帮我把它改写成打字稿?
This 是 Azure 人脸 API 中人脸识别的准则
https://westus.api.cognitive.microsoft.com/face/v1.0/detect[?returnFaceId][&returnFaceLandmarks][&returnFaceAttributes]
&subscription-key=<Subscription key>
faceServiceClient = new FaceServiceClient("<Subscription Key>");
// Create an empty PersonGroup
string personGroupId = "myfriends";
await faceServiceClient.CreatePersonGroupAsync(personGroupId, "My Friends");
// Define Anna
CreatePersonResult friend1 = await faceServiceClient.CreatePersonAsync(
// Id of the PersonGroup that the person belonged to
personGroupId,
// Name of the person
"Anna"
);
// Directory contains image files of Anna
const string friend1ImageDir = @"D:\Pictures\MyFriends\Anna\";
foreach (string imagePath in Directory.GetFiles(friend1ImageDir, "*.jpg"))
{
using (Stream s = File.OpenRead(imagePath))
{
// Detect faces in the image and add to Anna
await faceServiceClient.AddPersonFaceAsync(
personGroupId, friend1.PersonId, s);
}
}
【问题讨论】:
-
添加示例代码和代码仓库路径,因为您是新的 SO 成员,但请确保检查 stackoverflow.blog/2010/10/04/asking-better-questions
标签: c# angular typescript azure face-recognition