public void MeanPreprocessorConstructorTest()
        {
            Random rnd = new Random();

            for (int i = 0; i < 1000; i++)
            {
                int iWindowSize         = rnd.Next();
                MeanPreprocessor target = new MeanPreprocessor(iWindowSize);
                Assert.AreEqual <int>(iWindowSize, target.WindowSize);
            }
        }
示例#2
0
        public MainWindow()
        {
            try
            {
                var inputNode        = ConfigurationManager.AppSettings["inputnode"];
                var ageOutputNode    = ConfigurationManager.AppSettings["ageoutputnode"];
                var genderOutputNode = ConfigurationManager.AppSettings["genderoutputnode"];

                var outputNodes = new ValueTuple <string, string>(ageOutputNode, genderOutputNode);
                _runner = new PbRunnerWithWarmUp(inputNode, outputNodes, 150, 150, 3);

                var        meanJsonPath     = ConfigurationManager.AppSettings["meanjsonpath"];
                IProcessor meanPreprocessor = new MeanPreprocessor(meanJsonPath);

                IProcessor dividePreprocessor = new DividePreprocessor(127.5);

                IResizable resizer = new FaceResizer();
                _hogLocator  = new FaceLocatorDlib();
                _haarLocator = new FaceLocatorOpenCv();

                _predictor = new AgeAndGenderPredictor(_runner, inputNode,
                                                       ageOutputNode, genderOutputNode)
                {
                    Locator       = _hogLocator,
                    Resizer       = resizer,
                    Preprocessors = new List <IProcessor>
                    {
                        meanPreprocessor,
                        dividePreprocessor
                    }
                };

                _annotator = new Annotator();
            }
            catch (Exception ex)
            {
                var message = $"An error has occured : {Environment.NewLine}{ex.Message}";

                while (ex.InnerException != null)
                {
                    ex       = ex.InnerException;
                    message += $"{Environment.NewLine}{ex.Message}";
                }

                MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }

            InitializeComponent();
            DataContext = Context;
        }
        public void ProcessUnordinaryWindowSizesTest()
        {
            MeanPreprocessor target = new MeanPreprocessor(6);

            double[]     iArray   = { 1, 2, 3, 4, 5, 6 };
            double[]     expected = { 3.5 };
            BSDataObject actual   = target.Process(new BSDataObject(iArray));

            CheckTwoOrderedArrays(actual.DataArray, expected);
            target = new MeanPreprocessor(5);
            iArray = new double[] { 1, 2, 3, 4 };
            actual = target.Process(new BSDataObject(iArray));
            Assert.AreEqual <int>(0, actual.DataArray.Length);
        }
        public void ProcessTest()
        {
            MeanPreprocessor target = new MeanPreprocessor(5);

            double[]     iArray   = { 1, 2, 3, 10, 5, 7, 4, 2, 12, 3, 10 };
            double[]     expected = { 4.2, 5.4, 5.8, 5.6, 6, 5.6, 6.2 };
            BSDataObject actual   = target.Process(new BSDataObject(iArray));

            CheckTwoOrderedArrays(actual.DataArray, expected);
            target   = new MeanPreprocessor(4);
            iArray   = new double[] { 1, 2, 3, 4, 5 };
            expected = new double[] { 2.5, 3.5 };
            actual   = target.Process(new BSDataObject(iArray));
            CheckTwoOrderedArrays(actual.DataArray, expected);
        }
 public void MeanPreprocessorConstructorWindowSizeOnlyPositiveTest()
 {
     int iWindowSize         = -10;
     MeanPreprocessor target = new MeanPreprocessor(iWindowSize);
 }