Beispiel #1
0
        public async Task StartCalibration(ColorSkinCalibrationConfig config = null)
        {
            _samples.Clear();
            if (config != null)
            {
                _config.ColorSkinCalibrationConfig = config;
            }
            _calibrationStartDate = DateTime.Now;
            if (!_useHeadDetection)
            {
                _config.BackGroundRemoveConfig.IsActive = false;
            }

            Rect handZone = new Rect(_config.ColorSkinCalibrationConfig.TLX, _config.ColorSkinCalibrationConfig.TLY, Math.Min(_config.ColorSkinCalibrationConfig.Width, MaxWidth), Math.Min(_config.ColorSkinCalibrationConfig.Height, MaxHeight));
            var  tmp      = new Mat(_target, handZone);


            var pipelineBackGround = new Pipeline()
                                     .Pipe(new BlurFilter(_config.BlurConfig));
            await pipelineBackGround.RunAsync(tmp);

            Cv2.CvtColor(pipelineBackGround.OutputMat, _wbackground, ColorConversionCodes.BGR2GRAY);
            CalibrationStarted = true;
            Result             = new SkinPresetHSV();
        }
Beispiel #2
0
        public void ActivateCalibration(Mat currentFrame, ColorSkinCalibrationConfig config = null)
        {
            _target        = new Mat();
            _initialTarget = new Mat();
            Cv2.CopyTo(currentFrame, _target);
            Cv2.CopyTo(currentFrame, _initialTarget);
            if (config != null)
            {
                _config.ColorSkinCalibrationConfig = config;
            }
            CanStartCalibration = true;

            RaisePropertyChanged(() => MaxWidth);
            RaisePropertyChanged(() => MaxHeight);
            DrawTarget(_config.ColorSkinCalibrationConfig);
        }
Beispiel #3
0
 public void DrawTarget(ColorSkinCalibrationConfig config)
 {
     if (_useHeadDetection)
     {
         return;
     }
     if (_initialTarget != null && _initialTarget.Width > 0)
     {
         Rect handZone = new Rect(_config.ColorSkinCalibrationConfig.TLX, _config.ColorSkinCalibrationConfig.TLY, Math.Min(_config.ColorSkinCalibrationConfig.Width, MaxWidth), Math.Min(_config.ColorSkinCalibrationConfig.Height, MaxHeight));
         Cv2.CopyTo(_initialTarget, _target);
         Cv2.Rectangle(_target, handZone, new Scalar(0, 255, 0));
         RaisePropertyChanged(() => MaxWidth);
         RaisePropertyChanged(() => MaxHeight);
         W_HANDTARGET = _target.ToBitmap().ToBitmapImage();
     }
 }
Beispiel #4
0
        public static Config Default()
        {
            Config config = new Config();

            //config.BinaryThreshold = MinMax.Default();
            //config.HSVThreshold = HSVThresholdConfig.Default();
            config.BlurConfig                 = BlurConfig.Default();
            config.FaceConfig                 = FaceConfig.Default();
            config.MorphConfig                = MorphConfig.Default();
            config.BackGroundRemoveConfig     = BackGroundRemoveConfig.Default();
            config.ScaleDownConfig            = ResizeConfig.Default();
            config.TrackerConfig              = TrackerConfig.Default();
            config.ColorSkinCalibrationConfig = ColorSkinCalibrationConfig.Default();
            config.BackGroundRemoveConfig     = BackGroundRemoveConfig.Default();
            //config.YCrCbThresholdConfig = YCrCbThresholdConfig.Default();
            config.SkinDetectConfig = SkinDetectConfig.Default();
            return(config);
        }