P066.Data/Form1.Designer.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
P066.Data/Form1.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
P066.Data/P066RunParam.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
P066.Data/Form1.Designer.cs
@@ -36,10 +36,9 @@ // // btnLoadData1 // this.btnLoadData1.Location = new System.Drawing.Point(16, 15); this.btnLoadData1.Margin = new System.Windows.Forms.Padding(4); this.btnLoadData1.Location = new System.Drawing.Point(12, 12); this.btnLoadData1.Name = "btnLoadData1"; this.btnLoadData1.Size = new System.Drawing.Size(176, 29); this.btnLoadData1.Size = new System.Drawing.Size(132, 23); this.btnLoadData1.TabIndex = 0; this.btnLoadData1.Text = "加载文件夹1"; this.btnLoadData1.UseVisualStyleBackColor = true; @@ -47,10 +46,9 @@ // // btnAnalyze // this.btnAnalyze.Location = new System.Drawing.Point(16, 88); this.btnAnalyze.Margin = new System.Windows.Forms.Padding(4); this.btnAnalyze.Location = new System.Drawing.Point(12, 70); this.btnAnalyze.Name = "btnAnalyze"; this.btnAnalyze.Size = new System.Drawing.Size(176, 29); this.btnAnalyze.Size = new System.Drawing.Size(132, 23); this.btnAnalyze.TabIndex = 1; this.btnAnalyze.Text = "开始分析"; this.btnAnalyze.UseVisualStyleBackColor = true; @@ -58,24 +56,22 @@ // // btnLoadData2 // this.btnLoadData2.Location = new System.Drawing.Point(16, 51); this.btnLoadData2.Margin = new System.Windows.Forms.Padding(4); this.btnLoadData2.Location = new System.Drawing.Point(12, 41); this.btnLoadData2.Name = "btnLoadData2"; this.btnLoadData2.Size = new System.Drawing.Size(176, 29); this.btnLoadData2.Size = new System.Drawing.Size(149, 23); this.btnLoadData2.TabIndex = 1; this.btnLoadData2.Text = "加载文件夹2"; this.btnLoadData2.Text = "刮伤、镀膜破损文件夹"; this.btnLoadData2.UseVisualStyleBackColor = true; this.btnLoadData2.Click += new System.EventHandler(this.btnLoadData2_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1067, 562); this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.btnAnalyze); this.Controls.Add(this.btnLoadData2); this.Controls.Add(this.btnLoadData1); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); P066.Data/Form1.cs
@@ -49,11 +49,13 @@ private void btnAnalyze_Click(object sender, EventArgs e) { var fileinfos11 = directoryInfo1.GetFiles(); var fileinfos22 = directoryInfo2.GetFiles(); var fileinfos11 = directoryInfo1.GetFiles().ToList().FindAll(a => a.Extension == ".csv"); ; List<FileInfo> fileInfo1 = new List<FileInfo>(); List<FileInfo> fileInfo2 = new List<FileInfo>(); for (int i = 0; i < fileinfos11.Length; i++) for (int i = 0; i < fileinfos11.Count; i++) { if (fileinfos11[i].Name.Contains("1_1") || fileinfos11[i].Name.Contains("2_1") || fileinfos11[i].Name.Contains("3_1") || fileinfos11[i].Name.Contains("4_1") ) { @@ -94,25 +96,15 @@ dataListSum22.Sort(); #endregion //如果需要合并表格就执行 for (int i = 0; i < fileinfos22.Length; i++) if (directoryInfo2 != null) { var fileinfos22 = directoryInfo2.GetFiles().ToList().FindAll(a=>a.Extension==".csv"); for (int i = 0; i < fileinfos22.Count; i++) { var allLines = File.ReadAllLines(fileinfos22[i].FullName, Encoding.Default); var list = GetData(allLines, GetDefactType(fileinfos22[i])).FindAll(a=>!a.Result); /*CompareFile(fileInfo1[i], fileInfo2[i],dataListSum22)*/ for (int ii = 0; ii < list.Count; ii++) { if (list[ii].Width > list[ii].Height) { list[ii].ex = list[ii].Width * 0.0043; } else { list[ii].ex = list[ii].Height * 0.0043; } } GetMaxSize(list); if (fileinfos22[i].Name.Contains("划伤")) { ScratchI++; @@ -125,12 +117,12 @@ ZoomI++; list.ForEach(a => a.Lensnumber = ZoomI); listSum.AddRange(list); } } directoryInfo2 = null; } @@ -231,19 +223,6 @@ } //不需要合并表格 //else if(fileInfo1.Count>0&& fileInfo2.Count==0) //{ // for (int i = 0; i < fileInfo1.Count; i++) // { // var allLines = File.ReadAllLines(fileInfo1[i].FullName, Encoding.Default); // var list = GetData(allLines,GetDefactType(fileInfo1[i])); /*CompareFile(fileInfo1[i], fileInfo2[i],dataListSum22)*/ // } //} #region//将设备判断结果输出到CSV报表中 var title12 = $"时间戳,相机序号,设备判断结果,缺陷类型,设备后处理结果,最大尺寸,位置,X,Y,R,角度"; var file12 = $"{directoryInfo1.Parent.FullName}\\{filenameDir + "设备判断结果"}.csv"; @@ -329,33 +308,13 @@ var list1 = dataList1.FindAll(a => a.TimeTip == item && !a.Result); var list2 = dataList2.FindAll(a => a.TimeTip == item && !a.Result); var itemToRemove = new List<ResultData>(); #region//计算表格2最大尺寸 for (int ii = 0; ii < list2.Count; ii++) { if (list2[ii].Width > list2[ii].Height) { list2[ii].ex = list2[ii].Width * 0.0043; } else { list2[ii].ex = list2[ii].Height * 0.0043; } } #endregion //计算表格1最大尺寸 GetMaxSize(list1); //计算表格2最大尺寸 GetMaxSize(list2); for (int i = 0; i < list1.Count; i++) { #region//计算表格1最大尺寸 if (list1[i].Width > list1[i].Height) { list1[i].ex = list1[i].Width * 0.0043; } else { list1[i].ex = list1[i].Height * 0.0043; } #endregion for (int j = 0; j < list2.Count; j++) { if (list1[i].JudgmentResult != list2[j].JudgmentResult) @@ -782,14 +741,14 @@ } } else if (Lens[0].DefectType == "划伤") else if (Lens[0].DefectType == "划伤"|| Lens[0].DefectType == "脏污") { var content11 = $"{item},{LensNumb},{Lens[0].JudgmentResult},{Lens[0].DefectType}"; File.AppendAllText(file12, content11, Encoding.UTF8); File.AppendAllText(file12, "\r\n"); for (int i = 0; i < Lens.Count; i++) { if (Lens[i].DefectType == "划伤") if (Lens[i].DefectType == "划伤"|| Lens[i].DefectType == "脏污") { var content111 = $"{""},{""},{""},{""},{""},{Lens[i].ex},{Lens[i].location},{Lens[i].X},{Lens[i].Y},{(int)(Lens[i].R)},{(int)(Lens[i].angle)}"; File.AppendAllText(file12, content111, Encoding.UTF8); @@ -853,6 +812,23 @@ { return Math.Atan2((y1 - size), (x1 - size)) * (180 / Math.PI); } //计算最大尺寸 private List<ResultData> GetMaxSize(List<ResultData> list) { for (int i = 0; i < list.Count; i++) { if (list[i].Width > list[i].Height) { list[i].ex = list[i].Width * 0.0043; } else { list[i].ex = list[i].Height * 0.0043; } } return list; } //获取文件名称并确定缺陷类型 @@ -888,6 +864,7 @@ var nametemp = allLines[1].Split(',')[0]; var resulttemp = allLines[1].Split(',')[1]; string Ptr = ""; string deTy = ""; for (int i = 1; i < allLines.Length; i++) { @@ -901,6 +878,7 @@ if (defectType == "白点") { data[10] = Ptr; deTy = "白点"; } @@ -908,14 +886,28 @@ if (defectType == "刮白") { Ptr = "刮白"; deTy = "刮白"; } else if (defectType == "划伤") { Ptr = "划伤"; Ptr = ""; if (data[3]!="OK") { deTy = data[3]; } else { deTy = ""; } } else if (defectType == "白点") { Ptr = data[10]; deTy = "白点"; } if (defectType== "镀膜破损") @@ -993,7 +985,7 @@ { TimeTip = data[0].Split('-')[0], ImageFileName = data[0], JudgmentResult = data[1]=="OK" ? "OK" :"NG", JudgmentResult = data[1]== "OK" ? "OK" :"NG", Result = data[3] == "OK", Probability = Convert.ToDouble(data[4]), Uncertainty = Convert.ToDouble(data[5]), @@ -1003,13 +995,14 @@ Width = Convert.ToDouble(data[7]), X = Convert.ToDouble(data[8].Replace("#", "").Replace("-", "")), Y = Convert.ToDouble(data[9].Replace("#", "").Replace("-", "")), DefectType = defectType, DefectType = deTy, PostTreatmentResults = Ptr, }); ; ; nametemp = data[0]; resulttemp = data[1]; //Ptr = data[10]; } P066.Data/P066RunParam.cs
@@ -26,4 +26,109 @@ public double BkLens4R1; //public double BkLens4R2; } public class P066ReadFile { public List<ResultData1> GetWhiteFile(string[] allLines) { var dataList = new List<ResultData1>(); var nametemp = allLines[1].Split(',')[0]; var resulttemp = allLines[1].Split(',')[1]; string Ptr = ""; string deTy = ""; for (int i = 1; i < allLines.Length; i++) { var data = allLines[i].Split(','); if (data[0] == "") { data[0] = nametemp; data[1] = resulttemp; } if (data[6] == "-") { dataList.Add(new ResultData1() { TimeTip = data[0].Split('-')[0], ImageFileName = data[0], JudgmentResult = data[1] == "OK" ? "OK" : "NG", Result = data[3] == "OK", }); ; ; continue; } //将地7、8列中选最大像素点 data[6] = SelectMaxPiont(data[6]); data[7] = SelectMaxPiont(data[7]); dataList.Add(new ResultData1() { TimeTip = data[0].Split('-')[0], ImageFileName = data[0], JudgmentResult = data[1] == "OK" ? "OK" : "NG", Result = data[3] == "OK", Probability = Convert.ToDouble(data[4]), Uncertainty = Convert.ToDouble(data[5]), //Height = Convert.ToDouble(data[6].Replace("#", "").Replace("-", "")), //Width = Convert.ToDouble(data[7].Replace("#", "").Replace("-", "")), Height = Convert.ToDouble(data[6]), Width = Convert.ToDouble(data[7]), X = Convert.ToDouble(data[8].Replace("#", "").Replace("-", "")), Y = Convert.ToDouble(data[9].Replace("#", "").Replace("-", "")), DefectType = deTy, PostTreatmentResults = Ptr, }); ; ; nametemp = data[0]; resulttemp = data[1]; } return dataList; } private string SelectMaxPiont(string Data) { var data = Data.Split('#').ToList(); data.Remove(""); var temp = Convert.ToInt32(data[0]); for (int i = 0; i < data.Count; i++) { if (Convert.ToInt32(data[i]) > temp) { temp = Convert.ToInt32(data[i]); } } return Convert.ToString(temp); } } public class ResultData1 { public string TimeTip = ""; public string JudgmentResult = ""; public string ImageFileName = ""; public bool Result = true; public int Lensnumber = 0; public double Probability = 0; public double Uncertainty = 0; public double Height = 0; public double Width = 0; public double X = 0; public double Y = 0; public double ex = 0; public string location = ""; public double angle = 0; public double R = 0; public string DefectType = ""; public string PostTreatmentResults = ""; } }