/// <summary> /// Create analyzer /// </summary> private void CreateAnalyzer() { // Create an MLFrame by using the bitmap. Bitmap originBitmap = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.hand); // Gets the targeted width / height, only portrait. int maxHeight = ((View)mPreviewView.Parent).Height; int targetWidth = ((View)mPreviewView.Parent).Width; // Determine how much to scale down the image. float scaleFactor = Math.Max( (float)originBitmap.Width / (float)targetWidth, (float)originBitmap.Height / (float)maxHeight); Bitmap resizedBitmap = Bitmap.CreateScaledBitmap( originBitmap, (int)(originBitmap.Width / scaleFactor), (int)(originBitmap.Height / scaleFactor), true); mlFrame = new MLFrame.Creator().SetBitmap(resizedBitmap).Create(); //Create analyzer setting. MLHandKeypointAnalyzerSetting setting = new MLHandKeypointAnalyzerSetting.Factory() .SetMaxHandResults(2) .SetSceneType(MLHandKeypointAnalyzerSetting.TypeAll) .Create(); //Obtain analyzer instance with custom configuration. this.mAnalyzer = MLHandKeypointAnalyzerFactory.Instance.GetHandKeypointAnalyzer(setting); }
/// <summary> /// Create Hand Keypoint analyzer /// with custom setting. /// </summary> private void CreateHandAnalyzer() { // Create a analyzer. You can create an analyzer using the provided customized handkeypoint detection parameter: MLHandKeypointAnalyzerSetting MLHandKeypointAnalyzerSetting setting = new MLHandKeypointAnalyzerSetting.Factory() .SetMaxHandResults(2) .SetSceneType(MLHandKeypointAnalyzerSetting.TypeAll) .Create(); mAnalyzer = MLHandKeypointAnalyzerFactory.Instance.GetHandKeypointAnalyzer(setting); mAnalyzer.SetTransactor(new HandAnalyzerTransactor(this, mOverlay)); }