private async void Analyzer() { // Use default parameter settings. this.analyzer = MLAnalyzerFactory.Instance.FaceAnalyzer; // Create an MLFrame by using the bitmap. Recommended image size: large than 320*320, less than 1920*1920. MLFrame frame = MLFrame.FromBitmap(this.mBitmap); // Call the AnalyseFrameAsync method to perform face detection System.Threading.Tasks.Task <IList <MLFace> > faceAnalyseTask = this.analyzer.AnalyseFrameAsync(frame); try { await faceAnalyseTask; if (faceAnalyseTask.IsCompleted && faceAnalyseTask.Result != null) { IList <MLFace> faces = faceAnalyseTask.Result; if (faces.Count > 0) { DisplaySuccess(faces.ElementAt(0)); } } else { DisplayFailure(); } } catch (Exception e) { //Operation failed. DisplayFailure(); } }
/// <summary> /// Create Face Analyzer /// </summary> private void CreateFaceAnalyzer() { // Create a face analyzer. You can create an analyzer using the provided customized face detection parameter // MLFaceAnalyzerSetting MLFaceAnalyzerSetting setting = new MLFaceAnalyzerSetting.Factory() .SetFeatureType(MLFaceAnalyzerSetting.TypeFeatures) .SetKeyPointType(MLFaceAnalyzerSetting.TypeKeypoints) .SetMinFaceProportion(0.2f) .AllowTracing() .Create(); this.analyzer = MLAnalyzerFactory.Instance.GetFaceAnalyzer(setting); this.analyzer.SetTransactor(new FaceAnalyzerTransactor(this.mOverlay)); }