static void Main(string[] args) { int test = 0; List <Skies> dangus = new List <Skies>(); List <TempSky> tempDangus = new List <TempSky>(); classMakeTemp(out tempDangus, @"C:\Users\Laptop\Desktop\temp"); Console.WriteLine("Press a or anything else."); if (tempDangus.Count > 0 && (Console.ReadKey().KeyChar == 'a')) { classMake(out dangus, @"C:\Users\Laptop\Desktop\asd2", tempDangus[0].Image); } else if (tempDangus.Count > 0) { dangus = DeSerializeObject <List <Skies> >(@".\dangau.xml"); } else { System.Environment.Exit(1); } string oroSalygos = ""; int[] debesuotumasArray = new int[5]; GC.Collect(); Dictionary <int, double> skyDictionary = new Dictionary <int, double>(); for (int i = 0; i < dangus.Count; i = i + 5) { if (dangus.Count - i > 5) { for (int j = 0; j < 5; j++) { skyDictionary = Surykiavimas(skyDictionary, tempDangus, dangus, test, j); counteris(dangus, skyDictionary, debesuotumasArray); } } } Window show = new Window("Dangus", WindowMode.FreeRatio); oroSalygos = oroSalygosFunc(debesuotumasArray.ToList().IndexOf(debesuotumasArray.Max())); if (tempDangus.Count > 0) { Skies sky = new Skies(); Point vieta = new Point(100, 100); Cv2.PutText(tempDangus[test].Image, oroSalygos, vieta, FontFace.Italic, 3, Scalar.Red, 5); show.Image = tempDangus[test].Image; WaitKey(); if (Console.ReadKey().KeyChar == 'a') { sky.getSkies(tempDangus[test].Mean, tempDangus[test].Variance, tempDangus[test].FileName, tempDangus[test].Energy, tempDangus[test].Entropy, tempDangus[test].Smoothness, oroSalygos); dangus.Add(sky); } else { Console.WriteLine("0: Debesuota, 1:Labai Debesuota, 2:Sauleta su debesimis, 3:Lengvai Debesuota, 4:Giedra"); string irasyta = Console.ReadLine(); int inSk = Int32.Parse(irasyta); oroSalygos = oroSalygosFunc(inSk); if (oroSalygos == "") { System.Environment.Exit(0); } sky.getSkies(tempDangus[test].Mean, tempDangus[test].Variance, tempDangus[test].FileName, tempDangus[test].Energy, tempDangus[test].Entropy, tempDangus[test].Smoothness, oroSalygos); dangus.Add(sky); } SerializeObject <List <Skies> >(dangus, @".\dangau.xml"); } else { System.Environment.Exit(1); } }
static void classMake(out List <Skies> dangus, string directory, Mat tempSky) { string[] files = Directory.GetFiles(directory); dangus = new List <Skies>(); Mat dangusPhoto = new Mat(); Mat bw = new Mat(); Mat[] dangusSplit = new Mat[3]; Mat dangusHSV = new Mat(); //Moments moments = new Moments(); string name = ""; double matching = 0; foreach (var file in files) { if (file.Contains("cloudy") && !file.Contains("verycloudy") && !file.Contains("partlycloudy")) { name = "Debesuota"; } else if (file.Contains("verycloudy")) { name = "Labai Debesuota"; } else if (file.Contains("partlycloudy")) { name = "Saulėta su debesimis"; } else if (file.Contains("lightcloud")) { name = "Lengvai debesuota"; } else if (file.Contains("clear")) { name = "Giedra"; } dangusPhoto = ImRead(file, LoadMode.Color); CvtColor(dangusPhoto, bw, ColorConversion.RgbToGray); CvtColor(dangusPhoto, dangusHSV, ColorConversion.RgbToHsv); Cv2.Split(dangusPhoto, out dangusSplit); float mean = 0; float variance = 0; float smoothness = 0; float energy = 0; float entropy = 0; for (int i = 0; i < 3; i++) { MeanStdDev(dangusSplit[i], out Scalar meanScalar, out Scalar varianceScalar); getStats(dangusSplit[i], (float)mean, (float)variance, out smoothness, out energy, out entropy); mean += (float)meanScalar[0]; variance += (float)varianceScalar[0]; smoothness += smoothness; energy += energy; entropy += entropy; } //matching = machingas(dangusPhoto, tempSky, 1); //moments = Moments(bw); Skies sky = new Skies(); sky.getSkies(mean, variance, file, energy, entropy, smoothness, name); dangus.Add(sky); GC.Collect(); } }