Ejemplo n.º 1
0
        private void videoNewFrame(object sender, NewFrameEventArgs args)
        {
            Bitmap temp = args.Frame.Clone() as Bitmap;

            try
            {
                frameCounter++;

                if (frameCounter > 10)
                {
                    cards        = recognizer.Recognize(temp);
                    frameCounter = 0;
                }

                //Draw Rectangle around cards and write card strings on card
                using (Graphics graph = Graphics.FromImage(temp))
                {
                    foreach (Card card in cards)
                    {
                        graph.DrawPolygon(pen, card.Corners);                          //Draw a polygon around card
                        PointF point = CardRecognizer.GetStringPoint(card.Corners);    //Find Top left corner
                        point.Y += 10;
                        graph.DrawString(card.ToString(), font, Brushes.White, point); //Write string on card
                    }
                }
            }
            catch { }
            this.pictureBox1.Image = ResizeBitmap(temp);
        }
Ejemplo n.º 2
0
        private void ProcessRecognition()
        {
            for (int i = 0; i <= 2; i++)
            {
                if (counter3 == 0)
                {
                    this.image = im1;
                }
                else if (counter3 == 1)
                {
                    this.image = im2;
                }
                else
                {
                    this.image = im3;
                }

                CardCollection cards = recognizer.Recognize(this.image);
                //cardImagePanel.DrawImages(cards.ToImageList());
                String r, b;
                //txtCards.Clear();

                //foreach (Card card in cards)
                //{

                //txtCards.AppendText(card.ToString() + Environment.NewLine);

                getScore();

                //getWinner();

                //}
                // */
                //Draw Rectangle around cards and write card strings on card
                using (Graphics graph = Graphics.FromImage(image))
                {
                    foreach (Card card in cards)
                    {
                        graph.DrawPolygon(pen, card.Corners);                          //Draw a polygon around card
                        PointF point = CardRecognizer.GetStringPoint(card.Corners);    //Find Top left corner
                        point.Y += 10;
                        graph.DrawString(card.ToString(), font, Brushes.White, point); //Write string on card
                    }
                }

                /*
                 * r = recognizer.rank1.ToString();
                 * b = recognizer.numBlack.ToString();
                 * txtRed.Text = r;
                 * txtBlack.Text = b;
                 */
                /*
                 * recognizer.numRed = 0;
                 * recognizer.numBlack = 0;
                 */
                if (counter3 == 0)
                {
                    pb1.Image = ResizeBitmap(this.image);
                }
                else if (counter3 == 1)
                {
                    pb2.Image = ResizeBitmap(this.image);
                }
                else
                {
                    pb3.Image = ResizeBitmap(this.image);
                }


                //this.pb_loaded.Image = ResizeBitmap(this.image);
                counter3++;
            }
            getWinner();
        }