Esempio n. 1
0
        public override void Init()
        {
            WindowProperties.Title     = "Scan Face...";
            WindowProperties.CanResize = false;
            _windowAdjusted            = false;

            var cfg = CameraConfig.LoadConfig();

            if (cfg == null)
            {
                ConfigureWebcam();
                return;
            }

            _cc = new CameraController();
            _cc.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName.Equals(nameof(_cc.ImageSource)))
                {
                    WebcamImage = _cc.ImageSource;
                    if (!_windowAdjusted && _cc.ImageSource != null)
                    {
                        var imageRatio = _cc.ImageSource.Width / _cc.ImageSource.Height;

                        if (_cc.ImageSource.Height > _cc.ImageSource.Width)
                        {
                            WindowProperties.Height = 500;
                            WindowProperties.Width  = (int)(500 * imageRatio);
                        }
                        else
                        {
                            WindowProperties.Width  = 400;
                            WindowProperties.Height = (int)(400 * imageRatio);
                        }
                        _windowAdjusted = true;
                    }
                }
            };

            _cc.Start(cfg);
        }