Exemplo n.º 1
0
        private void AnalizeImage(Bitmap recimg)
        {
            if (recimg == null)
            {
                MessageBox.Show("Please select an image to analyze");
            }
            else
            {
                IList <string> identifiedObjects = ObjectIdentificationService.AnalyzeImage(recimg);
                //this.label32.Text = "";
                Dispatcher.Invoke(this, () => { this.label32.Text = ""; });

                foreach (string objectName in identifiedObjects)
                {
                    //this.label32.Text = this.label32.Text + ("May contain " + objectName + "\r\n");
                    Dispatcher.Invoke(this, () => { this.label32.Text = this.label32.Text + ("May contain " + objectName + "\r\n"); });
                }

                if (identifiedObjects.Count == 0)
                {
                    //this.label32.Text = "Did not recognize anything";
                    Dispatcher.Invoke(this, () => { this.label32.Text = "Did not recognize anything"; });
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Repeat the code if is not correct for the first time with the recognization of the camera
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Correct_Click(object sender, RoutedEventArgs e)
        {
            Carta.CardAI = Carta.CardAICopy;

            identificationImage = webCameraControl.GetCurrentImage();
            if (identificationImage == null)
            {
                MessageBox.Show("Please select an image to analyze");
            }
            else
            {
                IList <string> identifiedObjects = ObjectIdentificationService.AnalyzeImage(Convert(identificationImage));
                if (identifiedObjects.Count == 0)
                {
                    FoundedCard.Content = "Not work";
                }
                else
                {
                    string[] objectCard = identifiedObjects[0].Split(' ');
                    Carta.CardInGame[0]  = objectCard[0];
                    Carta.CardInGame[1]  = objectCard[1];
                    FoundedCard.Content  = objectCard[0] + " " + objectCard[1];
                    Carta.CardInGameCopy = (String[])Carta.CardInGame.Clone();
                    SelectGame(Carta.CardInGameCopy[0], Carta.CardInGameCopy[1], false);
                    SelectGame(objectCard[0], objectCard[1], false);
                    Random num = new Random();
                    Move.Content = "";
                    if (saveCombinations.Count != 0)
                    {
                        foreach (string comb in saveCombinations[num.Next(0, saveCombinations.Count)])
                        {
                            Thread.Sleep(1500);
                            Move.Content += comb + " - ";
                            DeleteCard(comb);
                            if (Carta.NumCard == 1)
                            {
                                Thread.Sleep(1500);
                                Move.Content += " - UNO!";
                            }
                            else if (Carta.NumCard == 0)
                            {
                                Move.Content = "!!!!!! I WIN !!!!!!";
                            }
                        }
                    }
                    else if (Carta.NumCard == 0)
                    {
                        Move.Content = "!!!!!! I WIN !!!!!!";
                    }
                    else
                    {
                        Move.Content = "DRAW";
                        IsDrawCard();
                    }
                }
                saveCombinations = null;
                saveCombinations = new List <String[]>();
            }
        }
        private void AnalyzeButton_Click(object sender, RoutedEventArgs e)
        {
            if (identificationImage == null)
            {
                MessageBox.Show("Please select an image to analyze");
            }
            else
            {
                IList <string> identifiedObjects = ObjectIdentificationService.AnalyzeImage(identificationImage);
                this.AnalysisResultsText.Text = "";

                foreach (string objectName in identifiedObjects)
                {
                    this.AnalysisResultsText.Text = this.AnalysisResultsText.Text + ("May contain " + objectName + "\r\n");
                }

                if (identifiedObjects.Count == 0)
                {
                    this.AnalysisResultsText.Text = "Did not recognize anything";
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Recognize a card
        /// </summary>
        /// <returns></returns>
        private string IdentifierObject()
        {
            var identificationImage = webCameraControl.GetCurrentImage();

            if (identificationImage == null)
            {
                MessageBox.Show("Please select an image to analyze");
            }
            else
            {
                IList <string> identifiedObjects = ObjectIdentificationService.AnalyzeImage(Convert(identificationImage));
                if (identifiedObjects.Count == 0)
                {
                    return("Not work");
                }
                else
                {
                    return(identifiedObjects[0]);
                }
            }
            return("Not work");
        }