예제 #1
0
        public void LoadImagesToWorkingArea(List <Image> images)
        {
            List <Image> workingAreaImages = new List <Image>();

            foreach (Image image in images)
            {
                List <Label> listLabelCopy = new List <Label>();
                foreach (Label label in image.Labels)
                {
                    if (label.labelType == "SimpleLabel")
                    {
                        SimpleLabel label2 = (SimpleLabel)label;
                        listLabelCopy.Add(new SimpleLabel(label2.Sentence));
                    }
                    else if (label.labelType == "PersonLabel")
                    {
                        PersonLabel label2 = (PersonLabel)label;
                        listLabelCopy.Add(new PersonLabel(label2.Name, label2.FaceLocation, label2.Surname, label2.Nationality, label2.EyesColor, label2.HairColor, label2.Sex, label2.BirthDate, label2.SerialNumber));
                    }
                    else if (label.labelType == "SpecialLabel")
                    {
                        SpecialLabel label2 = (SpecialLabel)label;
                        listLabelCopy.Add(new SpecialLabel(label2.GeographicLocation, label2.Address, label2.Photographer, label2.PhotoMotive, label2.Selfie, label2.SerialNumber));
                    }
                }

                Image newImage = new Image(image.Name, listLabelCopy, image.Calification, image.BitmapImage, image.Resolution, image.AspectRatio, image.DarkClear, image.Exif);
                workingAreaImages.Add(newImage);
            }
            foreach (Image image in workingAreaImages)
            {
                this.WorkingArea.WorkingAreaImages.Add(image);
            }

            return;
        }
예제 #2
0
        public List <Image> Search(List <Image> images, string searchDeclaration)
        {
            List <List <List <string> > > Declarations = Declaration(searchDeclaration);

            List <List <Image> > Total = new List <List <Image> >();
            List <Image>         Final = new List <Image>();

            foreach (List <List <string> > subDec in Declarations)
            {
                List <Image> temp = new List <Image>();
                foreach (Image image in images)
                {
                    int cont = 0;
                    foreach (List <string> atributes in subDec)
                    {
                        switch (atributes[0])
                        {
                        case "HairColor":
                            if (image.SomePersonLabelContains(atributes[0], null, ENationality.None, (EColor)Enum.Parse(typeof(EColor), atributes[1])))
                            {
                                cont++;
                            }
                            break;

                        case "EyesColor":
                            if (image.SomePersonLabelContains(atributes[0], null, ENationality.None, (EColor)Enum.Parse(typeof(EColor), atributes[1])))
                            {
                                cont++;
                            }
                            break;

                        case "Sex":
                            if (image.SomePersonLabelContains(atributes[0], null, ENationality.None, EColor.None, (ESex)Enum.Parse(typeof(ESex), atributes[1])))
                            {
                                cont++;
                            }
                            break;

                        case "Name":
                            if (image.SomePersonLabelContains(atributes[0], atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "Face":

                            foreach (Label b in image.Labels)
                            {
                                if (b.labelType == "PersonLabel")
                                {
                                    PersonLabel plb = (PersonLabel)b;
                                    if (plb.FaceLocation != null && plb.Name == atributes[1])
                                    {
                                        // x, y, width, height
                                        double[] coord = { plb.FaceLocation[0], plb.FaceLocation[1], plb.FaceLocation[2], plb.FaceLocation[3] };
                                        System.Drawing.Bitmap BmapClone = (System.Drawing.Bitmap)image.BitmapImage.Clone();
                                        BmapClone = scissors.Crop(BmapClone, coord);
                                        Image faceImage = new Image(BmapClone, new List <Label>(), image.Calification);
                                        temp.Add(faceImage);
                                    }
                                }
                            }
                            break;

                        case "Surname":
                            //Console.WriteLine(atributes[1]);
                            if (image.SomePersonLabelContains(atributes[0], atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "Birthdate":
                            if (image.SomePersonLabelContains(atributes[0], atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "FaceLocation":
                            string[] subFACEstring = atributes[1].Split(new string[] { "," }, StringSplitOptions.None);
                            double[] faceCoords    = { Convert.ToDouble(subFACEstring[0]), Convert.ToDouble(subFACEstring[1]), Convert.ToDouble(subFACEstring[2]), Convert.ToDouble(subFACEstring[3]) };
                            if (image.SomePersonLabelContains(atributes[0], null, ENationality.None, EColor.None, ESex.None, faceCoords))
                            {
                                cont++;
                            }
                            break;

                        case "Nationality":
                            if (image.SomePersonLabelContains(atributes[0], null, (ENationality)Enum.Parse(typeof(ENationality), atributes[1])))
                            {
                                cont++;
                            }
                            break;

                        case "GeographicLocation":

                            string[] substring = atributes[1].Split(new string[] { "," }, StringSplitOptions.None);
                            double[] coords    = { Convert.ToDouble(substring[0]), Convert.ToDouble(substring[1]) };
                            if (image.SomeSpecialLabelContains(atributes[0], coords))
                            {
                                cont++;
                            }
                            break;

                        case "Address":
                            if (image.SomeSpecialLabelContains(atributes[0], null, atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "Photographer":
                            if (image.SomeSpecialLabelContains(atributes[0], null, atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "Photomotive":
                            if (image.SomeSpecialLabelContains(atributes[0], null, atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "Selfie":
                            if (image.SomeSpecialLabelContains(atributes[0], null, null, Convert.ToBoolean(atributes[1])))
                            {
                                cont++;
                            }
                            break;

                        case "Sentence":
                            if (image.SomeSimpleLabelContains(atributes[0], atributes[1]))
                            {
                                cont++;
                            }
                            break;

                        case "ImageName":                                 //string
                            if (image.Name == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Calification":                                 // int
                            try
                            {
                                if (image.Calification == Convert.ToInt32(atributes[1]))
                                {
                                    cont++;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Calification => Parameter: {0} must be an integer", atributes[1]);
                            }
                            break;

                        case "Resolution":                                 // int[]
                            try
                            {
                                string[] resString  = atributes[1].Split(new string[] { "," }, StringSplitOptions.None);
                                int[]    resolution = { Convert.ToInt32(resString[0]), Convert.ToInt32(resString[1]) };
                                if (image.Resolution[0] == resolution[0] && image.Resolution[1] == resolution[1])
                                {
                                    cont++;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Resolution => Parameter: {0} must be an integer array", atributes[1]);
                            }
                            break;

                        case "AspectRatio":                                 // int[]
                            try
                            {
                                string[] aspectString = atributes[1].Split(new string[] { "," }, StringSplitOptions.None);
                                int[]    aspectRatio  = { Convert.ToInt32(aspectString[0]), Convert.ToInt32(aspectString[1]) };
                                if (image.Resolution[0] == aspectRatio[0] && image.Resolution[1] == aspectRatio[1])
                                {
                                    cont++;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("AspectRatio => Parameter: {0} must be an integer array", atributes[1]);
                            }
                            break;

                        case "DarkClear":                                 // bool
                            try
                            {
                                if (image.DarkClear == Convert.ToBoolean(atributes[1]))
                                {
                                    cont++;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("DarkClear => Parameter: {0} must be a boolean", atributes[1]);
                            }
                            break;

                        case "AutomaticAdjustment":
                            if (image.ApplyedFilters[EFilter.AutomaticAdjustment].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Grayscale":
                            if (image.ApplyedFilters[EFilter.Grayscale].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Brightness":
                            if (image.ApplyedFilters[EFilter.Brightness].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Color":
                            if (image.ApplyedFilters[EFilter.Color].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Invert":
                            if (image.ApplyedFilters[EFilter.Invert].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Sepia":
                            if (image.ApplyedFilters[EFilter.Sepia].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "RotateFlip":
                            if (image.ApplyedFilters[EFilter.RotateFlip].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Mirror":
                            if (image.ApplyedFilters[EFilter.Mirror].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "OldFilm":
                            if (image.ApplyedFilters[EFilter.OldFilm].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Windows":
                            if (image.ApplyedFilters[EFilter.Windows].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Contrast":
                            if (image.ApplyedFilters[EFilter.Contrast].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;

                        case "Burned":
                            if (image.ApplyedFilters[EFilter.Burned].ToString() == atributes[1])
                            {
                                cont++;
                            }
                            break;
                        }
                    }
                    if (cont == subDec.Count) //Contador de parametros que calzan, es igual a la cantidad de parametros en subDec
                    {
                        temp.Add(image);
                    }
                }
                Total.Add(temp);
            }
            //Image Filter
            foreach (List <Image> subList  in Total)
            {
                foreach (Image tempImage in subList)
                {
                    if (!Final.Contains(tempImage))
                    {
                        Final.Add(tempImage);
                    }
                }
            }

            return(Final);
        }