Example #1
0
        private async void CmbAnalysisType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(imageHandler.BitmapPath))
            {
                switch (cmbAnalysisType.Text)
                {
                case "Vision - Analyze":
                    txtResult.Text = await _visionClient.MakeAnalysisRequest(imageHandler.BitmapPath);

                    break;

                case "Face - Detect":
                    FaceAnalyzeResult detectedFaces = await _imageAnalizer.FaceAnalyze(imageHandler.BitmapPath);

                    txtResult.Text = detectedFaces.JsonResults[0].JsonContent;

                    Graphics graphic = this.CreateGraphics();

                    foreach (Face face in detectedFaces.Faces)
                    {
                        int xPos = this.AutoScrollPosition.X + grbAnalysis.Location.X + face.Box.Left;
                        int yPos = this.AutoScrollPosition.Y + grbAnalysis.Location.Y + grbAnalysis.Size.Height + 20 + face.Box.Top;

                        Rectangle rectangle = new Rectangle(xPos, yPos, face.Box.Width, face.Box.Height);
                        graphic.DrawRectangle(face.Gender.Equals("female") ? pinkPen : bluePen, rectangle);
                    }

                    break;

                case "Face - GetList":
                    txtResult.Text = await _faceClient.MakeGetListRequest(imageHandler.BitmapPath);

                    break;

                default:
                    break;
                }
            }
            else
            {
                MessageBox.Show("Please select an image", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #2
0
        public async Task <List <JsonResult> > LoadImageInformation(byte[] imageByteData)
        {
            List <JsonResult> jsonResults = new List <JsonResult>();

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            string facesDetectedJson = await _faceClient.MakeDetectRequest(imageByteData);

            stopwatch.Stop();

            string elapsedTime = GetElapsedTime(stopwatch.Elapsed);

            if (!string.IsNullOrWhiteSpace(facesDetectedJson))
            {
                jsonResults.Add(new JsonResult()
                {
                    Name = "Face", Time = elapsedTime, Json = JsonConvert.DeserializeObject <JArray>(facesDetectedJson)
                });
            }

            stopwatch.Start();
            string imageAnalysisJson = await _visionClient.MakeAnalysisRequest(imageByteData);

            stopwatch.Stop();

            elapsedTime = GetElapsedTime(stopwatch.Elapsed);

            if (!string.IsNullOrWhiteSpace(imageAnalysisJson))
            {
                jsonResults.Add(new JsonResult()
                {
                    Name = "Vision", Time = elapsedTime, Json = JsonConvert.DeserializeObject <JObject>(imageAnalysisJson)
                });
            }

            return(jsonResults);
        }