/// <summary>
        /// Draw Feature Metrics on Webcam-Video according to given face-parameters and Classificator Selection
        /// </summary>
        /// <param name="face">Input-Face</param>
        /// <param name="dc">Drawing Context of Webcam Video</param>
        /// <param name="tl">Point (top left)</param>
        /// <param name="bl">Point (bottom left)</param>
        private void DrawMetrics(Face face, DrawingContext dc, System.Windows.Point tl, System.Windows.Point bl)
        {
            double padding = (bl.Y - tl.Y) / DataManager.FaceWatcher.EnabledClassifiers.Count;
            double startY  = tl.Y - padding;

            foreach (string metric in DataManager.FaceWatcher.EnabledClassifiers)
            {
                double width  = _maxTxtWidth;
                double height = _maxTxtHeight;
                float  value  = DataManager.ExtractFeaturePropertyValue(face, metric);

                SolidColorBrush metricBrush = value > 0 ? _pozMetricBrush : _negMetricBrush;
                value = Math.Abs(value);
                SolidColorBrush txtBrush = value > 1 ? _emojiBrush : _boundingBrush;

                double x           = tl.X - width - _margin;
                double y           = startY += padding;
                double valBarWidth = width * (value / 100);

                if (value > 1)
                {
                    dc.DrawRectangle(null, _boundingPen, new System.Windows.Rect(x, y, width, height));
                }
                dc.DrawRectangle(metricBrush, null, new System.Windows.Rect(x, y, valBarWidth, height));

                FormattedText metricFTScaled = new FormattedText((String)_upperConverter.Convert(metric, null, null, null),
                                                                 System.Globalization.CultureInfo.CurrentCulture,
                                                                 System.Windows.FlowDirection.LeftToRight,
                                                                 _metricTypeFace, _metricFontSize * width / _maxTxtWidth, txtBrush);

                dc.DrawText(metricFTScaled, new System.Windows.Point(x, y));
            }
        }
Beispiel #2
0
        public override void ProcessInput(int inputID, PipelineBuffer buffer)
        {
            base.ProcessInput(inputID, buffer);

            while (buffer.NextRow())
            {
                var value = buffer.GetString(0);
                var upperCaseConverter = new UpperCaseConverter();

                buffer.SetString(0, upperCaseConverter.Convert(value));
            }
        }
Beispiel #3
0
 public void UpperCaseConverterShouldWork()
 {
     var s = "hsDkjdsa8dask";
     var converter = new UpperCaseConverter();
     Assert.AreEqual(s.ToUpper(), (string)converter.Convert(s, typeof(bool), null, CultureInfo.CurrentCulture));
 }
        public void Test_Convert_Ok(object str, string expected)
        {
            UpperCaseConverter converter = new UpperCaseConverter();

            Assert.Equal(expected, converter.Convert(str, typeof(string), null, CultureInfo.InvariantCulture));
        }