private void loader(object fileName) { try { int count = File.ReadAllLines(fileName.ToString()).Length; Bar_prog.Invoke(new Action(() => { Bar_prog.Maximum = count; })); using (StreamReader SR = new StreamReader(fileName.ToString())) { VectorsImage = new List <Vectors>(); while (!SR.EndOfStream) { string[] str = SR.ReadLine().Split(';'); Vectors vector = new Vectors(); vector.CounterWay = new int[8]; vector.CounterAngle = new int[3]; vector.CountPointsImage = int.Parse(str[0]); vector.CounterPointsContour = int.Parse(str[1]); vector.CounterWay[0] = int.Parse(str[2]); vector.CounterWay[1] = int.Parse(str[3]); vector.CounterWay[2] = int.Parse(str[4]); vector.CounterWay[3] = int.Parse(str[5]); vector.CounterWay[4] = int.Parse(str[6]); vector.CounterWay[5] = int.Parse(str[7]); vector.CounterWay[6] = int.Parse(str[8]); vector.CounterWay[7] = int.Parse(str[9]); vector.CounterLength = int.Parse(str[10]); vector.CounterAngle[0] = int.Parse(str[11]); vector.CounterAngle[1] = int.Parse(str[12]); vector.CounterAngle[2] = int.Parse(str[13]); vector.ClassImage = int.Parse(str[14]); VectorsImage.Add(vector); Bar_prog.Invoke(new Action(() => { Bar_prog.Value++; })); } } } catch (Exception ex) { MessageBox.Show("Не удалось загрузить!\r\n" + ex); } }
private void ImageAnaliz(object path1) { string path = path1.ToString(); if (path != String.Empty) { string[] pathFiles = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories); AttributeSearch attributeSearch = new AttributeSearch(); Bar_prog.Invoke(new Action(() => { Bar_prog.Maximum = pathFiles.Length; })); using (StreamWriter SW = new StreamWriter(path + @"\FilesInfo.txt", false)) { for (int i = 0; i < pathFiles.Length; i++) { Bitmap image = new Bitmap(pathFiles[i]); Vectors vector = new Vectors(); vector.ListPointsImage = attributeSearch.ListPointsImage(image); vector.CountPointsImage = attributeSearch.CounterPoints(image); vector.CounterPointsContour = attributeSearch.CounterPointsContour(vector.ListPointsImage); vector.CounterWay = attributeSearch.CounterWay(vector.ListPointsImage); vector.CounterLength = attributeSearch.CounterLength(vector.CounterWay); vector.CounterAngle = attributeSearch.CounterAngle(vector.ListPointsImage); string temp = pathFiles[i].Remove(0, path.Length + 1); if (temp.StartsWith("10")) { vector.ClassImage = 10; } else if (temp.StartsWith("2")) { vector.ClassImage = 2; } else if (temp.StartsWith("3")) { vector.ClassImage = 3; } else if (temp.StartsWith("4")) { vector.ClassImage = 4; } else if (temp.StartsWith("5")) { vector.ClassImage = 5; } else if (temp.StartsWith("6")) { vector.ClassImage = 6; } else if (temp.StartsWith("7")) { vector.ClassImage = 7; } else if (temp.StartsWith("8")) { vector.ClassImage = 8; } else if (temp.StartsWith("9")) { vector.ClassImage = 9; } else if (temp.StartsWith("1")) { vector.ClassImage = 1; } SW.WriteLine( +vector.CountPointsImage + ";" + vector.CounterPointsContour + ";" + vector.CounterWay[0] + ";" + vector.CounterWay[1] + ";" + vector.CounterWay[2] + ";" + vector.CounterWay[3] + ";" + vector.CounterWay[4] + ";" + vector.CounterWay[5] + ";" + vector.CounterWay[6] + ";" + vector.CounterWay[7] + ";" + vector.CounterLength + ";" + vector.CounterAngle[0] + ";" + vector.CounterAngle[1] + ";" + vector.CounterAngle[2] + ";" + vector.ClassImage ); Bar_prog.Invoke(new Action(() => { Bar_prog.Value = i + 1; })); } } } }