示例#1
0
        // GET: EmoFaces/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmoFace emoFace = db.EmoFaces.Find(id);

            if (emoFace == null)
            {
                return(HttpNotFound());
            }
            return(View(emoFace));
        }
示例#2
0
        public IHttpActionResult DeleteEmoFace(int id)
        {
            EmoFace emoFace = db.EmoFaces.Find(id);

            if (emoFace == null)
            {
                return(NotFound());
            }

            db.EmoFaces.Remove(emoFace);
            db.SaveChanges();

            return(Ok(emoFace));
        }
示例#3
0
        // GET: EmoFaces/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmoFace emoFace = db.EmoFaces.Find(id);

            if (emoFace == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmoPictureId = new SelectList(db.EmoPictures, "Id", "Name", emoFace.EmoPictureId);
            return(View(emoFace));
        }
示例#4
0
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] emotions, EmoPicture emoPicture)
        {
            var listaFaces = new ObservableCollection <EmoFace>(); //ObservableCollection, porque es un tipo especial que emite notificaciones cada vez que se le agregan o eliminan miembros y esto sirve al EF para saber que hacer a continuacion.

            foreach (var emotion in emotions)
            {
                var emoface = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = emoPicture
                };
                emoface.Emotions = ProcessEmotions(emotion.Scores, emoface);
                listaFaces.Add(emoface);
            }
            return(listaFaces);
        }
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] emotions, EmoPicture emoPicture)
        {
            var listaFaces = new ObservableCollection <EmoFace>();

            foreach (var emotion in emotions)
            {
                var emoface = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = emoPicture
                };
                emoface.Emotions = ConvertEmotions(emotion.Scores, emoface);
                listaFaces.Add(emoface);
            }
            return(listaFaces);
        }
示例#6
0
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] emotions, EmoPicture emopic)
        {
            var Faces = new ObservableCollection <EmoFace>();

            foreach (var emotion in emotions)
            {
                var emoface = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Height  = emotion.FaceRectangle.Height,
                    Width   = emotion.FaceRectangle.Width,
                    Picture = emopic,
                };
                emoface.Emotion = ProcessEmotion(emotion.Scores, emoface);
                Faces.Add(emoface);
            }
            return(Faces);
        }
示例#7
0
        private ObservableCollection <EmoFace> ExtractFaces(Microsoft.ProjectOxford.Emotion.Contract.Emotion[] emotions, EmoPicture emoPicture)
        {
            var facesList = new ObservableCollection <EmoFace>();

            foreach (var emotion in emotions)
            {
                var emoFace = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = emoPicture,
                };
                emoFace.Emotions = ProcessEmotions(emotion.Scores, emoFace);
                facesList.Add(emoFace);
            }
            return(facesList);
        }
        //Face
        private ObservableCollection <EmoFace> ExtractFaces(Face[] vFaces, EmoPicture vPicture)
        {
            var lFaces = new ObservableCollection <EmoFace>();

            foreach (var face in vFaces)
            {
                var vFace = new EmoFace()
                {
                    X       = face.FaceRectangle.Left,
                    Y       = face.FaceRectangle.Top,
                    Width   = face.FaceRectangle.Width,
                    Height  = face.FaceRectangle.Height,
                    Picture = vPicture
                };
                vFace.Emotions = ProcessEmotions(face.FaceAttributes.Emotion, vFace);
                lFaces.Add(vFace);
            }

            return(lFaces);
        }
示例#9
0
        private ObservableCollection <EmoFace> ExtractFaces(Face[] faces, EmoPicture emoPicture)
        {
            var listaFaces = new ObservableCollection <EmoFace>();

            foreach (var face in faces)
            {
                var emoface = new EmoFace()
                {
                    X       = face.FaceRectangle.Left,
                    Y       = face.FaceRectangle.Top,
                    Width   = face.FaceRectangle.Width,
                    Heigth  = face.FaceRectangle.Height,
                    Picture = emoPicture
                };

                emoface.Emotions = ProcessEmotions(face.FaceAttributes.Emotion, emoface);
                listaFaces.Add(emoface);
            }
            return(listaFaces);
        }
示例#10
0
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] emotions, EmoPicture emoPicture)
        {
            // ObservableCollection emite notificaciones cada vez que cambiamos sus miembros asi entity framework reconoceria los cambios
            var listaFaces = new ObservableCollection <EmoFace>();

            foreach (var emotion in emotions)
            {
                var emoFace = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = emoPicture,
                };

                emoFace.Emotions = ProcessEmotion(emotion.Scores, emoFace);
                listaFaces.Add(emoFace);
            }
            return(listaFaces);
        }
示例#11
0
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] vEmotion, EmoPicture vPicture)
        {
            var lFaces = new ObservableCollection <EmoFace>();

            foreach (Emotion emotion in vEmotion)
            {
                EmoFace vFace = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = vPicture
                };

                vFace.Emotions = ProcessEmotions(emotion.Scores, vFace);
                lFaces.Add(vFace);
            }

            return(lFaces);
        }
示例#12
0
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] emotions, EmoPicture emoPicture)
        {
            //emoPicture.Faces = new ObservableCollection<EmoFace>();
            var facesList = new ObservableCollection <EmoFace>();

            foreach (var emotion in emotions)
            {
                var emoface = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = emoPicture
                };

                //emoPicture.Faces.Add(emoface);
                facesList.Add(emoface);
                emoface.Emotions = ProcessEmotions(emotion.Scores, emoface);
            }
            return(facesList);
        }
        public List <EmoFace> GetEmoFaces(Emotion[] emotions, Face[] faces)
        {
            int            numberOfFaces = faces.Length;
            List <EmoFace> emoFaces      = new List <EmoFace>();

            if (numberOfFaces > 0)
            {
                for (int i = 0; i < numberOfFaces; i++)
                {
                    EmoFace emoFace = new EmoFace();
                    Debug.WriteLine(faces[i].FaceAttributes.Gender);
                    emoFace.FaceAttributes = faces[i].FaceAttributes;
                    emoFace.FaceId         = faces[i].FaceId;
                    emoFace.FaceLandmarks  = faces[i].FaceLandmarks;
                    emoFace.FaceRectangle  = faces[i].FaceRectangle;
                    emoFace.Scores         = emotions[i].Scores;
                    emoFaces.Add(emoFace);
                }
            }

            return(emoFaces);
        }
示例#14
0
        // populate Faces of emoPicture
        private ObservableCollection <EmoFace> ExtractFaces(Emotion[] emotions, EmoPicture emoPicture)
        {
            var listaFaces = new ObservableCollection <EmoFace>();

            // llenamos la informacion de cada una de las caras que se encuentran en cada emocion
            foreach (var emotion in emotions)
            {
                var emoFace = new EmoFace()
                {
                    X       = emotion.FaceRectangle.Left,
                    Y       = emotion.FaceRectangle.Top,
                    Width   = emotion.FaceRectangle.Width,
                    Height  = emotion.FaceRectangle.Height,
                    Picture = emoPicture,
                };

                emoFace.Emotions = ProcessEmotions(emotion.Scores, emoFace);
                listaFaces.Add(emoFace);
            }

            return(listaFaces);
        }
示例#15
0
        private ObservableCollection <EmoEmotion> ProcessEmotion(Scores scores, EmoFace face)
        {
            var emotionlist = new ObservableCollection <EmoEmotion>();
            var properties  = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            var            filterProperties = properties.Where(p => p.PropertyType == typeof(float));
            EmoEmotionEnum emotype          = EmoEmotionEnum.undetermined;

            foreach (var property in filterProperties)
            {
                if (!Enum.TryParse <EmoEmotionEnum>(property.Name, out emotype))
                {
                    emotype = EmoEmotionEnum.undetermined;
                }
                var emotion = new EmoEmotion();
                emotion.Score       = (float)property.GetValue(scores);
                emotion.EmotionType = emotype;
                emotion.Face        = face;
                emotionlist.Add(emotion);
            }
            return(emotionlist);
        }
示例#16
0
        // Se crea el metodo para
        private ObservableCollection <EmoEmotion> ProcessEmotions(EmotionScores scores, EmoFace emoface)
        {
            // Se instancia una variable lista de EmoEmotion para Almacenar los valores a las emociones
            var emotionList = new ObservableCollection <EmoEmotion>();

            // con GetType se muestro toda la informacion que tiene scores,Con GetProperties Me devuelve todas
            // las propiedades de scores y en los parametros de Getproperties para que no me devuelva todas las
            // las propiedades le especifico cuales quiero traer. El | es un or binario ya que estamos haciendo
            // intercambio con una enumeracion. El Instance es para que no me devuelva los campos estaticos
            var properties = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            // Se filtran los valores recividos que sean de tipo float de properties
            var filterProperties = properties.Where(p => p.PropertyType == typeof(float));
            // Se Crea una variable para los valores que no estan definidos para que se almacenen en el
            var emotype = EmoEmotionEnum.Undetermined;

            // Se recorre filterProperties para irle agregando los valores de puntuacion
            foreach (var prop in filterProperties)
            {
                // Se convierte los parametros de la Emumeracion EmoEmotionEnum EN un valor equivalente
                // a un Enumerable y si no los convierte el valor recivido se convierte en
                if (!Enum.TryParse <EmoEmotionEnum>(prop.Name, out emotype))
                {
                    emotype = EmoEmotionEnum.Undetermined;
                }

                // Se instancia EmoEmotion
                var emoEmotion = new EmoEmotion();
                // Se le agregan los valores a los atributos de EmoEmotion
                emoEmotion.Score = (float)prop.GetValue(scores);
                // Se le almacena un valor Indeterminado a emoEmotion.EmotionType
                emoEmotion.EmotionType = emotype;
                // Se le almacenan las propiedades definidas en el metodo anterior
                emoEmotion.Face = emoface;
                // Se va llenando la lista con los valores almacenados
                emotionList.Add(emoEmotion);
            }
            // Se returno la Lista que se lleno
            return(emotionList);
        }
        private ObservableCollection <EmoEmotion> ProcessEmotions(Microsoft.ProjectOxford.Common.Contract.EmotionScores scores, EmoFace emoFace)
        {
            var emotionList = new ObservableCollection <EmoEmotion>();

            var properties = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            // var filterProperties = properties.Where(p => p.PropertyType == typeof(float));
            var filterProperties = from prop in properties
                                   where prop.PropertyType == typeof(float)
                                   select prop;

            var emotype = EmoEmotionEnum.Untertermind;

            foreach (var propertie in filterProperties)
            {
                if (!Enum.TryParse <EmoEmotionEnum>(propertie.Name, out emotype))
                {
                    emotype = EmoEmotionEnum.Untertermind;
                }

                var emoEmotion = new EmoEmotion();
                emoEmotion.Score       = (float)propertie.GetValue(scores);
                emoEmotion.EmotionType = emotype;
                emoEmotion.Face        = emoFace;

                emotionList.Add(emoEmotion);
            }

            return(emotionList);
        }
示例#18
0
        private ObservableCollection <EmoEmotion> ProcessEmotions(EmotionScores scores, EmoFace vFace)
        {
            ObservableCollection <EmoEmotion> lEmotion = new ObservableCollection <EmoEmotion>();

            var vProperties       = scores.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
            var vFilterProperties = vProperties.Where(x => x.PropertyType == typeof(float));

            var vEmoType = EmoEmotionEnum.Undertermined;

            foreach (var prop in vFilterProperties)
            {
                if (!Enum.TryParse <EmoEmotionEnum>(prop.Name, out vEmoType))
                {
                    vEmoType = EmoEmotionEnum.Undertermined;
                }

                var vEmotion = new EmoEmotion();
                vEmotion.Score       = (float)prop.GetValue(scores);
                vEmotion.EmotionType = vEmoType;
                //vEmotion.EmoFaceId = vFace.Id;
                vEmotion.Face = vFace;

                lEmotion.Add(vEmotion);
            }

            return(lEmotion);
        }
示例#19
0
        private ObservableCollection <EmoEmotion> ProcessEmotions(EmotionScores emotionScores, EmoFace emoFace)
        {
            var emotionList = new ObservableCollection <EmoEmotion>();

            var properties     = emotionScores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            var filterProperty = properties.Where(p => p.PropertyType == typeof(float));

            /*var filterProperty = from p in properties
             *                   where p.PropertyType == typeof(float)
             *                   select p;*/

            foreach (var prop in filterProperty)
            {
                if (Enum.TryParse <EmoEmotionEnum>(prop.Name, out var emoType))
                {
                    emoType = EmoEmotionEnum.Undetermined;
                }

                var emoEmotion = new EmoEmotion();
                emoEmotion.Score       = (float)prop.GetValue(emotionScores);
                emoEmotion.EmotionType = emoType;
                emoEmotion.Face        = emoFace;

                emotionList.Add(emoEmotion);
            }

            return(emotionList);
        }
示例#20
0
        private ObservableCollection <EmoEmotion> ProcessEmotions(EmotionScores scores, EmoFace emoface)
        {
            //C# es un lenguaje capaz de autodescribirse, es capaz de describir cada uno de los objetos que tiene, sabe como estan construidos cada uno de esos objetos(REFLECTION).
            var emotionList      = new ObservableCollection <EmoEmotion>();
            var properties       = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); //devuelve toda la informacion del tipo de datos que tiene esta variable
            var filterProperties = properties.Where(p => p.PropertyType == typeof(float));                      //En toda Coleccion se puede meter Linq. | Quiero todas las propiedades de tipo float.
                                                                                                                //from p in properties where p.PropertyType == typeof(float) select p;

            var emotype = EmoEmotionEnum.Undetermined;                                                          //variable auxiliar

            foreach (var prop in filterProperties)
            {
                if (!Enum.TryParse <EmoEmotionEnum>(prop.Name, out emotype))
                {
                    emotype = EmoEmotionEnum.Undetermined;
                }

                var emoEmotion = new EmoEmotion();
                emoEmotion.Score       = (float)prop.GetValue(scores);
                emoEmotion.EmotionType = emotype;
                emoEmotion.Face        = emoface;
                emotionList.Add(emoEmotion);
            }

            return(emotionList);
        }
示例#21
0
        private ObservableCollection <EmoEmotion> ProcessEmotion(EmotionScores scores, EmoFace emoFace)
        {
            var emotionList = new ObservableCollection <EmoEmotion>();

            // Reflection
            // permite aaceder a los metodos propios de los componentes en tiempo de ejecucion
            // (que sean publicos o propios de la instancia)
            // traer todas las propiedades
            var properties = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            // linq para hacer query en una lista y filtrar tofas las propiedades float
            // var filterProperties = from p in properties where p.PropertyType == typeof(float) select p;

            var filterProperties = properties.Where(p => p.PropertyType == typeof(float));

            var emoType = EmoEmotionEnum.Undertermined;

            foreach (var prop in filterProperties)
            {
                // asignar el valor en un enum
                // convierte el parametro en una opcion del enumerador ENUM -> retorna booleano


                Enum.TryParse <EmoEmotionEnum>(prop.Name, out emoType);
                var emoEmotion = new EmoEmotion()
                {
                    Score       = (float)prop.GetValue(scores),
                    EmotionType = emoType,
                    Face        = emoFace
                };

                emotionList.Add(emoEmotion);
            }

            return(emotionList);
        }
示例#22
0
        private ObservableCollection <EmoEmotion> ProcessEmotions(EmotionScores scores, EmoFace emoface)
        {
            //Creamos una lista observable de emociones
            var emotionList = new ObservableCollection <EmoEmotion>();

            //Devuelve el tipo y las propiedades publicas y que son parte de una instancia
            var properties = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            //Las propiedades son generias, las filtramos por el tipo Float que es el tipo
            //de dato que necesitamos de Scores
            var filterProperties = properties.Where(p => p.PropertyType == typeof(float));

            //Incia la iteracion
            var emotype = EmoEmotionEnum.Undetermined;

            foreach (var prop in filterProperties)
            {
                //este metodo recibe dos parametros, 1 un string de valor, y otro un valor de salida del Enum
                if (!Enum.TryParse <EmoEmotionEnum>(prop.Name, out emotype))
                {
                    emotype = EmoEmotionEnum.Undetermined;
                }

                //Instancia del EmoEmotion
                var emoEmotion = new EmoEmotion();
                //Agregamos el valor que se itera de las filtraciones
                emoEmotion.Score       = (float)prop.GetValue(scores);
                emoEmotion.EmotionType = emotype;
                emoEmotion.Face        = emoface;

                //Lo agregamos
                emotionList.Add(emoEmotion);
            }

            //Retornamos la lista
            return(emotionList);
        }
示例#23
0
        /*
         * La funcion extraera cada emocion de la variable scores para transformarla en un
         * array de EmoEmotion
         * scores: es la respuesta con cada valor de emociones en una sola variable
         *
         */
        private ObservableCollection <EmoEmotion> ProcessEmotions(EmotionScores scores, EmoFace emoFace)
        {
            // se usara reflection
            var emotionList = new ObservableCollection <EmoEmotion>();

            // Obtengo los campos del objeto
            // BindingFlags.Public: para obtener solo las propiedades publicas
            // BindingFlags.Instance: Para que no me devuelva los campos estaticos
            var properties = scores.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            // como properties es collection, puedo usar linq
            //var filterProperties = properties.Where(p => p.PropertyType == typeof(float));
            var filterProperties = from p in properties
                                   where p.PropertyType == typeof(float)
                                   select p;

            // variable que se usara para tener el tipo de emotion
            var emotype = EmoEmotionEnum.Undetermined;

            foreach (var prop in filterProperties)
            {
                // trato de determinar el valor de la enumeracion
                if (!Enum.TryParse <EmoEmotionEnum>(prop.Name, out emotype))
                {
                    emotype = EmoEmotionEnum.Undetermined;
                }

                var emoEmotion = new EmoEmotion();
                // obtengo el valor de la emotion
                emoEmotion.Score       = (float)prop.GetValue(scores);
                emoEmotion.EmotionType = emotype;
                emoEmotion.Face        = emoFace;

                emotionList.Add(emoEmotion);
            }

            return(emotionList);
        }