Exemple #1
0
        //for the sake of the example the parameters types are string
        public bool CompareEmotion(string randomEmotion)
        {
            //NN analyse throws an object with EmotionName, percentage and user Recognition.
            ReturnObject result = nnUnit.analyse();

            //Debug Mode Ausgabe
            this.testObj = result;

            //check if NNUnit threw an Exception (During Game)
            switch (result.FaceDetected)
            {
            case ReturnObject.Type.NoFaceDetected:
                throw new UserMissingException();

            case ReturnObject.Type.MoreThanOneFaceDetected:
                throw new MoreThanOneUserException();

            case ReturnObject.Type.Exception:
                throw new UnknownException();
            }

            //Compare our randomEmotion and the result
            if (randomEmotion == result.Emotion)
            {
                //save points
                points += result.Percentage;

                //true for SUCCESS
                return(true);
            }

            //false for FAILURE
            return(false);
        }
        public EmotionTableInterpreter(Process neuralNetProcess, ref ReturnObject i_returnObject)
        {
            neuralNetProcess.Start();
            netOutput = neuralNetProcess.StandardOutput.ReadToEnd();

            //1. Versuch
            netOutput = netOutput.Replace(Environment.NewLine, "");
            //2. Versuch
            //netOutput = Regex.Replace(netOutput, @"\r\n?|\n", "");
            netOutput         = netOutput.Replace(@"\n", "");
            netOutput         = netOutput.Replace(@"\r", "");
            netOutput         = netOutput.Replace(@"\t", "");
            netOutput         = netOutput.Replace(@"\v", "");
            netOutput         = netOutput.Replace("@\f", "");
            a_matchCollection = Regex.Matches(netOutput, patternFaceFoundCount);
            if (a_matchCollection.Count > 0)
            {
                foreach (Match singlePic in a_matchCollection)
                {
                    if (Convert.ToInt64(singlePic.Groups[FACES_FOUND_COUNT].Value) > 1)
                    {
                        severalFacesFound = true;
                        break;
                    }

                    if (Convert.ToInt64(singlePic.Groups[FACES_FOUND_COUNT].Value) == 0)
                    {
                        noFacesFound = true;
                        noFaceFoundCnt++;
                    }
                }
            }
            if (!severalFacesFound)
            {
                if (a_matchCollection.Count > noFaceFoundCnt)
                {
                    a_matchCollection = Regex.Matches(netOutput, patternArray);
                    if (a_matchCollection.Count > 0)
                    {
                        foreach (Match singlePic in a_matchCollection)
                        {
                            Evaluate(singlePic.Groups[SINGLE_PIC_OUTPUT].Value);
                        }
                    }
                    KeyValuePair <string, EmoCollValue> resultEmo = GetEmotion();

                    i_returnObject = new ReturnObject(resultEmo.Key, resultEmo.Value.finalPercentage, ReturnObject.Type.FaceDetected);
                }
                else if (/*noFacesFound &&*/ a_matchCollection.Count <= noFaceFoundCnt)
                {
                    i_returnObject = new ReturnObject(NO_EMO_DETECED, 0, ReturnObject.Type.NoFaceDetected);
                }
            }
            else if (severalFacesFound)
            {
                i_returnObject = new ReturnObject(NO_EMO_DETECED, 0, ReturnObject.Type.MoreThanOneFaceDetected);
            }
        }
Exemple #3
0
 //check if user Exist to Start Game
 public ReturnObject TryToRecognizeUser()
 {
     this.testObj = nnUnit.CheckUserExist();
     return(this.testObj);
 }