public void TestFaceDetectFromBytesImage()
        {
            byte[] arrBytes = GetImageAsByteArray("imageTest/img1.jpg");

            using (FaceDetect faceDetect = new FaceDetect(LocationServerApiAzure.EastUS))
            {
                faceDetect.SuscriptionKey = "Api Key Azure Cognitive Services";
                ResponseFaceDetect responseFaceDetect = faceDetect.GetFacesFromImageInDisk("Path The Image").Result;
            }
        }
Ejemplo n.º 2
0
        private async void btnSelectImage_Click(object sender, EventArgs e)
        {
            if (IsBusy)
            {
                return;
            }

            if (dialogOpen.ShowDialog() == DialogResult.OK)
            {
                dataFaces.Rows.Clear();
                IsBusy = true;
                btnSelectImage.Text       = "Loading...";
                pictureUsed.ImageLocation = dialogOpen.FileName;

                using (FaceDetect faceDetect = new FaceDetect(LocationServerApiAzure.EastUS))
                {
                    faceDetect.SuscriptionKey = "Api Azure Key";
                    ResponseFaceDetect responseFaceDetect = await faceDetect.GetFacesFromImageInDisk(dialogOpen.FileName);

                    if (responseFaceDetect.IsSuccess)
                    {
                        foreach (var face in responseFaceDetect.Faces)
                        {
                            dataFaces.Rows.Add(face.faceAttributes.gender, face.faceAttributes.age);
                        }
                    }
                    else
                    {
                        MessageBox.Show(responseFaceDetect.Error.Message);
                    }
                }

                btnSelectImage.Text = "Select Image";
                IsBusy = false;
            }
        }