【发布时间】:2018-02-28 22:28:18
【问题描述】:
我能够从实时网络摄像头获取面孔作为Windows.Media.FaceAnalysis DetectedFace 对象的列表。现在我想将这些人脸传递给 Microsoft Cognitive Services API 来检测人脸并获取人脸属性。我该怎么做?
IList<DetectedFace> faces = null;
// Create a VideoFrame object specifying the pixel format we want our capture image to be (NV12 bitmap in this case).
// GetPreviewFrame will convert the native webcam frame into this format.
const BitmapPixelFormat InputPixelFormat = BitmapPixelFormat.Nv12;
using (VideoFrame previewFrame = new VideoFrame(InputPixelFormat, (int)this.videoProperties.Width, (int)this.videoProperties.Height))
{
await this.mediaCapture.GetPreviewFrameAsync(previewFrame);
// The returned VideoFrame should be in the supported NV12 format but we need to verify this.
if (FaceDetector.IsBitmapPixelFormatSupported(previewFrame.SoftwareBitmap.BitmapPixelFormat))
{
faces = await this.faceDetector.DetectFacesAsync(previewFrame.SoftwareBitmap);
// Now pass this faces to Cognitive services API
// faceClient.DetectAsync
}
}
【问题讨论】:
标签: c# uwp microsoft-cognitive face-api azure-cognitive-services