Ejemplo n.º 1
0
        private void btnCardRank_Click(object sender, EventArgs e)
        {
            var  image  = Bitmap.FromFile(tbFile.Text) as Bitmap;
            Crop crop   = new Crop(_settings.MyCardsRect);//TODO card identity
            var  source = crop.Apply(image);

            FiltersSequence seq = new FiltersSequence();

            seq.Add(Grayscale.CommonAlgorithms.BT709); //First add  grayScaling filter
            seq.Add(new OtsuThreshold());              //Then add binarization(thresholding) filter
            var temp = seq.Apply(source);              // Apply filters on source image


            BlobCounter extractor = new BlobCounter();

            extractor.FilterBlobs = true;
            extractor.MinWidth    = extractor.MinHeight = (int)_settings.MinCardSize;//TODO card size
            //extractor.MaxWidth = extractor.MaxHeight = 70;//TODO card size
            extractor.ProcessImage(temp);

            //Will be used transform(extract) cards on source image
            //QuadrilateralTransformation quadTransformer = new QuadrilateralTransformation();


            Bitmap cardImg = null;

            foreach (Blob blob in extractor.GetObjectsInformation())
            {
                cardImg = source.Clone(blob.Rectangle, PixelFormat.DontCare);
                break;
            }

            var r = _settings.CardRankRect;
            var f = new AreaSelectorForm(new Rectangle(r.X * 5, r.Y * 5, r.Width * 5, r.Height * 5));

            f.Text = "Select CardRankRect rect";

            f.SetImage(cardImg, 5);
            if (f.ShowDialog() == DialogResult.OK)
            {
                var newRect = new Rectangle(
                    (int)Math.Round(f.Rect.X / 5.0),
                    (int)Math.Round(f.Rect.Y / 5.0),
                    (int)Math.Round(f.Rect.Width / 5.0),
                    (int)Math.Round(f.Rect.Height / 5.0));
                lblCardRank.Text       = newRect.ToString();
                _settings.CardRankRect = newRect;
                AppSettingsManager.Save(_settings);
            }
        }
Ejemplo n.º 2
0
        private void btnFold5_Click(object sender, EventArgs e)
        {
            var f = new AreaSelectorForm(_settings.Fold5);

            f.Text = "Select Fold5 rect";
            var image = Bitmap.FromFile(tbFile.Text) as Bitmap;

            f.SetImage(image);
            if (f.ShowDialog() == DialogResult.OK)
            {
                lblFold5.Text   = f.Rect.ToString();
                _settings.Fold5 = f.Rect;
                AppSettingsManager.Save(_settings);
            }
        }
Ejemplo n.º 3
0
        private void btnBetRaise_Click(object sender, EventArgs e)
        {
            var f = new AreaSelectorForm(_settings.BetRaiseRect);

            f.Text = "Select Check/Call button rect";
            var image = Bitmap.FromFile(tbFile.Text) as Bitmap;

            f.SetImage(image);
            if (f.ShowDialog() == DialogResult.OK)
            {
                lblBetRaise.Text       = f.Rect.ToString();
                _settings.BetRaiseRect = f.Rect;
                AppSettingsManager.Save(_settings);
            }
        }
Ejemplo n.º 4
0
        private void btnShort4_Click(object sender, EventArgs e)
        {
            var f = new AreaSelectorForm(_settings.ShortButtonRect4);

            f.Text = "Select Short button 4 rect";
            var image = Bitmap.FromFile(tbFile.Text) as Bitmap;

            f.SetImage(image);
            if (f.ShowDialog() == DialogResult.OK)
            {
                lblShort4.Text             = f.Rect.ToString();
                _settings.ShortButtonRect4 = f.Rect;
                AppSettingsManager.Save(_settings);
            }
        }
Ejemplo n.º 5
0
        private void btnSelectPicture_Click(object sender, EventArgs e)
        {
            var f = new AreaSelectorForm(Rectangle.Empty);

            f.Text = "Select rect";

            if (_lastFileName != "")
            {
                var image = Bitmap.FromFile(_lastFileName) as Bitmap;
                f.SetImage(image);
            }
            if (f.ShowDialog() == DialogResult.OK)
            {
                _rect = f.Rect;
                pbSelectedPicture.Image = f.GetSelectedPicture();
                _lastFileName           = f.SelectedImageFileName;
                lblLastFileName.Text    = "last file: " + _lastFileName;
            }
        }
Ejemplo n.º 6
0
 private void btRectTableX_Click(object sender, EventArgs e)
 {
     var f = new AreaSelectorForm(_settings.RectTableX);
     f.Text = "Select RectTableX rect";
     var image = Bitmap.FromFile(tbFile.Text) as Bitmap;
     f.SetImage(image);
     if (f.ShowDialog() == DialogResult.OK)
     {
         lblRectTableX.Text = f.Rect.ToString();
         _settings.RectTableX = f.Rect;
         AppSettingsManager.Save(_settings);
     }
 }
Ejemplo n.º 7
0
 private void btnShort4_Click(object sender, EventArgs e)
 {
     var f = new AreaSelectorForm(_settings.ShortButtonRect4);
     f.Text = "Select Short button 4 rect";
     var image = Bitmap.FromFile(tbFile.Text) as Bitmap;
     f.SetImage(image);
     if (f.ShowDialog() == DialogResult.OK)
     {
         lblShort4.Text = f.Rect.ToString();
         _settings.ShortButtonRect4 = f.Rect;
         AppSettingsManager.Save(_settings);
     }
 }
Ejemplo n.º 8
0
 private void btnCheckCall_Click(object sender, EventArgs e)
 {
     var f = new AreaSelectorForm(_settings.CheckCallRect);
     f.Text = "Select Check/Call button rect";
     var image = Bitmap.FromFile(tbFile.Text) as Bitmap;
     f.SetImage(image);
     if (f.ShowDialog() == DialogResult.OK)
     {
         lblCheckCall.Text = f.Rect.ToString();
         _settings.CheckCallRect = f.Rect;
         AppSettingsManager.Save(_settings);
     }
 }
Ejemplo n.º 9
0
        private void btnCardSuit_Click(object sender, EventArgs e)
        {
            var image = Bitmap.FromFile(tbFile.Text) as Bitmap;
            Crop crop = new Crop(_settings.MyCardsRect);//TODO card identity
            var source = crop.Apply(image);

            FiltersSequence seq = new FiltersSequence();
            seq.Add(Grayscale.CommonAlgorithms.BT709);  //First add  grayScaling filter
            seq.Add(new OtsuThreshold()); //Then add binarization(thresholding) filter
            var temp = seq.Apply(source); // Apply filters on source image

            BlobCounter extractor = new BlobCounter();
            extractor.FilterBlobs = true;
            extractor.MinWidth = extractor.MinHeight = (int)_settings.MinCardSize;//TODO card size
            //extractor.MaxWidth = extractor.MaxHeight = 70;//TODO card size
            extractor.ProcessImage(temp);

            //Will be used transform(extract) cards on source image
            //QuadrilateralTransformation quadTransformer = new QuadrilateralTransformation();

            Bitmap cardImg = null;
            foreach (Blob blob in extractor.GetObjectsInformation())
            {
                cardImg = source.Clone(blob.Rectangle, PixelFormat.DontCare);
                break;
            }

            var r = _settings.CardSuitRect;
            var f = new AreaSelectorForm(new Rectangle(r.X*5, r.Y*5, r.Width*5, r.Height*5));
            f.Text = "Select CardSuitRect rect";

            f.SetImage(cardImg, 5);
            if (f.ShowDialog() == DialogResult.OK)
            {
                var newRect = new Rectangle(
                    (int)Math.Round(f.Rect.X / 5.0),
                    (int)Math.Round(f.Rect.Y / 5.0),
                    (int)Math.Round(f.Rect.Width / 5.0),
                    (int)Math.Round(f.Rect.Height / 5.0));
                lblCardSuit.Text = newRect.ToString();
                _settings.CardSuitRect = newRect;
                AppSettingsManager.Save(_settings);
            }
        }