Ejemplo n.º 1
0
        private BitmapSource VisualizeResult(VideoFrame frame)
        {
            // Draw any results on top of the image.
            BitmapSource visImage = frame.Image.ToBitmapSource();

            var result = _latestResultsToDisplay;

            if (result != null)
            {
                // See if we have local face detections for this image.
                var clientFaces = (OpenCvSharp.Rect[])frame.UserData;
                if (clientFaces != null && result.Faces != null)
                {
                    // If so, then the analysis results might be from an older frame. We need to match
                    // the client-side face detections (computed on this frame) with the analysis
                    // results (computed on the older frame) that we want to display.
                    MatchAndReplaceFaceRectangles(result.Faces, clientFaces);
                }

                visImage = Visualization.DrawFaces(visImage, result.Faces, result.EmotionScores, result.CelebrityNames);
                visImage = Visualization.DrawTags(visImage, result.Tags);
            }

            return(visImage);
        }
Ejemplo n.º 2
0
        private BitmapSource VisualizeResult(VideoFrame frame)
        {
            // Draw any results on top of the image.
            BitmapSource visImage = frame.Image.ToBitmapSource();

            var result = _latestResultsToDisplay;

            if (result != null)
            {
                // See if we have local face detections for this image.
                var clientFaces = (OpenCvSharp.Rect[])frame.UserData;
                if (clientFaces != null && result.Faces != null)
                {
                    // If so, then the analysis results might be from an older frame. We need to match
                    // the client-side face detections (computed on this frame) with the analysis
                    // results (computed on the older frame) that we want to display.
                    MatchAndReplaceFaceRectangles(result.Faces, clientFaces);
                }

                visImage = Visualization.DrawFaces(visImage, result.Faces, result.EmotionScores, result.CelebrityNames);

                IDictionary <string, string> tagCollection = new Dictionary <string, string>();
                StandardsFinder standardsFinder            = new StandardsFinder();

                if (result.Tags != null && result.Tags.Count() > 0)
                {
                    foreach (var tag in result.Tags)
                    {
                        var standardName = standardsFinder.GetStandards(tag.Name);
                        //tagCollection.Add(tag.Name,standardName);
                        tag.Name = tag.Name + " -   " + standardName;
                    }
                }

                visImage = Visualization.DrawTags(visImage, result.Tags);
            }

            return(visImage);
        }