v1.0.2.10 加入模型裁边

This commit is contained in:
CPL 2024-08-05 09:39:58 +08:00
parent 4691fa5919
commit 96034ee3c0
32 changed files with 7939 additions and 301 deletions

View File

@ -20,7 +20,8 @@ namespace LeatherApp
public static JArray defectItemList; public static JArray defectItemList;
// //
public static JArray colorNameList;//, materialNameList; public static JArray colorNameList;//, materialNameList;
//
public static JArray materialNameList;//, materialNameList;
//CMDProcess目录下的命令JSON文件 //CMDProcess目录下的命令JSON文件
public static Dictionary<CMDName, JObject> CMDProcess; public static Dictionary<CMDName, JObject> CMDProcess;
@ -68,8 +69,22 @@ namespace LeatherApp
public static string ImagePath; public static string ImagePath;
public static bool IsSaveAllImage, IsSaveDefectSourceImage, IsSaveDefectCutImage; public static bool IsSaveAllImage, IsSaveDefectSourceImage, IsSaveDefectCutImage;
//材质Material //材质Material 1
public static string[] SuedeList = new string[0]; public static string[] SuedeList1 = new string[0];
//材质Material 2
public static string[] SuedeList2 = new string[0];
//材质Material 3
public static string[] SuedeList3 = new string[0];
//材质Material 4
public static string[] SuedeList4 = new string[0];
//材质Material 5
public static string[] SuedeList5 = new string[0];
//材质Material 6
public static string[] SuedeList6 = new string[0];
//忽略的等级判断项目
public static string[] SkipLabelGrade = new string[0];
//云端 //云端
public static string cloud_ip, cloud_username, cloud_password, CloudThisName; public static string cloud_ip, cloud_username, cloud_password, CloudThisName;
@ -96,7 +111,7 @@ namespace LeatherApp
LoadDefectItemList(); LoadDefectItemList();
LoadColorNameList(); LoadColorNameList();
//LoadMaterialNameList(); LoadMaterialNameList();
//---- //----
string lsCmdPath = appBasePath + "\\CMDProcess\\"; string lsCmdPath = appBasePath + "\\CMDProcess\\";
if (!Directory.Exists(lsCmdPath)) if (!Directory.Exists(lsCmdPath))
@ -162,7 +177,41 @@ namespace LeatherApp
// //
string lsTmp = ini.ReadString("Material", "SuedeList", "").Trim(); string lsTmp = ini.ReadString("Material", "SuedeList", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp)) if (!string.IsNullOrWhiteSpace(lsTmp))
SuedeList=lsTmp.Split(new char[] { ',',';'}); SuedeList1 = lsTmp.Split(new char[] { ',', ';' });
else
SuedeList1 = new string[1] { "" };
lsTmp = ini.ReadString("Material", "SuedeList2", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp))
SuedeList2 = lsTmp.Split(new char[] { ',', ';' });
else
SuedeList2 = new string[1] { "" };
lsTmp = ini.ReadString("Material", "SuedeList3", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp))
SuedeList3 = lsTmp.Split(new char[] { ',', ';' });
else
SuedeList3 = new string[1] { "" };
lsTmp = ini.ReadString("Material", "SuedeList4", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp))
SuedeList4 = lsTmp.Split(new char[] { ',', ';' });
else
SuedeList4 = new string[1] { "" };
lsTmp = ini.ReadString("Material", "SuedeList5", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp))
SuedeList5 = lsTmp.Split(new char[] { ',', ';' });
else
SuedeList5 = new string[1] { "" };
lsTmp = ini.ReadString("Material", "SuedeList6", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp))
SuedeList6 = lsTmp.Split(new char[] { ',', ';' });
else
SuedeList6 = new string[1] { "" };
lsTmp = ini.ReadString("SkipLabelGrade", "LabelGradeList", "").Trim();
if (!string.IsNullOrWhiteSpace(lsTmp))
SkipLabelGrade = lsTmp.Split(new char[] { ',', ';' });
else
SkipLabelGrade = new string[1] { "" };
} }
#region defectItemList <=> DefectItemList.json #region defectItemList <=> DefectItemList.json
@ -182,33 +231,58 @@ namespace LeatherApp
File.WriteAllText(configPath, newValue.ToString()); File.WriteAllText(configPath, newValue.ToString());
} }
public static JObject getDefectItem(string code) public static JObject getDefectItem(string code)
{
try
{ {
var item = Config.defectItemList.FirstOrDefault(m => m.Value<string>("code") == code); var item = Config.defectItemList.FirstOrDefault(m => m.Value<string>("code") == code);
if (item == null) if (item == null)
return null; return null;
return (JObject)item; return (JObject)item;
} }
catch { return null; }
}
public static JObject getDefectItem(int id) public static JObject getDefectItem(int id)
{
try
{ {
var item = Config.defectItemList.FirstOrDefault(m => m.Value<int>("id") == id); var item = Config.defectItemList.FirstOrDefault(m => m.Value<int>("id") == id);
if (item == null) if (item == null)
return null; return null;
return (JObject)item; return (JObject)item;
} }
catch { return null; }
}
public static string getDefectCode(int id) public static string getDefectCode(int id)
{
try
{ {
var item = Config.defectItemList.FirstOrDefault(m => m.Value<int>("id") == id); var item = Config.defectItemList.FirstOrDefault(m => m.Value<int>("id") == id);
if (item == null) if (item == null)
return ""; return "";
return ((JObject)item).Value<string>("code"); return ((JObject)item).Value<string>("code");
} }
catch { return ""; }
}
public static string getDefectName(string code) public static string getDefectName(string code)
{ {
try {
var item = Config.defectItemList.FirstOrDefault(m => m.Value<string>("code") == code); var item = Config.defectItemList.FirstOrDefault(m => m.Value<string>("code") == code);
if (item == null) if (item == null)
return ""; return "";
return ((JObject)item).Value<string>("name"); return ((JObject)item).Value<string>("name");
} }
catch { return ""; }
}
public static string getDefectCode(string name)
{
try {
var item = Config.defectItemList.FirstOrDefault(m => m.Value<string>("name") == name);
if (item == null)
return "";
return ((JObject)item).Value<string>("code");
}
catch { return ""; }
}
#endregion #endregion
#region colorNameList <=> ColorNameList.json #region colorNameList <=> ColorNameList.json
@ -227,14 +301,14 @@ namespace LeatherApp
return null; return null;
return (JObject)item; return (JObject)item;
} }
//public static void LoadMaterialNameList() public static void LoadMaterialNameList()
//{ {
// if (string.IsNullOrWhiteSpace(appBasePath)) if (string.IsNullOrWhiteSpace(appBasePath))
// appBasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); appBasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// string configPath = appBasePath + "\\MaterialName.json"; string configPath = appBasePath + "\\MaterialName.json";
// string lsTmp = File.ReadAllText(configPath); string lsTmp = File.ReadAllText(configPath);
// materialNameList = JArray.Parse(lsTmp); materialNameList = JArray.Parse(lsTmp);
//} }
//public static JObject getMaterialItem(string code) //public static JObject getMaterialItem(string code)
//{ //{
// var item = Config.materialNameList.FirstOrDefault(m => m.Value<string>("code") == code); // var item = Config.materialNameList.FirstOrDefault(m => m.Value<string>("code") == code);

View File

@ -107,6 +107,12 @@ namespace LeatherApp
if (!Config.StopLight && !devLight.start(int.Parse(Config.Light_PortName.Substring(3)))) throw new Exception("光源设备初始化失败!"); if (!Config.StopLight && !devLight.start(int.Parse(Config.Light_PortName.Substring(3)))) throw new Exception("光源设备初始化失败!");
if (!libPhoto.start()) throw new Exception("图像库初始化失败!"); if (!libPhoto.start()) throw new Exception("图像库初始化失败!");
WarningEvent?.Invoke(DateTime.Now,WarningEnum.Normal, "2"); WarningEvent?.Invoke(DateTime.Now,WarningEnum.Normal, "2");
if (libDefect == null)
{
WarningEvent?.Invoke(DateTime.Now, WarningEnum.Normal, "算法库为空,重新初始化");
libDefect = new DefectLib();
libDefect.WarningEvent = WarningEvent;
}
if (!libDefect.start()) throw new Exception("缺陷库初始化失败!"); if (!libDefect.start()) throw new Exception("缺陷库初始化失败!");
WarningEvent?.Invoke(DateTime.Now,WarningEnum.Normal, "3"); WarningEvent?.Invoke(DateTime.Now,WarningEnum.Normal, "3");
if (!File.Exists(appBasePath+ "\\DevCfg\\" + Config.Carmer1ConfigFilePath) || !File.Exists(appBasePath + "\\DevCfg\\" + Config.Carmer2ConfigFilePath)) if (!File.Exists(appBasePath+ "\\DevCfg\\" + Config.Carmer1ConfigFilePath) || !File.Exists(appBasePath + "\\DevCfg\\" + Config.Carmer2ConfigFilePath))

View File

@ -610,13 +610,14 @@ namespace LeatherApp.Device
CopyMemory(m_pUserBuffer, hPtr, m_nBufferSize); CopyMemory(m_pUserBuffer, hPtr, m_nBufferSize);
m_bUpdateImage = true; m_bUpdateImage = true;
var bmp = hBuffer.toBmp(m_pUserBuffer); Mat mat = new Mat(m_nHeight, m_nWidth, MatType.CV_8UC3, m_pUserBuffer);
Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bmp); //var bmp = hBuffer.toBmp(m_pUserBuffer);
bmp.Dispose(); //Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bmp);
bmp = null; //bmp.Dispose();
//bmp = null;
//Monitor.Enter(frameQueue); //Monitor.Enter(frameQueue);
lock (frameQueue) lock (frameQueue)
frameQueue.Enqueue(new MyData(index, mat)); frameQueue.Enqueue(new MyData(index, mat.Clone()));
PhotoNumCacheEvent?.BeginInvoke(frameQueue.Count, null, null); PhotoNumCacheEvent?.BeginInvoke(frameQueue.Count, null, null);
} }
} }

View File

@ -98,17 +98,17 @@ namespace LeatherApp.Device
} }
public bool start() public bool start()
{ {
List<DefectLabelInfo> DefectLabelInfoList = new List<DefectLabelInfo>(); //List<DefectLabelInfo> DefectLabelInfoList = new List<DefectLabelInfo>();
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 1953, y = 429, w = 200, h = 200, classId = 1, confidence = 0.8, contrast = 0.9, i = 0, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 1953, y = 429, w = 200, h = 200, classId = 1, confidence = 0.8, contrast = 0.9, i = 0, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() {x = 1953,y = 929,w=900,h = 400,classId = 11,confidence = 0.8, contrast = 0.9, i = 0,j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() {x = 1953,y = 929,w=900,h = 400,classId = 11,confidence = 0.8, contrast = 0.9, i = 0,j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 3169, y = 1029, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 1, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 3169, y = 1029, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 1, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 4721, y = 919, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 2, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 4721, y = 919, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 2, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 6145, y = 829, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 3, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 6145, y = 829, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 3, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 8073, y = 929, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 4, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 8073, y = 929, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 4, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 9407, y = 929, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 5, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 9407, y = 929, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 5, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 10801, y = 999, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 6, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 10801, y = 999, w = 900, h = 400, classId = 11, confidence = 0.8, contrast = 0.9, i = 6, j = 0 });
DefectLabelInfoList.Add(new DefectLabelInfo() { x = 12465, y = 629, w = 900, h = 800, classId = 11, confidence = 0.8, contrast = 0.9, i = 7, j = 0 }); //DefectLabelInfoList.Add(new DefectLabelInfo() { x = 12465, y = 629, w = 900, h = 800, classId = 11, confidence = 0.8, contrast = 0.9, i = 7, j = 0 });
DefectLabelInfoList = HeBingDefect(16384, DefectLabelInfoList); //DefectLabelInfoList = HeBingDefect(16384, DefectLabelInfoList);
try try
{ {
//detector = CreateDetector(Config.model_path, Config.labels_path, true, 6); //detector = CreateDetector(Config.model_path, Config.labels_path, true, 6);
@ -190,6 +190,7 @@ namespace LeatherApp.Device
public int GetWidthForResize(int sumWidth) public int GetWidthForResize(int sumWidth)
{ {
int count =(int) Math.Round(sumWidth * 1.0f / image_width, 0); int count =(int) Math.Round(sumWidth * 1.0f / image_width, 0);
count = 8;
return count * image_width; return count * image_width;
//int count = sumWidth / image_width; //int count = sumWidth / image_width;
@ -244,7 +245,7 @@ namespace LeatherApp.Device
{ {
if (taskList.Count < 1) if (taskList.Count < 1)
{ {
Thread.Sleep(0); Thread.Sleep(20);
continue; continue;
} }
@ -325,7 +326,7 @@ namespace LeatherApp.Device
{ {
if (taskOperationList.Count < 1) if (taskOperationList.Count < 1)
{ {
Thread.Sleep(0); Thread.Sleep(20);
continue; continue;
} }
@ -454,6 +455,17 @@ namespace LeatherApp.Device
List<int> xPos2 = new List<int>(); List<int> xPos2 = new List<int>();
List<double> ZXD2 = new List<double>(); List<double> ZXD2 = new List<double>();
List<DefectLabelInfo> HeBingList3 = new List<DefectLabelInfo>();
List<DefectLabelInfo> XcHeBingList3 = new List<DefectLabelInfo>();
List<int> xPos3 = new List<int>();
List<double> ZXD3 = new List<double>();
List<DefectLabelInfo> HeBingList4 = new List<DefectLabelInfo>();
List<DefectLabelInfo> XcHeBingList4 = new List<DefectLabelInfo>();
List<int> xPos4 = new List<int>();
List<double> ZXD4 = new List<double>();
DefectLabelInfo stpoint = DefectLabelInfoList[0]; DefectLabelInfo stpoint = DefectLabelInfoList[0];
int colNum = Width / image_width; int colNum = Width / image_width;
@ -467,7 +479,7 @@ namespace LeatherApp.Device
if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max) if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max)
{ {
HeBingList.Add(DefectLabelInfoList[q]); HeBingList.Add(DefectLabelInfoList[q]);
xPos.Add(DefectLabelInfoList[q].x); xPos.Add((DefectLabelInfoList[q].i % colNum) * image_width + DefectLabelInfoList[q].x);
ZXD.Add(DefectLabelInfoList[q].confidence); ZXD.Add(DefectLabelInfoList[q].confidence);
} }
else else
@ -480,29 +492,60 @@ namespace LeatherApp.Device
if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max) if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max)
{ {
HeBingList2.Add(DefectLabelInfoList[q]); HeBingList2.Add(DefectLabelInfoList[q]);
xPos2.Add(DefectLabelInfoList[q].x); xPos2.Add((DefectLabelInfoList[q].i % colNum) * image_width + DefectLabelInfoList[q].x);
ZXD2.Add(DefectLabelInfoList[q].confidence); ZXD2.Add(DefectLabelInfoList[q].confidence);
} }
else else
XcHeBingList2.Add(DefectLabelInfoList[q]); XcHeBingList2.Add(DefectLabelInfoList[q]);
} }
else if (Config.getDefectCode(DefectLabelInfoList[q].classId) == "jt")
{
int max = stpoint.y + 500;
int min = stpoint.y - 500 > 0 ? stpoint.y - 500 : 0;
if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max)
{
HeBingList3.Add(DefectLabelInfoList[q]);
xPos3.Add((DefectLabelInfoList[q].i % colNum) * image_width + DefectLabelInfoList[q].x);
ZXD3.Add(DefectLabelInfoList[q].confidence);
}
else
XcHeBingList3.Add(DefectLabelInfoList[q]);
}
else if (Config.getDefectCode(DefectLabelInfoList[q].classId) == "tcy")
{
int max = stpoint.y + 500;
int min = stpoint.y - 500 > 0 ? stpoint.y - 500 : 0;
if (DefectLabelInfoList[q].y >= min && DefectLabelInfoList[q].y <= max)
{
HeBingList4.Add(DefectLabelInfoList[q]);
xPos4.Add((DefectLabelInfoList[q].i % colNum) * image_width + DefectLabelInfoList[q].x);
ZXD4.Add(DefectLabelInfoList[q].confidence);
}
else
XcHeBingList4.Add(DefectLabelInfoList[q]);
}
else else
outList.Add(DefectLabelInfoList[q]); outList.Add(DefectLabelInfoList[q]);
} }
//递归下次合并数据 //递归下次合并数据
List<DefectLabelInfo> dg1 = new List<DefectLabelInfo>(); List<DefectLabelInfo> dg1 = new List<DefectLabelInfo>();
List<DefectLabelInfo> dg2 = new List<DefectLabelInfo>(); List<DefectLabelInfo> dg2 = new List<DefectLabelInfo>();
List<DefectLabelInfo> dg3 = new List<DefectLabelInfo>();
List<DefectLabelInfo> dg4 = new List<DefectLabelInfo>();
if (XcHeBingList.Count >0) if (XcHeBingList.Count >0)
dg1 = HeBingDefect(Width, XcHeBingList); dg1 = HeBingDefect(Width, XcHeBingList);
if (XcHeBingList2.Count > 0) if (XcHeBingList2.Count > 0)
dg2 = HeBingDefect(Width, XcHeBingList2); dg2 = HeBingDefect(Width, XcHeBingList2);
if (XcHeBingList3.Count > 0)
dg3 = HeBingDefect(Width, XcHeBingList3);
if (XcHeBingList4.Count > 0)
dg4 = HeBingDefect(Width, XcHeBingList4);
//多个jietou合并 //多个jietou合并
if (HeBingList.Count>0) if (HeBingList.Count>0)
{ {
var stIt = HeBingList.Find(x => x.x == xPos.Min()); var stIt = HeBingList.Find(x => (x.i % colNum) * image_width + x.x == xPos.Min());
var edIt = HeBingList.Find(x => x.x == xPos.Max()); var edIt = HeBingList.Find(x => (x.i % colNum) * image_width + x.x == xPos.Max());
var eZXD = HeBingList.Find(x => x.confidence == ZXD.Max()); var eZXD = HeBingList.Find(x => x.confidence == ZXD.Max());
int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w; int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w;
outList.Add(new DefectLabelInfo() { outList.Add(new DefectLabelInfo() {
@ -522,8 +565,8 @@ namespace LeatherApp.Device
//多个hengdang合并 //多个hengdang合并
if (HeBingList2.Count > 0) if (HeBingList2.Count > 0)
{ {
var stIt = HeBingList2.Find(x => x.x == xPos2.Min()); var stIt = HeBingList2.Find(x => (x.i % colNum) * image_width + x.x == xPos2.Min());
var edIt = HeBingList2.Find(x => x.x == xPos2.Max()); var edIt = HeBingList2.Find(x => (x.i % colNum) * image_width + x.x == xPos2.Max());
var eZXD = HeBingList2.Find(x => x.confidence == ZXD2.Max()); var eZXD = HeBingList2.Find(x => x.confidence == ZXD2.Max());
int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w; int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w;
outList.Add(new DefectLabelInfo() outList.Add(new DefectLabelInfo()
@ -541,9 +584,54 @@ namespace LeatherApp.Device
j = stIt.j, j = stIt.j,
}); });
} }
//多个jt合并
if (HeBingList3.Count > 0)
{
var stIt = HeBingList3.Find(x => (x.i % colNum) * image_width + x.x == xPos3.Min());
var edIt = HeBingList3.Find(x => (x.i % colNum) * image_width + x.x == xPos3.Max());
var eZXD = HeBingList3.Find(x => x.confidence == ZXD3.Max());
int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w;
outList.Add(new DefectLabelInfo()
{
x = stIt.x,
y = edIt.y,
w = newW, //多图叠加
h = edIt.h,
classId = eZXD.classId,
confidence = eZXD.confidence,
contrast = eZXD.contrast,
cmH = Math.Round(edIt.h * 1.0 / Config.cm2px_y, 2),
cmW = Math.Round(newW * 1.0 / Config.cm2px_x, 2),
i = stIt.i,
j = stIt.j,
});
}
//多个tcy合并
if (HeBingList4.Count > 0)
{
var stIt = HeBingList4.Find(x => (x.i % colNum) * image_width + x.x == xPos4.Min());
var edIt = HeBingList4.Find(x => (x.i % colNum) * image_width + x.x == xPos4.Max());
var eZXD = HeBingList4.Find(x => x.confidence == ZXD4.Max());
int newW = Math.Abs(((edIt.i % colNum) * image_width + edIt.x) - ((stIt.i % colNum) * image_width + stIt.x)) + edIt.w;
outList.Add(new DefectLabelInfo()
{
x = stIt.x,
y = edIt.y,
w = newW, //多图叠加
h = edIt.h,
classId = eZXD.classId,
confidence = eZXD.confidence,
contrast = eZXD.contrast,
cmH = Math.Round(edIt.h * 1.0 / Config.cm2px_y, 2),
cmW = Math.Round(newW * 1.0 / Config.cm2px_x, 2),
i = stIt.i,
j = stIt.j,
});
}
outList = outList.Concat(dg1).ToList<DefectLabelInfo>();//保留重复项 outList = outList.Concat(dg1).ToList<DefectLabelInfo>();//保留重复项
outList = outList.Concat(dg2).ToList<DefectLabelInfo>();//保留重复项 outList = outList.Concat(dg2).ToList<DefectLabelInfo>();//保留重复项
outList = outList.Concat(dg3).ToList<DefectLabelInfo>();//保留重复项
outList = outList.Concat(dg4).ToList<DefectLabelInfo>();//保留重复项
return outList; return outList;
} }
//打标 //打标
@ -554,7 +642,7 @@ namespace LeatherApp.Device
{ {
if (taskMakeTagList.Count < 1) if (taskMakeTagList.Count < 1)
{ {
Thread.Sleep(0); Thread.Sleep(20);
continue; continue;
} }
@ -743,7 +831,7 @@ namespace LeatherApp.Device
} }
#region #region
liStep++; liStep = 3000;
if (DefectLabelInfoList.Count >0) if (DefectLabelInfoList.Count >0)
DefectLabelInfoList = HeBingDefect(task.bmp.Width, DefectLabelInfoList); DefectLabelInfoList = HeBingDefect(task.bmp.Width, DefectLabelInfoList);
liStep++; liStep++;
@ -806,6 +894,11 @@ namespace LeatherApp.Device
task.resultInfo += $" 判断为接头处横档,跳过! \n"; task.resultInfo += $" 判断为接头处横档,跳过! \n";
continue; continue;
} }
if (Config.getDefectCode(DefectLabelInfoListByClassID[q].classId) == "na")
{
task.resultInfo += $" 判断为正向标签na跳过 \n";
continue;
}
//WarningEvent?.Invoke(DateTime.Now,WarningEnum.Low, $"判断是瑕疵类别ID:{classId} 置信度({confidence},[{qualifiedLimit.ZXD}]); isOr({qualifiedLimit.IsOR}); 面积({cmW * cmH},[{ qualifiedLimit.Area}]); 对比度({contrast},[{qualifiedLimit.ContrastLower}-{qualifiedLimit.ContrastTop}])"); //WarningEvent?.Invoke(DateTime.Now,WarningEnum.Low, $"判断是瑕疵类别ID:{classId} 置信度({confidence},[{qualifiedLimit.ZXD}]); isOr({qualifiedLimit.IsOR}); 面积({cmW * cmH},[{ qualifiedLimit.Area}]); 对比度({contrast},[{qualifiedLimit.ContrastLower}-{qualifiedLimit.ContrastTop}])");
} }
} }
@ -815,7 +908,7 @@ namespace LeatherApp.Device
var point2 = new OpenCvSharp.Point(point1.X + DefectLabelInfoListByClassID[q].w, point1.Y + DefectLabelInfoListByClassID[q].h); var point2 = new OpenCvSharp.Point(point1.X + DefectLabelInfoListByClassID[q].w, point1.Y + DefectLabelInfoListByClassID[q].h);
liStep++;//2 liStep++;//2
//task.resultInfo += $" 转换到大图坐标(px)p1={point1.X},{point1.Y}; p2={point2.X},{point2.Y}\n"; //task.resultInfo += $" 转换到大图坐标(px)p1={point1.X},{point1.Y}; p2={point2.X},{point2.Y}\n";
Cv2.Rectangle(task.bmpTag, point1, point2, new Scalar(0.0, 0.0, 255.0), 1);//画打标点 Cv2.Rectangle(task.bmpTag, point1, point2, new Scalar(0.0, 0.0, 255.0), 5);//画打标点
//WarningEvent?.Invoke(DateTime.Now,WarningEnum.Low, $"保存第 {count} 行缺陷信息;"); //WarningEvent?.Invoke(DateTime.Now,WarningEnum.Low, $"保存第 {count} 行缺陷信息;");
int px = (point1.X - task.xw) > 0 ? (point1.X - task.xw) : 0; int px = (point1.X - task.xw) > 0 ? (point1.X - task.xw) : 0;

View File

@ -118,7 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="textBox1.Text" xml:space="preserve"> <data name="textBox1.Text" xml:space="preserve">
<value>v1.0.2.9(2024-05-09) <value>v1.0.2.10(2024-08-05)
1、修复bug优化显示
2、加入模型裁边
v1.0.2.9(2024-05-09)
1、加入实时幅宽 1、加入实时幅宽
2、加入jietouhengdang标签合并 2、加入jietouhengdang标签合并
v1.0.2.8(2024-05-06) v1.0.2.8(2024-05-06)

View File

@ -28,14 +28,14 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
this.uiPanel1 = new Sunny.UI.UIPanel(); this.uiPanel1 = new Sunny.UI.UIPanel();
this.lblLen = new Sunny.UI.UILabel(); this.lblLen = new Sunny.UI.UILabel();
this.lblSpeed = new Sunny.UI.UISymbolLabel(); this.lblSpeed = new Sunny.UI.UISymbolLabel();
@ -58,7 +58,6 @@
this.btnEnd = new Sunny.UI.UISymbolButton(); this.btnEnd = new Sunny.UI.UISymbolButton();
this.btnStart = new Sunny.UI.UISymbolButton(); this.btnStart = new Sunny.UI.UISymbolButton();
this.uiTitlePanel2 = new Sunny.UI.UITitlePanel(); this.uiTitlePanel2 = new Sunny.UI.UITitlePanel();
this.ucColorListDefect = new LeatherApp.UIExtend.UCColorList();
this.lineChartDefect = new Sunny.UI.UILineChart(); this.lineChartDefect = new Sunny.UI.UILineChart();
this.uiTitlePanel3 = new Sunny.UI.UITitlePanel(); this.uiTitlePanel3 = new Sunny.UI.UITitlePanel();
this.uiDataGridView1 = new Sunny.UI.UIDataGridView(); this.uiDataGridView1 = new Sunny.UI.UIDataGridView();
@ -81,7 +80,6 @@
this.lstboxLog = new Sunny.UI.UIListBox(); this.lstboxLog = new Sunny.UI.UIListBox();
this.uiTitlePanel6 = new Sunny.UI.UITitlePanel(); this.uiTitlePanel6 = new Sunny.UI.UITitlePanel();
this.uiPanel3 = new Sunny.UI.UIPanel(); this.uiPanel3 = new Sunny.UI.UIPanel();
this.picDefectImage = new LeatherApp.UIExtend.UCImageView();
this.pnlScannerImg = new Sunny.UI.UITitlePanel(); this.pnlScannerImg = new Sunny.UI.UITitlePanel();
this.picScanner2 = new System.Windows.Forms.PictureBox(); this.picScanner2 = new System.Windows.Forms.PictureBox();
this.picScanner1 = new System.Windows.Forms.PictureBox(); this.picScanner1 = new System.Windows.Forms.PictureBox();
@ -100,6 +98,8 @@
this.uiLabel8 = new Sunny.UI.UILabel(); this.uiLabel8 = new Sunny.UI.UILabel();
this.uiLabel7 = new Sunny.UI.UILabel(); this.uiLabel7 = new Sunny.UI.UILabel();
this.uiLabel6 = new Sunny.UI.UILabel(); this.uiLabel6 = new Sunny.UI.UILabel();
this.picDefectImage = new LeatherApp.UIExtend.UCImageView();
this.ucColorListDefect = new LeatherApp.UIExtend.UCColorList();
this.uiPanel1.SuspendLayout(); this.uiPanel1.SuspendLayout();
this.uiTitlePanel1.SuspendLayout(); this.uiTitlePanel1.SuspendLayout();
this.uiPanel2.SuspendLayout(); this.uiPanel2.SuspendLayout();
@ -448,7 +448,6 @@
this.button1.TabIndex = 1; this.button1.TabIndex = 1;
this.button1.Text = "button1"; this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Visible = false;
this.button1.Click += new System.EventHandler(this.button1_Click); this.button1.Click += new System.EventHandler(this.button1_Click);
// //
// btnPause // btnPause
@ -633,29 +632,6 @@
this.uiTitlePanel2.TitleColor = System.Drawing.Color.White; this.uiTitlePanel2.TitleColor = System.Drawing.Color.White;
this.uiTitlePanel2.TitleForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(29)))), ((int)(((byte)(138))))); this.uiTitlePanel2.TitleForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(29)))), ((int)(((byte)(138)))));
// //
// ucColorListDefect
//
this.ucColorListDefect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ucColorListDefect.ColorChanged = null;
this.ucColorListDefect.FillColor = System.Drawing.Color.White;
this.ucColorListDefect.FillColor2 = System.Drawing.Color.White;
this.ucColorListDefect.FillDisableColor = System.Drawing.Color.White;
this.ucColorListDefect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ucColorListDefect.Location = new System.Drawing.Point(1, 38);
this.ucColorListDefect.MinimumSize = new System.Drawing.Size(1, 1);
this.ucColorListDefect.Name = "ucColorListDefect";
this.ucColorListDefect.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.ucColorListDefect.RectColor = System.Drawing.Color.White;
this.ucColorListDefect.RectDisableColor = System.Drawing.Color.White;
this.ucColorListDefect.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom;
this.ucColorListDefect.Size = new System.Drawing.Size(121, 42);
this.ucColorListDefect.Style = Sunny.UI.UIStyle.Custom;
this.ucColorListDefect.StyleCustomMode = true;
this.ucColorListDefect.TabIndex = 1;
this.ucColorListDefect.Text = "ucColorList1";
this.ucColorListDefect.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
//
// lineChartDefect // lineChartDefect
// //
this.lineChartDefect.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.lineChartDefect.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -705,21 +681,21 @@
// //
// uiDataGridView1 // uiDataGridView1
// //
dataGridViewCellStyle9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250))))); dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
this.uiDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle9; this.uiDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.uiDataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.uiDataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.uiDataGridView1.BackgroundColor = System.Drawing.Color.White; this.uiDataGridView1.BackgroundColor = System.Drawing.Color.White;
this.uiDataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.uiDataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle10.BackColor = System.Drawing.Color.Blue; dataGridViewCellStyle2.BackColor = System.Drawing.Color.Blue;
dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle10.ForeColor = System.Drawing.Color.White; dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(29)))), ((int)(((byte)(138))))); dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(29)))), ((int)(((byte)(138)))));
dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.uiDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle10; this.uiDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.uiDataGridView1.ColumnHeadersHeight = 32; this.uiDataGridView1.ColumnHeadersHeight = 32;
this.uiDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.uiDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.uiDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.uiDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
@ -734,14 +710,14 @@
this.colArea, this.colArea,
this.colZXD, this.colZXD,
this.colTarget}); this.colTarget});
dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle14.BackColor = System.Drawing.Color.White; dataGridViewCellStyle6.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); dataGridViewCellStyle6.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle14.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238))))); dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238)))));
dataGridViewCellStyle14.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.False; dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.uiDataGridView1.DefaultCellStyle = dataGridViewCellStyle14; this.uiDataGridView1.DefaultCellStyle = dataGridViewCellStyle6;
this.uiDataGridView1.EnableHeadersVisualStyles = false; this.uiDataGridView1.EnableHeadersVisualStyles = false;
this.uiDataGridView1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiDataGridView1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiDataGridView1.GridColor = System.Drawing.Color.CornflowerBlue; this.uiDataGridView1.GridColor = System.Drawing.Color.CornflowerBlue;
@ -749,21 +725,21 @@
this.uiDataGridView1.MultiSelect = false; this.uiDataGridView1.MultiSelect = false;
this.uiDataGridView1.Name = "uiDataGridView1"; this.uiDataGridView1.Name = "uiDataGridView1";
this.uiDataGridView1.RectColor = System.Drawing.Color.DodgerBlue; this.uiDataGridView1.RectColor = System.Drawing.Color.DodgerBlue;
dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle15.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250))))); dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); dataGridViewCellStyle7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(29)))), ((int)(((byte)(138))))); dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(29)))), ((int)(((byte)(138)))));
dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); dataGridViewCellStyle7.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.uiDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle15; this.uiDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle7;
this.uiDataGridView1.RowHeadersWidth = 62; this.uiDataGridView1.RowHeadersWidth = 62;
dataGridViewCellStyle16.BackColor = System.Drawing.Color.White; dataGridViewCellStyle8.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle16.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle16.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238))))); dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(242)))), ((int)(((byte)(238)))));
dataGridViewCellStyle16.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle16; this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle8;
this.uiDataGridView1.RowTemplate.Height = 30; this.uiDataGridView1.RowTemplate.Height = 30;
this.uiDataGridView1.ScrollBarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250))))); this.uiDataGridView1.ScrollBarBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(251)))), ((int)(((byte)(250)))));
this.uiDataGridView1.ScrollBarColor = System.Drawing.Color.DodgerBlue; this.uiDataGridView1.ScrollBarColor = System.Drawing.Color.DodgerBlue;
@ -814,9 +790,9 @@
// colX // colX
// //
this.colX.DataPropertyName = "X"; this.colX.DataPropertyName = "X";
dataGridViewCellStyle11.Format = "N1"; dataGridViewCellStyle3.Format = "N1";
dataGridViewCellStyle11.NullValue = null; dataGridViewCellStyle3.NullValue = null;
this.colX.DefaultCellStyle = dataGridViewCellStyle11; this.colX.DefaultCellStyle = dataGridViewCellStyle3;
this.colX.HeaderText = "X(cm)"; this.colX.HeaderText = "X(cm)";
this.colX.MinimumWidth = 8; this.colX.MinimumWidth = 8;
this.colX.Name = "colX"; this.colX.Name = "colX";
@ -826,9 +802,9 @@
// colY // colY
// //
this.colY.DataPropertyName = "Y"; this.colY.DataPropertyName = "Y";
dataGridViewCellStyle12.Format = "N2"; dataGridViewCellStyle4.Format = "N2";
dataGridViewCellStyle12.NullValue = null; dataGridViewCellStyle4.NullValue = null;
this.colY.DefaultCellStyle = dataGridViewCellStyle12; this.colY.DefaultCellStyle = dataGridViewCellStyle4;
this.colY.HeaderText = "Y(米)"; this.colY.HeaderText = "Y(米)";
this.colY.MinimumWidth = 8; this.colY.MinimumWidth = 8;
this.colY.Name = "colY"; this.colY.Name = "colY";
@ -851,9 +827,9 @@
// //
// colArea // colArea
// //
dataGridViewCellStyle13.Format = "N2"; dataGridViewCellStyle5.Format = "N2";
dataGridViewCellStyle13.NullValue = null; dataGridViewCellStyle5.NullValue = null;
this.colArea.DefaultCellStyle = dataGridViewCellStyle13; this.colArea.DefaultCellStyle = dataGridViewCellStyle5;
this.colArea.HeaderText = "面积(mm²)"; this.colArea.HeaderText = "面积(mm²)";
this.colArea.MinimumWidth = 8; this.colArea.MinimumWidth = 8;
this.colArea.Name = "colArea"; this.colArea.Name = "colArea";
@ -1062,15 +1038,6 @@
this.uiPanel3.Text = null; this.uiPanel3.Text = null;
this.uiPanel3.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; this.uiPanel3.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
// //
// picDefectImage
//
this.picDefectImage.Dock = System.Windows.Forms.DockStyle.Fill;
this.picDefectImage.Location = new System.Drawing.Point(0, 0);
this.picDefectImage.Margin = new System.Windows.Forms.Padding(0);
this.picDefectImage.Name = "picDefectImage";
this.picDefectImage.Size = new System.Drawing.Size(350, 226);
this.picDefectImage.TabIndex = 1;
//
// pnlScannerImg // pnlScannerImg
// //
this.pnlScannerImg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.pnlScannerImg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -1359,6 +1326,38 @@
this.uiLabel6.Text = "光源"; this.uiLabel6.Text = "光源";
this.uiLabel6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.uiLabel6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// picDefectImage
//
this.picDefectImage.Dock = System.Windows.Forms.DockStyle.Fill;
this.picDefectImage.Location = new System.Drawing.Point(0, 0);
this.picDefectImage.Margin = new System.Windows.Forms.Padding(0);
this.picDefectImage.Name = "picDefectImage";
this.picDefectImage.Size = new System.Drawing.Size(350, 226);
this.picDefectImage.TabIndex = 1;
//
// ucColorListDefect
//
this.ucColorListDefect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ucColorListDefect.ColorChanged = null;
this.ucColorListDefect.FillColor = System.Drawing.Color.White;
this.ucColorListDefect.FillColor2 = System.Drawing.Color.White;
this.ucColorListDefect.FillDisableColor = System.Drawing.Color.White;
this.ucColorListDefect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ucColorListDefect.Location = new System.Drawing.Point(1, 38);
this.ucColorListDefect.MinimumSize = new System.Drawing.Size(1, 1);
this.ucColorListDefect.Name = "ucColorListDefect";
this.ucColorListDefect.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.ucColorListDefect.RectColor = System.Drawing.Color.White;
this.ucColorListDefect.RectDisableColor = System.Drawing.Color.White;
this.ucColorListDefect.RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom;
this.ucColorListDefect.Size = new System.Drawing.Size(121, 42);
this.ucColorListDefect.Style = Sunny.UI.UIStyle.Custom;
this.ucColorListDefect.StyleCustomMode = true;
this.ucColorListDefect.TabIndex = 1;
this.ucColorListDefect.Text = "ucColorList1";
this.ucColorListDefect.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
//
// FHome // FHome
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@ -1382,6 +1381,8 @@
this.StyleCustomMode = true; this.StyleCustomMode = true;
this.Load += new System.EventHandler(this.FHome_Load); this.Load += new System.EventHandler(this.FHome_Load);
this.Shown += new System.EventHandler(this.FHome_Shown); this.Shown += new System.EventHandler(this.FHome_Shown);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.FHome_Paint);
this.Resize += new System.EventHandler(this.FHome_Resize);
this.uiPanel1.ResumeLayout(false); this.uiPanel1.ResumeLayout(false);
this.uiTitlePanel1.ResumeLayout(false); this.uiTitlePanel1.ResumeLayout(false);
this.uiTitlePanel1.PerformLayout(); this.uiTitlePanel1.PerformLayout();

View File

@ -54,6 +54,11 @@ namespace LeatherApp.Page
//无产品编码时加载 //无产品编码时加载
FProductInfo frmProduct; FProductInfo frmProduct;
private double ThnDieLen = 0;
private Dictionary<int, Mat> defectTag = new Dictionary<int, Mat>();
//裁切偏移
private double OffsetCut = 0.2;
//云端 //云端
private CloudMgr cloudMgr = new CloudMgr(); private CloudMgr cloudMgr = new CloudMgr();
private bool init_Cloud; private bool init_Cloud;
@ -439,8 +444,8 @@ namespace LeatherApp.Page
})); }));
} }
private delegate void AddTextDelegate(DateTime time,string tag, string msg, WarningEnum level); private delegate void AddTextDelegate(DateTime time,string tag, string msg, WarningEnum level, bool Show);
private void AddTextEvent(DateTime now, string tag, string msg, WarningEnum level = WarningEnum.Normal) private void AddTextEvent(DateTime now, string tag, string msg, WarningEnum level = WarningEnum.Normal, bool Show = true)
{ {
try try
{ {
@ -451,7 +456,8 @@ namespace LeatherApp.Page
now, now,
tag, tag,
msg, msg,
level level,
Show
}); });
} }
else else
@ -469,7 +475,8 @@ namespace LeatherApp.Page
// //
//if (type > 0) //if (type > 0)
// cont = $"<color=\"{(type == 1 ? "Yellow" : "Red")}\">{cont}</color>"; // cont = $"<color=\"{(type == 1 ? "Yellow" : "Red")}\">{cont}</color>";
if (Show)
{
//msg = (level == WarningEnum.Normal ? "B" : level == WarningEnum.Low ? "Y" : "R") + msg; //msg = (level == WarningEnum.Normal ? "B" : level == WarningEnum.Low ? "Y" : "R") + msg;
msg = (level == WarningEnum.Normal ? "" : level == WarningEnum.Low ? "Y" : "R") + msg; msg = (level == WarningEnum.Normal ? "" : level == WarningEnum.Low ? "Y" : "R") + msg;
//this.Invoke(new System.Action(() => //this.Invoke(new System.Action(() =>
@ -478,6 +485,7 @@ namespace LeatherApp.Page
this.lstboxLog.Items.Clear(); this.lstboxLog.Items.Clear();
lstboxLog.Items.Insert(0, msg); lstboxLog.Items.Insert(0, msg);
//})); //}));
}
//日志滚动 //日志滚动
//lstLog.SelectedIndex = lstLog.Items.Count - 1; //lstLog.SelectedIndex = lstLog.Items.Count - 1;
@ -562,6 +570,8 @@ namespace LeatherApp.Page
//DefectLib dl = new DefectLib(); //DefectLib dl = new DefectLib();
//dl.start(); //dl.start();
//加载寻边模型
OpenCVUtil.LoadEdgeMode();
this.btnOpen.Enabled = false; this.btnOpen.Enabled = false;
@ -675,12 +685,27 @@ namespace LeatherApp.Page
errCode = 2; errCode = 2;
//加载新产品 //加载新产品
string pcode = "1-" + codes[2]; string pcode = "1-" + codes[2];
if (codes[1] == "0" || Config.SuedeList.Contains(codes[1])) if (codes[1] == "0" || Config.SuedeList1.Contains(codes[1]))
pcode = "0-" + codes[2]; pcode = "0-" + codes[2];
else
#if false #if false
else
pcode = codes[1] + "-" + codes[2]; pcode = codes[1] + "-" + codes[2];
#elif HX_LOD
else
pcode = "1-" + codes[2];
#else #else
else if (codes[1] == "1" || Config.SuedeList2.Contains(codes[1]))
pcode = "1-" + codes[2];
else if (codes[1] == "2" || Config.SuedeList3.Contains(codes[1]))
pcode = "2-" + codes[2];
else if (codes[1] == "3" || Config.SuedeList4.Contains(codes[1]))
pcode = "3-" + codes[2];
else if (codes[1] == "4" || Config.SuedeList5.Contains(codes[1]))
pcode = "4-" + codes[2];
else if (codes[1] == "5" || Config.SuedeList6.Contains(codes[1]))
pcode = "5-" + codes[2];
else
pcode = "1-" + codes[2]; pcode = "1-" + codes[2];
#endif #endif
@ -834,7 +859,7 @@ namespace LeatherApp.Page
}; };
devContainer.WarningEvent = (now,level, msg) => devContainer.WarningEvent = (now,level, msg) =>
{ {
AddTextEvent(DateTime.Now,$"设备事件{Thread.CurrentThread.ManagedThreadId}", msg, level); AddTextEvent(DateTime.Now,$"设备事件{Thread.CurrentThread.ManagedThreadId}", msg, level, false);
if (level == WarningEnum.High) if (level == WarningEnum.High)
Task.Run(() => warning(level, true)); Task.Run(() => warning(level, true));
}; };
@ -936,7 +961,7 @@ namespace LeatherApp.Page
{ {
if (Config.Camer_Name == CamerDevNameEnum.) if (Config.Camer_Name == CamerDevNameEnum.)
{ {
AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"采集卡({devIndex}),图像({num})"); AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"采集卡({devIndex}),图像({num})", WarningEnum.Low, false);
Cv2.Flip(matone, matone, FlipMode.XY);//翻转 Cv2.Flip(matone, matone, FlipMode.XY);//翻转
Bitmap bitmap = BitmapConverter.ToBitmap(matone); Bitmap bitmap = BitmapConverter.ToBitmap(matone);
this.BeginInvoke(new Action(() => this.BeginInvoke(new Action(() =>
@ -980,7 +1005,7 @@ namespace LeatherApp.Page
Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records; Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records;
Device.PhotoLib.PhotoTask task; Device.PhotoLib.PhotoTask task;
Mat myMat = matone;//.Clone(); Mat myMat = matone;//.Clone();
AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"(图像{num})-采集卡({devIndex}),size:({myMat.Width}*{myMat.Height})({(myMat == null ? "A" : "B")})"); AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"(图像{num})-采集卡({devIndex}),size:({myMat.Width}*{myMat.Height})({(myMat == null ? "A" : "B")})", WarningEnum.Low, false);
//AddTextEvent(DateTime.Now,"拍照", $"Dev={devIndex},图像{num}-2"); //AddTextEvent(DateTime.Now,"拍照", $"Dev={devIndex},图像{num}-2");
lock (lockScanPhoto)//多线程操作 lock (lockScanPhoto)//多线程操作
{ {
@ -1056,19 +1081,42 @@ namespace LeatherApp.Page
//warning(WarningEnum.Low, true);//暂停 //warning(WarningEnum.Low, true);//暂停
} }
errStep = 6; errStep = 6;
//厚度检测提示
if (curRecord.ProductInfo.OpenThicknessDetection)
{
if ((curRecord.Len - ThnDieLen) > curRecord.ProductInfo.ThicknessDetectionStopDis)
{
ThnDieLen = curRecord.Len;
AddTextEvent(DateTime.Now, $"厚度检测{Thread.CurrentThread.ManagedThreadId}", $"位置:{curRecord.Len}; 上次位置:{ThnDieLen}");
if (!Config.StopPLC)
this.devContainer.devPlc.pauseDev();
else if (!Config.StopIO && devContainer.devIOCard.IsInit)
{
//只是设备暂停APP没暂停
//devContainer.io_output(CMDName.绿灯输出, false, true, 0);
//devContainer.io_output(CMDName.黄灯输出);
devContainer.devIOCard.writeBitState(0, 1, true);
Task.Run(async () =>
{
await Task.Delay(500);
this.devContainer.devIOCard.writeBitState(0, 1, false);
});
}
}
}
// //
AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"待处理图像队列:{curRecord.ScannerPhotoCount - curRecord.ScannerPhotoFinishCount}张"); AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"待处理图像队列:{curRecord.ScannerPhotoCount - curRecord.ScannerPhotoFinishCount}张", WarningEnum.Low, false);
if (task.scanPhotos0 != null && task.scanPhotos1 != null) if (task.scanPhotos0 != null && task.scanPhotos1 != null)
{ {
var scanPhoto = task.scanPhotos0 as ScanPhotoInfo; var scanPhoto = task.scanPhotos0 as ScanPhotoInfo;
curRecord.dicPhoto_Defect.TryAdd(scanPhoto.photoIndex, false);//加入索引,默认无瑕疵 curRecord.dicPhoto_Defect.TryAdd(scanPhoto.photoIndex, false);//加入索引,默认无瑕疵
AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"图像索引:{scanPhoto.photoIndex},标识数:{curRecord.dicPhoto_Defect.Count}"); AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"图像索引:{scanPhoto.photoIndex},标识数:{curRecord.dicPhoto_Defect.Count}", WarningEnum.Low, false);
errStep = 7; errStep = 7;
//暂停:瑕疵二次判断 //暂停:瑕疵二次判断
if (this.defectPauseForUser) if (this.defectPauseForUser)
{ {
int liPhotoIndex = scanPhoto.photoIndex - Config.defectPauseSkipPhotoCount; int liPhotoIndex = scanPhoto.photoIndex - Config.defectPauseSkipPhotoCount;
AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"Dev={devIndex},图像{scanPhoto.photoIndex} {liPhotoIndex}={scanPhoto.photoIndex}-{Config.defectPauseSkipPhotoCount}{JsonConvert.SerializeObject(curRecord.dicPhoto_Defect)}"); AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"Dev={devIndex},图像{scanPhoto.photoIndex} {liPhotoIndex}={scanPhoto.photoIndex}-{Config.defectPauseSkipPhotoCount}{JsonConvert.SerializeObject(curRecord.dicPhoto_Defect)}", WarningEnum.Low, false);
if (liPhotoIndex >= 0 && curRecord.dicPhoto_Defect[liPhotoIndex]) if (liPhotoIndex >= 0 && curRecord.dicPhoto_Defect[liPhotoIndex])
{ {
List<DefectInfo> lstEditDefect = curRecord.DefectInfoList.Where(m => m.PhotoIndex == liPhotoIndex).ToList(); List<DefectInfo> lstEditDefect = curRecord.DefectInfoList.Where(m => m.PhotoIndex == liPhotoIndex).ToList();
@ -1096,9 +1144,10 @@ namespace LeatherApp.Page
this.BeginInvoke(new System.Action(() => this.BeginInvoke(new System.Action(() =>
{ {
int liDefectCount = lstEditDefect.Count; int liDefectCount = lstEditDefect.Count;
FHome_Defect frmDefect = new FHome_Defect(lstEditDefect); FHome_Defect frmDefect = new FHome_Defect(lstEditDefect, defectTag[liPhotoIndex]);
if (frmDefect.ShowDialog() == DialogResult.OK) if (frmDefect.ShowDialog() == DialogResult.OK)
{ {
defectTag.Remove(liPhotoIndex);
string oldCode; string oldCode;
for (int i = 0; i < this.uiDataGridView1.Rows.Count; i++) for (int i = 0; i < this.uiDataGridView1.Rows.Count; i++)
{ {
@ -1108,7 +1157,7 @@ namespace LeatherApp.Page
long uid = (long)this.uiDataGridView1.Rows[i].Cells["colUid"].Value; long uid = (long)this.uiDataGridView1.Rows[i].Cells["colUid"].Value;
foreach (var row in lstEditDefect) foreach (var row in lstEditDefect)
{ {
AddTextEvent(DateTime.Now, $"暂停{Thread.CurrentThread.ManagedThreadId}", $"修改第({i + 1})行瑕疵名称,{uid} {row.uid}"); AddTextEvent(DateTime.Now, $"暂停{Thread.CurrentThread.ManagedThreadId}", $"修改第({i + 1})行瑕疵名称,{uid} {row.uid}", WarningEnum.Low, false);
if (row.uid == uid) if (row.uid == uid)
{ {
oldCode = this.uiDataGridView1.Rows[i].Cells["colCode"].Value.ToString(); oldCode = this.uiDataGridView1.Rows[i].Cells["colCode"].Value.ToString();
@ -1170,12 +1219,187 @@ namespace LeatherApp.Page
} }
} }
errStep = 10; errStep = 10;
//以下判定放置于二次判定之后,因为二次判定可能会忽略部分检测项!!
//暂停:缺陷超标
//每百米告警判断???在此还是在收到新照片时触发???
if (curRecord.ProductInfo.DefectCountLimit > 0 && curRecord.DefectTotalCount >= curRecord.ProductInfo.DefectCountLimit && curRecord.DefectInfoList != null)
{
int liPhotoIndex = scanPhoto.photoIndex - Config.defectPauseSkipPhotoCount; //二次判定完的图片index
int compLen = 100 * 100;//每百米 to cm
int compCount = compLen * Config.cm2px_y / scanPhoto.mat.Height; //100m图像张数
//从上次告警后重新开始计算长度及数量
int defectCount = curRecord.DefectInfoList.Where(m => m.PhotoIndex >= curRecord.preWarningPhotoIndex && m.PhotoIndex >= (liPhotoIndex + 1 - compCount) && m.PhotoIndex <= liPhotoIndex).Count();
if (defectCount >= curRecord.ProductInfo.DefectCountLimit)
{
curRecord.preWarningPhotoIndex = liPhotoIndex + 1;
AddTextEvent(DateTime.Now, $"告警{Thread.CurrentThread.ManagedThreadId}", $"每百米瑕疵数量达到阈值!({defectCount}>={curRecord.ProductInfo.DefectCountLimit})", WarningEnum.High);
if (!Config.StopPLC)
this.devContainer.devPlc.pauseDev();
else if (!Config.StopIO && devContainer.devIOCard.IsInit)
{
//只是设备暂停APP没暂停
devContainer.io_output(CMDName.绿, false, true, 0);
devContainer.io_output(CMDName.);
devContainer.devIOCard.writeBitState(0, 1, true);
Task.Run(async () =>
{
await Task.Delay(500);
this.devContainer.devIOCard.writeBitState(0, 1, false);
});
}
}
errStep = 11;
}
//暂停:每个缺陷项不同长度检测数量报警
if (curRecord.DefectTotalCount > 0 && curRecord.DefectInfoList != null)
{
#if true
//按缺陷计算没X米多少缺陷报警
for (int i = 0; i < curRecord.ProductInfo.QualifiedLimitList.Count; i++)
{
var defectWarn = curRecord.ProductInfo.QualifiedLimitList[i];
if (defectWarn.DefectWarnLength > 0 || defectWarn.DefectWarnCnt > 0)
{
errStep = 12;
int liPhotoIndex = scanPhoto.photoIndex - Config.defectPauseSkipPhotoCount; //二次判定完的图片index
int warnLen = defectWarn.DefectWarnLength * 100;//每米 to cm
int warnCount = warnLen * Config.cm2px_y / scanPhoto.mat.Height; //计算图像张数
//从上次告警后重新开始计算长度及数量
int warnDefectCount = curRecord.DefectInfoList.Where(m => m.PhotoIndex >= curRecord.preWarningPhotoIndexByLabel[i] && m.PhotoIndex >= (liPhotoIndex + 1 - warnCount) && m.PhotoIndex <= liPhotoIndex).Count();
if (warnDefectCount >= defectWarn.DefectWarnCnt)
{
curRecord.preWarningPhotoIndexByLabel[i] = liPhotoIndex + 1;
AddTextEvent(DateTime.Now, $"告警{Thread.CurrentThread.ManagedThreadId}", $"每{defectWarn.DefectWarnLength}米{Config.getDefectName(defectWarn.Code)}瑕疵数量达到阈值!({warnDefectCount}>={defectWarn.DefectWarnCnt})", WarningEnum.High);
if (!Config.StopPLC)
this.devContainer.devPlc.pauseDev();
else if (!Config.StopIO && devContainer.devIOCard.IsInit)
{
//只是设备暂停APP没暂停
devContainer.io_output(CMDName.绿, false, true, 0);
devContainer.io_output(CMDName.);
devContainer.devIOCard.writeBitState(0, 1, true);
Task.Run(async () =>
{
await Task.Delay(500);
this.devContainer.devIOCard.writeBitState(0, 1, false);
});
}
}
}
}
#endif
}
#if false
//暂停:按等级分卷
if (curRecord.DefectTotalCount > 0 && curRecord.ProductInfo.GradeLimitList != null && curRecord.ProductInfo.GradeLimitList.Count > 0 && curRecord.DefectInfoList != null)
{
errStep = 13;
//按缺陷计算每X米多少缺陷分等级
for (int i = 0; i < curRecord.ProductInfo.GradeLimitList.Count; i++)
{
if (curRecord.ProductInfo.GradeLimitList[i].JudgeLength > 0)
{
errStep = 14;
int liPhotoIndex = scanPhoto.photoIndex - Config.defectPauseSkipPhotoCount; //二次判定完的图片index
double GrageLen = curRecord.ProductInfo.GradeLimitList[i].JudgeLength * 100;//每米 to cm
int warnCount = (int)(GrageLen * Config.cm2px_y) / scanPhoto.mat.Height; //计算图像张数
if (curRecord.GradeDifferentiateInfoList == null)
{
curRecord.GradeDifferentiateInfoList = new List<GradeDifferentiateInfo>();
}
GradeLimit item = curRecord.ProductInfo.GradeLimitList[i];
GradeDifferentiateInfo differentiateInfo = new GradeDifferentiateInfo();
//从上次告警后重新开始计算长度及数量
var allFind = curRecord.DefectInfoList.Where(m => m.PhotoIndex >= curRecord.preGradePhotoIndexByGradeIndex && m.PhotoIndex >= (liPhotoIndex + 1 - warnCount) && m.PhotoIndex <= liPhotoIndex).ToList();
int warnDefectCount = 0;
if (item.Code == "All")
warnDefectCount = allFind.Count();
else
{
warnDefectCount = allFind.Where(m => m.Code == item.Code).Count();
}
int GradeCount = 0;
if (item.E > 0 && warnDefectCount > item.E)
{
GradeCount = item.E;
differentiateInfo.GradeCode = "E";
}
else if (item.D > 0 && warnDefectCount > item.D)
{
GradeCount = item.D;
differentiateInfo.GradeCode = "D";
}
else if (item.C > 0 && warnDefectCount > item.C)
{
GradeCount = item.C;
differentiateInfo.GradeCode = "C";
}
else if (item.B > 0 && warnDefectCount > item.B)
{
GradeCount = item.B;
differentiateInfo.GradeCode = "B";
}
else if (item.A > 0 && warnDefectCount > item.A)
{
GradeCount = item.A;
differentiateInfo.GradeCode = "A";
}
else
{
//不需要分级,下一条
continue;
}
differentiateInfo.UseGradeLimit = item;
differentiateInfo.DefectCnt = warnDefectCount;
differentiateInfo.StartPhotoIndex = allFind.Min(x => x.PhotoIndex);
differentiateInfo.EndPhotoIndex = allFind.Max(x => x.PhotoIndex);
differentiateInfo.StartY = allFind.Min(x => x.CentreY) / 100 - OffsetCut;
differentiateInfo.EndY = allFind.Max(x => x.CentreY) / 100 + OffsetCut;
differentiateInfo.CutLen = differentiateInfo.EndY - differentiateInfo.StartY;
//记录新的判定开始位置
curRecord.preGradePhotoIndexByGradeIndex = liPhotoIndex + 1;
AddTextEvent(DateTime.Now, $"提示{Thread.CurrentThread.ManagedThreadId}", $"每{curRecord.ProductInfo.GradeLimitList[i].JudgeLength}米,瑕疵数量达到分级阈值!({warnDefectCount}>={GradeCount})", WarningEnum.Low);
curRecord.GradeDifferentiateInfoList.Add(differentiateInfo);
//标记裁切位置
this.BeginInvoke(new System.Action(() =>
{
reDrawDefectPointsAndCut(differentiateInfo.StartY, differentiateInfo.EndY, differentiateInfo.GradeCode);
}));
//裁切暂停提示
if (curRecord.ProductInfo.IsHintCutting)
{
AddTextEvent(DateTime.Now, $"提示", $"裁切 起始{differentiateInfo.StartY}-终点{differentiateInfo.EndY}", WarningEnum.Low);
if (!Config.StopPLC)
this.devContainer.devPlc.pauseDev();
else if (!Config.StopIO && devContainer.devIOCard.IsInit)
{
//只是设备暂停APP没暂停
devContainer.io_output(CMDName.绿, false, true, 0);
devContainer.io_output(CMDName.);
devContainer.devIOCard.writeBitState(0, 1, true);
Task.Run(async () =>
{
await Task.Delay(500);
this.devContainer.devIOCard.writeBitState(0, 1, false);
});
}
}
}
}
}
#endif
task.record = curRecord; task.record = curRecord;
task.finishEvent = callBackPhotoEvent; task.finishEvent = callBackPhotoEvent;
devContainer.libPhoto.add(task); devContainer.libPhoto.add(task);
AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"Dev={devIndex},图像{scanPhoto.photoIndex},已加入图像处理队列"); AddTextEvent(DateTime.Now, $"拍照{Thread.CurrentThread.ManagedThreadId}", $"Dev={devIndex},图像{scanPhoto.photoIndex},已加入图像处理队列");
errStep = 11; errStep = 21;
Application.DoEvents(); //Application.DoEvents();
} }
} }
catch (Exception e) catch (Exception e)
@ -1191,7 +1415,7 @@ namespace LeatherApp.Page
ScanPhotoInfo scanPhotos1 = task.scanPhotos1 as ScanPhotoInfo; ScanPhotoInfo scanPhotos1 = task.scanPhotos1 as ScanPhotoInfo;
Stopwatch stopWatch = new Stopwatch(); Stopwatch stopWatch = new Stopwatch();
AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"图像{scanPhotos0.photoIndex}ThreadId={Thread.CurrentThread.ManagedThreadId}"); AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"图像{scanPhotos0.photoIndex}ThreadId={Thread.CurrentThread.ManagedThreadId}", WarningEnum.Low, false);
string time = ""; string time = "";
stopWatch.Start(); stopWatch.Start();
try try
@ -1245,7 +1469,7 @@ namespace LeatherApp.Page
} }
AddTextEvent(DateTime.Now,$"裁边{Thread.CurrentThread.ManagedThreadId}", AddTextEvent(DateTime.Now,$"裁边{Thread.CurrentThread.ManagedThreadId}",
$"(图像{scanPhotos0.photoIndex})-左图去重后:{mat0.Width}*{mat0.Height},右图:{mat1.Width}*{mat1.Height}" + $"(图像{scanPhotos0.photoIndex})-左图去重后:{mat0.Width}*{mat0.Height},右图:{mat1.Width}*{mat1.Height}" +
$"重复值:{Config.MiddleSuperposition},孔洞:{Config.MarginHoleWidth},cm2px{Config.cm2px_x},resizeWidth{resizeWidth}"); $"重复值:{Config.MiddleSuperposition},孔洞:{Config.MarginHoleWidth},cm2px{Config.cm2px_x},resizeWidth{resizeWidth}", WarningEnum.Low, false);
errStep = 4; errStep = 4;
//mat0 = OpenCVUtil.getMaxInsetRect(mat0); //mat0 = OpenCVUtil.getMaxInsetRect(mat0);
int marginWidth0, marginWidth1; int marginWidth0, marginWidth1;
@ -1260,7 +1484,7 @@ namespace LeatherApp.Page
time += $"->图2裁边({stopWatch.ElapsedMilliseconds})"; time += $"->图2裁边({stopWatch.ElapsedMilliseconds})";
//水平合并l //水平合并l
Mat mat = OpenCVUtil.mergeImage_sameSize(new Mat[] { mat0, mat1 });//这里相机反装,左右反转下 Mat mat = OpenCVUtil.mergeImage_sameSize(new Mat[] { mat0, mat1 });//这里相机反装,左右反转下
AddTextEvent(DateTime.Now,$"裁边{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-边缘宽度:(左图)={marginWidth0},(右图)={marginWidth1}; 裁边去孔洞后:({mat0.Width}+{mat1.Width}={mat0.Width+ mat1.Width});合并后(去孔洞){mat.Width}*{mat.Height}"); AddTextEvent(DateTime.Now,$"裁边{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-边缘宽度:(左图)={marginWidth0},(右图)={marginWidth1}; 裁边去孔洞后:({mat0.Width}+{mat1.Width}={mat0.Width+ mat1.Width});合并后(去孔洞){mat.Width}*{mat.Height}", WarningEnum.Low, false);
float widthRatio = mat.Width * 1.0f / resize.Width;//宽度比例 float widthRatio = mat.Width * 1.0f / resize.Width;//宽度比例
time += $"->图1+2合并({stopWatch.ElapsedMilliseconds})"; time += $"->图1+2合并({stopWatch.ElapsedMilliseconds})";
@ -1274,7 +1498,7 @@ namespace LeatherApp.Page
if (curRecord.FaceWidthMax < faceWidthY_cm) if (curRecord.FaceWidthMax < faceWidthY_cm)
curRecord.FaceWidthMax = faceWidthY_cm; curRecord.FaceWidthMax = faceWidthY_cm;
var point = new float[] { faceWidthX_cm, faceWidthY_cm };// new System.Drawing.PointF(faceWidthX_cm, faceWidthY_cm); var point = new float[] { faceWidthX_cm, faceWidthY_cm };// new System.Drawing.PointF(faceWidthX_cm, faceWidthY_cm);
AddTextEvent(DateTime.Now,$"门幅{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-({scanPhotos0.photoIndex})位置:{point[0]}; 幅宽:{point[1]}"); AddTextEvent(DateTime.Now,$"门幅{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-({scanPhotos0.photoIndex})位置:{point[0]}; 幅宽:{point[1]}", WarningEnum.Low, false);
curRecord.FacePointList.Add(point); curRecord.FacePointList.Add(point);
reDrawFaceWidth(curRecord.FacePointList, reDrawFaceWidth(curRecord.FacePointList,
new double[] { 0, Math.Round(point[0] + 0.005f, 2) }, new double[] { 0, Math.Round(point[0] + 0.005f, 2) },
@ -1302,7 +1526,7 @@ namespace LeatherApp.Page
//----缺陷队列 //----缺陷队列
int oxw, oxh; int oxw, oxh;
mat = OpenCVUtil.resize(mat, resize.Width, resize.Height, out oxw, out oxh); mat = OpenCVUtil.resize(mat, resize.Width, resize.Height, out oxw, out oxh);
AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}"); AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}", WarningEnum.Low, false);
devContainer.libDefect.add(new Device.DefectLib.DefectTask() devContainer.libDefect.add(new Device.DefectLib.DefectTask()
{ {
modelName= curRecord.ProductInfo.ModelName, modelName= curRecord.ProductInfo.ModelName,
@ -1328,12 +1552,12 @@ namespace LeatherApp.Page
} }
finally finally
{ {
AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-进度计时:{time}"); AddTextEvent(DateTime.Now,$"图像处理{Thread.CurrentThread.ManagedThreadId}", $"(图像{scanPhotos0.photoIndex})-进度计时:{time}", WarningEnum.Low, false);
scanPhotos0.mat.Dispose(); scanPhotos0.mat.Dispose();
scanPhotos1.mat.Dispose(); scanPhotos1.mat.Dispose();
scanPhotos0 = scanPhotos1 = null; scanPhotos0 = scanPhotos1 = null;
task = null; task = null;
System.GC.Collect(); //System.GC.Collect();
} }
} }
private void callBackDefectEvent(Device.DefectLib.DefectTask res) private void callBackDefectEvent(Device.DefectLib.DefectTask res)
@ -1342,7 +1566,7 @@ namespace LeatherApp.Page
int step = 0; int step = 0;
try try
{ {
AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", $"图像队列:{res.record.ScannerPhotoFinishCount+1}/{res.record.ScannerPhotoCount} (图像{res.photoIndex})检测结果:{res.isSucceed}"); AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", $"图像队列:{res.record.ScannerPhotoFinishCount+1}/{res.record.ScannerPhotoCount} (图像{res.photoIndex})检测结果:{res.isSucceed}", WarningEnum.Low, false);
string dirPath = FileUtil.initFolder($"{Config.ImagePath}{res.record.BatchId}_{res.record.ReelId}\\"); string dirPath = FileUtil.initFolder($"{Config.ImagePath}{res.record.BatchId}_{res.record.ReelId}\\");
string dirSourcePath = FileUtil.initFolder($"{Config.ImagePath}{res.record.BatchId}_{res.record.ReelId}\\源图\\"); string dirSourcePath = FileUtil.initFolder($"{Config.ImagePath}{res.record.BatchId}_{res.record.ReelId}\\源图\\");
//Cv2.Flip(res.bmp, res.bmp, FlipMode.XY);//翻转 //Cv2.Flip(res.bmp, res.bmp, FlipMode.XY);//翻转
@ -1352,10 +1576,10 @@ namespace LeatherApp.Page
if (res.isSucceed) if (res.isSucceed)
{ {
step = 1; step = 1;
AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", $"(图像{res.photoIndex})-瑕疵检测完成,共{res.excelTable.Rows.Count}个瑕疵!各环节用时:{string.Join(",",res.stopwatch)}"); AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", $"(图像{res.photoIndex})-瑕疵检测完成,共{res.excelTable.Rows.Count}个瑕疵!各环节用时:{string.Join(",",res.stopwatch)}", WarningEnum.Low, false);
//AddTextEvent(DateTime.Now,$"打标完成", $"第 ({res.photoIndex}) 张照片,计算过程:{res.resultInfo}"); //AddTextEvent(DateTime.Now,$"打标完成", $"第 ({res.photoIndex}) 张照片,计算过程:{res.resultInfo}");
if (!Config.IsSaveAllImage && Config.IsSaveDefectSourceImage) //if (!Config.IsSaveAllImage && Config.IsSaveDefectSourceImage)
OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmp).Save($"{dirSourcePath}{res.photoIndex}.bmp", ImageFormat.Bmp); // OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmp).Save($"{dirSourcePath}{res.photoIndex}.bmp", ImageFormat.Bmp);
step = 2; step = 2;
if (res.excelTable.Rows.Count > 0) if (res.excelTable.Rows.Count > 0)
@ -1363,6 +1587,8 @@ namespace LeatherApp.Page
res.record.dicPhoto_Defect[res.photoIndex] = true;//改为此图有瑕疵 res.record.dicPhoto_Defect[res.photoIndex] = true;//改为此图有瑕疵
//有瑕疵打标图必需保存 Jpeg //有瑕疵打标图必需保存 Jpeg
OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmpTag).Save($"{dirPath}{res.photoIndex}_tag.jpg", ImageFormat.Jpeg); OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmpTag).Save($"{dirPath}{res.photoIndex}_tag.jpg", ImageFormat.Jpeg);
if (!Config.IsSaveAllImage && Config.IsSaveDefectSourceImage)
OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.bmp).Save($"{dirSourcePath}{res.photoIndex}.bmp", ImageFormat.Bmp);
step = 3; step = 3;
res.record.DefectTotalCount += res.excelTable.Rows.Count; res.record.DefectTotalCount += res.excelTable.Rows.Count;
if (res.record.DefectInfoList == null) if (res.record.DefectInfoList == null)
@ -1398,6 +1624,11 @@ namespace LeatherApp.Page
defectInfo.uid = preTicks++;// res.record.DefectInfoList.Count;//程序中的唯一索引,用于移除用索引 defectInfo.uid = preTicks++;// res.record.DefectInfoList.Count;//程序中的唯一索引,用于移除用索引
//AddTextEvent(DateTime.Now,$"打标完成", $"第{i}个缺陷:{ JsonConvert.SerializeObject(defectInfo)}; Y={res.photoIndex * res.bmp.Height * 1.0d / Config.cm2px_y}+{res.excelTable.Rows[i]["Y"].ToString()}"); //AddTextEvent(DateTime.Now,$"打标完成", $"第{i}个缺陷:{ JsonConvert.SerializeObject(defectInfo)}; Y={res.photoIndex * res.bmp.Height * 1.0d / Config.cm2px_y}+{res.excelTable.Rows[i]["Y"].ToString()}");
step = 7 + i * 10; step = 7 + i * 10;
if (!defectTag.ContainsKey(res.photoIndex))
{
defectTag.Add(res.photoIndex, res.bmpTag.Clone());
}
//保存打标小图 //保存打标小图
if (Config.IsSaveDefectCutImage) if (Config.IsSaveDefectCutImage)
{ {
@ -1424,9 +1655,23 @@ namespace LeatherApp.Page
if (res.record.ProductInfo.DefectAreaLimit > 0 && defectInfo.Area>=res.record.ProductInfo.DefectAreaLimit) if (res.record.ProductInfo.DefectAreaLimit > 0 && defectInfo.Area>=res.record.ProductInfo.DefectAreaLimit)
{ {
AddTextEvent(DateTime.Now,$"告警{Thread.CurrentThread.ManagedThreadId}", $"瑕疵面积达到阈值!({defectInfo.Area}>={res.record.ProductInfo.DefectAreaLimit})", WarningEnum.High); AddTextEvent(DateTime.Now,$"告警{Thread.CurrentThread.ManagedThreadId}", $"瑕疵面积达到阈值!({defectInfo.Area}>={res.record.ProductInfo.DefectAreaLimit})", WarningEnum.High);
if (!Config.StopPLC)
this.devContainer.devPlc.pauseDev();
else if (!Config.StopIO && devContainer.devIOCard.IsInit)
{
//只是设备暂停APP没暂停
devContainer.io_output(CMDName.绿, false, true, 0);
devContainer.io_output(CMDName.);
devContainer.devIOCard.writeBitState(0, 1, true);
Task.Run(async () =>
{
await Task.Delay(500);
this.devContainer.devIOCard.writeBitState(0, 1, false);
});
} }
} }
AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", "更新UI"); }
AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", "更新UI", WarningEnum.Low, false);
//更新UI //更新UI
int bmpHeight = res.bmp.Height; int bmpHeight = res.bmp.Height;
this.BeginInvoke(new System.Action(() => this.BeginInvoke(new System.Action(() =>
@ -1444,12 +1689,12 @@ namespace LeatherApp.Page
this.reDrawDefectPoints(res.record.DefectInfoList, new double[] { 0, Math.Round(res.record.FaceWidthMax+ 0.005f, 2) }, new double[] { 0, len }); this.reDrawDefectPoints(res.record.DefectInfoList, new double[] { 0, Math.Round(res.record.FaceWidthMax+ 0.005f, 2) }, new double[] { 0, len });
})); }));
step = 9; step = 9;
AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", "保存CSV"); AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", "保存CSV", WarningEnum.Low, false);
//保存CSV //保存CSV
bool b = Utils.ExcelUtil.DataTable2CSV($"{dirPath}{res.photoIndex}.csv", res.excelTable); bool b = Utils.ExcelUtil.DataTable2CSV($"{dirPath}{res.photoIndex}.csv", res.excelTable);
//AddTextEvent(DateTime.Now,$"打标完成", $"{res.tag}.xlsx {(b ? "保存成功!" : "保存失败!")}"); //AddTextEvent(DateTime.Now,$"打标完成", $"{res.tag}.xlsx {(b ? "保存成功!" : "保存失败!")}");
step = 10; step = 10;
#if
//每百米告警判断???在此还是在收到新照片时触发??? //每百米告警判断???在此还是在收到新照片时触发???
if (res.record.ProductInfo.DefectCountLimit > 0 && res.record.DefectTotalCount >= res.record.ProductInfo.DefectCountLimit) if (res.record.ProductInfo.DefectCountLimit > 0 && res.record.DefectTotalCount >= res.record.ProductInfo.DefectCountLimit)
{ {
@ -1484,6 +1729,7 @@ namespace LeatherApp.Page
} }
#endif #endif
} }
#endif
} }
} }
@ -1505,7 +1751,7 @@ namespace LeatherApp.Page
res.record.ScannerPhotoFinishCount++; res.record.ScannerPhotoFinishCount++;
int liScannerPhotoFinishCount = res.record.ScannerPhotoFinishCount; int liScannerPhotoFinishCount = res.record.ScannerPhotoFinishCount;
int liScannerPhotoCount = res.record.ScannerPhotoCount; int liScannerPhotoCount = res.record.ScannerPhotoCount;
AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", $"{liScannerPhotoFinishCount}/{liScannerPhotoCount}"); AddTextEvent(DateTime.Now,$"检测完成{Thread.CurrentThread.ManagedThreadId}", $"{liScannerPhotoFinishCount}/{liScannerPhotoCount}", WarningEnum.Low, false);
//this.BeginInvoke(new System.Action(() => //this.BeginInvoke(new System.Action(() =>
//{ //{
// this.lblWaitImageCount.Text = $"{liScannerPhotoCount - liScannerPhotoFinishCount}"; // this.lblWaitImageCount.Text = $"{liScannerPhotoCount - liScannerPhotoFinishCount}";
@ -1693,6 +1939,8 @@ namespace LeatherApp.Page
resetUIValue(); resetUIValue();
AddTextEvent(DateTime.Now,"启动", "等待扫码..."); AddTextEvent(DateTime.Now,"启动", "等待扫码...");
currentState = CurrentStateEnum.; currentState = CurrentStateEnum.;
defectTag.Clear();
ThnDieLen = 0;
} }
this.Invoke(new System.Action(() => this.Invoke(new System.Action(() =>
@ -1901,14 +2149,55 @@ namespace LeatherApp.Page
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
List<DefectInfo> lstEditDefect = new List<DefectInfo>(); //List<DefectInfo> lstEditDefect = new List<DefectInfo>();
DefectInfo dt = new DefectInfo(); //DefectInfo dt = new DefectInfo();
dt.Name = "123"; //dt.Name = "123";
dt.Code = "jb"; //dt.Code = "wuyin";
dt.image = Image.FromFile("C:\\Users\\fang\\Desktop\\123.png"); //dt.image = Image.FromFile("C:\\Users\\fang\\Desktop\\123.png");
lstEditDefect.Add(dt); //lstEditDefect.Add(dt);
FHome_Defect frmDefect = new FHome_Defect(lstEditDefect); //Mat mtt = new Mat("C:\\Users\\fang\\Desktop\\新建文件夹\\mx\\636.bmp");
frmDefect.ShowDialog(); //FHome_Defect frmDefect = new FHome_Defect(lstEditDefect, mtt);
//frmDefect.ShowDialog();
Config.LoadAllConfig();
//设置程序最小/大线程池
// Get the current settings.
int minWorker, minIOC;
ThreadPool.GetMinThreads(out minWorker, out minIOC);
ThreadPool.SetMinThreads(25, minIOC);
Mat matt = new Mat("C:\\Users\\fang\\Desktop\\新建文件夹\\287.bmp");
//OpenCVUtil.LoadEdgeMode();
//int tt = 0;
//var mty = OpenCVUtil.getMaxInsetRect2(matt, false, 0,out tt);
//mty.SaveImage("edge.bmp");
List<QualifiedLimit> qlist = new List<QualifiedLimit>();
qlist.Add(new QualifiedLimit() { Code = "laji", ZXD = 0.3, Area = 0.04, ContrastLower = 0.98, ContrastTop = 1.02 });
qlist.Add(new QualifiedLimit() { Code = "wuyin", ZXD = 0.3, Area = 0.09, ContrastLower = 0.93, ContrastTop = 1.07 });
qlist.Add(new QualifiedLimit() { Code = "jiangyin", ZXD = 0.3, Area = 0.04, ContrastLower = 0.96, ContrastTop = 1.04 });
qlist.Add(new QualifiedLimit() { Code = "zhouyin", ZXD = 0.3, Area = 0.09, ContrastLower = 0.94, ContrastTop = 1.06 });
qlist.Add(new QualifiedLimit() { Code = "hengdang", ZXD = 0.3, Area = 0.08, ContrastLower = 0.99, ContrastTop = 1.01 });
qlist.Add(new QualifiedLimit() { Code = "jietou", ZXD = 0.3, Area = 0.04, ContrastLower = 0.99, ContrastTop = 1.01 });
qlist.Add(new QualifiedLimit() { Code = "chongying", ZXD = 0.3, Area = 2, ContrastLower = 0.99, ContrastTop = 1.01 });
qlist.Add(new QualifiedLimit() { Code = "aokeng", ZXD = 0.3, Area = 0.05, ContrastLower = 0.99, ContrastTop = 1.01 });
qlist.Add(new QualifiedLimit() { Code = "bmss", ZXD = 0.3, Area = 2, ContrastLower = 0.99, ContrastTop = 1.01 });
DefectLib dlt = new DefectLib();
dlt.start();
dlt.add(new Device.DefectLib.DefectTask()
{
modelName = "CYG_0706.trt",
record = null,
bmp = matt,
bmpTag = matt.Clone(),
photoIndex = 0,//0-n 首张必需为0因下面计算长度是从0开始
widthRatio = 1,
qualifiedLimitList = qlist,
finishEvent = callBackDefectEvent,
xw = 0,
});
return; return;
Config.LoadAllConfig(); Config.LoadAllConfig();
DefectLib dl = new DefectLib(); DefectLib dl = new DefectLib();
@ -2104,5 +2393,15 @@ namespace LeatherApp.Page
record.ErpLen = val; record.ErpLen = val;
} }
} }
private void FHome_Resize(object sender, EventArgs e)
{
uilbKF.Top = 8;
}
private void FHome_Paint(object sender, PaintEventArgs e)
{
uilbKF.Top = 8;
}
} }
} }

View File

@ -29,25 +29,35 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.uiPanel1 = new Sunny.UI.UIPanel(); this.uiPanel1 = new Sunny.UI.UIPanel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnOK = new Sunny.UI.UIButton(); this.btnOK = new Sunny.UI.UIButton();
this.btnCancel = new Sunny.UI.UIButton(); this.btnCancel = new Sunny.UI.UIButton();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.uiPanel1.SuspendLayout(); this.uiPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// uiPanel1 // uiPanel1
// //
this.uiPanel1.Controls.Add(this.flowLayoutPanel1); this.uiPanel1.Controls.Add(this.flowLayoutPanel1);
this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiPanel1.Location = new System.Drawing.Point(4, 39); this.uiPanel1.Location = new System.Drawing.Point(4, 221);
this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1); this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1);
this.uiPanel1.Name = "uiPanel1"; this.uiPanel1.Name = "uiPanel1";
this.uiPanel1.Size = new System.Drawing.Size(1242, 919); this.uiPanel1.Size = new System.Drawing.Size(1242, 737);
this.uiPanel1.TabIndex = 0; this.uiPanel1.TabIndex = 0;
this.uiPanel1.Text = "uiPanel1"; this.uiPanel1.Text = "uiPanel1";
this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
// //
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(1236, 731);
this.flowLayoutPanel1.TabIndex = 0;
//
// btnOK // btnOK
// //
this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand; this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
@ -75,19 +85,24 @@
this.btnCancel.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnCancel.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// //
// flowLayoutPanel1 // pictureBox1
// //
this.flowLayoutPanel1.AutoScroll = true; this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3); | System.Windows.Forms.AnchorStyles.Left)
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; | System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel1.Size = new System.Drawing.Size(1236, 913); this.pictureBox1.Location = new System.Drawing.Point(4, 38);
this.flowLayoutPanel1.TabIndex = 0; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(1242, 180);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
// //
// FHome_Defect // FHome_Defect
// //
this.AcceptButton = this.btnOK; this.AcceptButton = this.btnOK;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1250, 1014); this.ClientSize = new System.Drawing.Size(1250, 1014);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK); this.Controls.Add(this.btnOK);
this.Controls.Add(this.uiPanel1); this.Controls.Add(this.uiPanel1);
@ -99,6 +114,7 @@
this.ZoomScaleRect = new System.Drawing.Rectangle(22, 22, 800, 450); this.ZoomScaleRect = new System.Drawing.Rectangle(22, 22, 800, 450);
this.Load += new System.EventHandler(this.FHome_Defect_Load); this.Load += new System.EventHandler(this.FHome_Defect_Load);
this.uiPanel1.ResumeLayout(false); this.uiPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -109,5 +125,6 @@
private Sunny.UI.UIButton btnOK; private Sunny.UI.UIButton btnOK;
private Sunny.UI.UIButton btnCancel; private Sunny.UI.UIButton btnCancel;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.PictureBox pictureBox1;
} }
} }

View File

@ -1,5 +1,7 @@
using LeatherApp.UIExtend; using LeatherApp.UIExtend;
using Models; using Models;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using Sunny.UI; using Sunny.UI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -17,10 +19,13 @@ namespace LeatherApp.Page
{ {
private List<DefectInfo> list; private List<DefectInfo> list;
public List<DefectInfo> lstDel = new List<DefectInfo>(); public List<DefectInfo> lstDel = new List<DefectInfo>();
public FHome_Defect(List<DefectInfo> lst) private Mat Image;
public FHome_Defect(List<DefectInfo> lst, Mat img)
{ {
InitializeComponent(); InitializeComponent();
list = lst; list = lst;
Image = img;
pictureBox1.Image = Image.ToBitmap();
init(); init();
} }

View File

@ -33,12 +33,12 @@
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.uiTitlePanel2 = new Sunny.UI.UITitlePanel(); this.uiTitlePanel2 = new Sunny.UI.UITitlePanel();
this.tcbarTensionValue = new Sunny.UI.UITrackBar(); this.tcbarTensionValue = new Sunny.UI.UITrackBar();
this.tcbarGain = new Sunny.UI.UITrackBar(); this.tcbarGain = new Sunny.UI.UITrackBar();
@ -65,6 +65,14 @@
this.uiLabel7 = new Sunny.UI.UILabel(); this.uiLabel7 = new Sunny.UI.UILabel();
this.uiTitlePanel5 = new Sunny.UI.UITitlePanel(); this.uiTitlePanel5 = new Sunny.UI.UITitlePanel();
this.uiDataGridView1 = new Sunny.UI.UIDataGridView(); this.uiDataGridView1 = new Sunny.UI.UIDataGridView();
this.col_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_zxd = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_area = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_contrast_lower = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_contrast_top = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_IsOR = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.col_Len = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_Cnt = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uiTitlePanel6 = new Sunny.UI.UITitlePanel(); this.uiTitlePanel6 = new Sunny.UI.UITitlePanel();
this.uiDataGridView2 = new Sunny.UI.UIDataGridView(); this.uiDataGridView2 = new Sunny.UI.UIDataGridView();
this.col2_code = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.col2_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
@ -88,14 +96,9 @@
this.cmbColor = new Sunny.UI.UIComboBox(); this.cmbColor = new Sunny.UI.UIComboBox();
this.uiLabel3 = new Sunny.UI.UILabel(); this.uiLabel3 = new Sunny.UI.UILabel();
this.uiLabel2 = new Sunny.UI.UILabel(); this.uiLabel2 = new Sunny.UI.UILabel();
this.col_code = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uiSwitch1 = new Sunny.UI.UISwitch();
this.col_zxd = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uiLabel11 = new Sunny.UI.UILabel();
this.col_area = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uiNumPadTextBox1 = new Sunny.UI.UINumPadTextBox();
this.col_contrast_lower = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_contrast_top = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_IsOR = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.col_Len = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_Cnt = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uiTitlePanel2.SuspendLayout(); this.uiTitlePanel2.SuspendLayout();
this.uiTitlePanel3.SuspendLayout(); this.uiTitlePanel3.SuspendLayout();
this.uiTitlePanel4.SuspendLayout(); this.uiTitlePanel4.SuspendLayout();
@ -373,6 +376,9 @@
// uiTitlePanel4 // uiTitlePanel4
// //
this.uiTitlePanel4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.uiTitlePanel4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.uiTitlePanel4.Controls.Add(this.uiNumPadTextBox1);
this.uiTitlePanel4.Controls.Add(this.uiLabel11);
this.uiTitlePanel4.Controls.Add(this.uiSwitch1);
this.uiTitlePanel4.Controls.Add(this.btnDefectOption); this.uiTitlePanel4.Controls.Add(this.btnDefectOption);
this.uiTitlePanel4.Controls.Add(this.swcDefectPauseForUser); this.uiTitlePanel4.Controls.Add(this.swcDefectPauseForUser);
this.uiTitlePanel4.Controls.Add(this.numDefectCountLimit); this.uiTitlePanel4.Controls.Add(this.numDefectCountLimit);
@ -579,6 +585,68 @@
this.uiDataGridView1.Style = Sunny.UI.UIStyle.Custom; this.uiDataGridView1.Style = Sunny.UI.UIStyle.Custom;
this.uiDataGridView1.TabIndex = 21; this.uiDataGridView1.TabIndex = 21;
// //
// col_code
//
this.col_code.DataPropertyName = "Code";
this.col_code.HeaderText = "code";
this.col_code.MinimumWidth = 8;
this.col_code.Name = "col_code";
this.col_code.ReadOnly = true;
this.col_code.Visible = false;
this.col_code.Width = 150;
//
// col_zxd
//
this.col_zxd.DataPropertyName = "ZXD";
dataGridViewCellStyle3.NullValue = null;
this.col_zxd.DefaultCellStyle = dataGridViewCellStyle3;
this.col_zxd.HeaderText = "置信度";
this.col_zxd.MinimumWidth = 20;
this.col_zxd.Name = "col_zxd";
this.col_zxd.Width = 150;
//
// col_area
//
this.col_area.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.col_area.DataPropertyName = "Area";
this.col_area.HeaderText = "面积(mm^2)";
this.col_area.MinimumWidth = 20;
this.col_area.Name = "col_area";
//
// col_contrast_lower
//
this.col_contrast_lower.DataPropertyName = "Contrast";
this.col_contrast_lower.HeaderText = "对比度(下限)";
this.col_contrast_lower.MinimumWidth = 80;
this.col_contrast_lower.Name = "col_contrast_lower";
this.col_contrast_lower.Width = 120;
//
// col_contrast_top
//
this.col_contrast_top.HeaderText = "对比度(上限)";
this.col_contrast_top.MinimumWidth = 80;
this.col_contrast_top.Name = "col_contrast_top";
this.col_contrast_top.Width = 120;
//
// col_IsOR
//
this.col_IsOR.HeaderText = "或向选择";
this.col_IsOR.MinimumWidth = 8;
this.col_IsOR.Name = "col_IsOR";
this.col_IsOR.Width = 150;
//
// col_Len
//
this.col_Len.HeaderText = "报警长度(m)";
this.col_Len.Name = "col_Len";
this.col_Len.Visible = false;
//
// col_Cnt
//
this.col_Cnt.HeaderText = "报警数量";
this.col_Cnt.Name = "col_Cnt";
this.col_Cnt.Visible = false;
//
// uiTitlePanel6 // uiTitlePanel6
// //
this.uiTitlePanel6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.uiTitlePanel6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -957,67 +1025,45 @@
this.uiLabel2.Text = "产品颜色"; this.uiLabel2.Text = "产品颜色";
this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// col_code // uiSwitch1
// //
this.col_code.DataPropertyName = "Code"; this.uiSwitch1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.col_code.HeaderText = "code"; this.uiSwitch1.Location = new System.Drawing.Point(9, 294);
this.col_code.MinimumWidth = 8; this.uiSwitch1.MinimumSize = new System.Drawing.Size(1, 1);
this.col_code.Name = "col_code"; this.uiSwitch1.Name = "uiSwitch1";
this.col_code.ReadOnly = true; this.uiSwitch1.Size = new System.Drawing.Size(80, 29);
this.col_code.Visible = false; this.uiSwitch1.Style = Sunny.UI.UIStyle.Custom;
this.col_code.Width = 150; this.uiSwitch1.TabIndex = 15;
this.uiSwitch1.Text = "uiSwitch1";
// //
// col_zxd // uiLabel11
// //
this.col_zxd.DataPropertyName = "ZXD"; this.uiLabel11.AutoSize = true;
dataGridViewCellStyle3.NullValue = null; this.uiLabel11.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.col_zxd.DefaultCellStyle = dataGridViewCellStyle3; this.uiLabel11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.col_zxd.HeaderText = "置信度"; this.uiLabel11.Location = new System.Drawing.Point(5, 268);
this.col_zxd.MinimumWidth = 20; this.uiLabel11.Name = "uiLabel11";
this.col_zxd.Name = "col_zxd"; this.uiLabel11.Size = new System.Drawing.Size(106, 21);
this.col_zxd.Width = 150; this.uiLabel11.Style = Sunny.UI.UIStyle.Custom;
this.uiLabel11.TabIndex = 16;
this.uiLabel11.Text = "厚度检测判断";
this.uiLabel11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// col_area // uiNumPadTextBox1
// //
this.col_area.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.uiNumPadTextBox1.FillColor = System.Drawing.Color.White;
this.col_area.DataPropertyName = "Area"; this.uiNumPadTextBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.col_area.HeaderText = "面积(mm^2)"; this.uiNumPadTextBox1.Location = new System.Drawing.Point(96, 294);
this.col_area.MinimumWidth = 20; this.uiNumPadTextBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.col_area.Name = "col_area"; this.uiNumPadTextBox1.MinimumSize = new System.Drawing.Size(63, 0);
// this.uiNumPadTextBox1.Name = "uiNumPadTextBox1";
// col_contrast_lower this.uiNumPadTextBox1.NumPadType = Sunny.UI.NumPadType.Integer;
// this.uiNumPadTextBox1.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
this.col_contrast_lower.DataPropertyName = "Contrast"; this.uiNumPadTextBox1.Size = new System.Drawing.Size(132, 29);
this.col_contrast_lower.HeaderText = "对比度(下限)"; this.uiNumPadTextBox1.Style = Sunny.UI.UIStyle.Custom;
this.col_contrast_lower.MinimumWidth = 80; this.uiNumPadTextBox1.TabIndex = 17;
this.col_contrast_lower.Name = "col_contrast_lower"; this.uiNumPadTextBox1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
this.col_contrast_lower.Width = 120; this.uiNumPadTextBox1.Watermark = "";
//
// col_contrast_top
//
this.col_contrast_top.HeaderText = "对比度(上限)";
this.col_contrast_top.MinimumWidth = 80;
this.col_contrast_top.Name = "col_contrast_top";
this.col_contrast_top.Width = 120;
//
// col_IsOR
//
this.col_IsOR.HeaderText = "或向选择";
this.col_IsOR.MinimumWidth = 8;
this.col_IsOR.Name = "col_IsOR";
this.col_IsOR.Width = 150;
//
// col_Len
//
this.col_Len.HeaderText = "报警长度(m)";
this.col_Len.Name = "col_Len";
this.col_Len.Visible = false;
//
// col_Cnt
//
this.col_Cnt.HeaderText = "报警数量";
this.col_Cnt.Name = "col_Cnt";
this.col_Cnt.Visible = false;
// //
// FProductInfo // FProductInfo
// //
@ -1111,5 +1157,8 @@
private System.Windows.Forms.DataGridViewCheckBoxColumn col_IsOR; private System.Windows.Forms.DataGridViewCheckBoxColumn col_IsOR;
private System.Windows.Forms.DataGridViewTextBoxColumn col_Len; private System.Windows.Forms.DataGridViewTextBoxColumn col_Len;
private System.Windows.Forms.DataGridViewTextBoxColumn col_Cnt; private System.Windows.Forms.DataGridViewTextBoxColumn col_Cnt;
private Sunny.UI.UINumPadTextBox uiNumPadTextBox1;
private Sunny.UI.UILabel uiLabel11;
private Sunny.UI.UISwitch uiSwitch1;
} }
} }

View File

@ -46,6 +46,13 @@ namespace LeatherApp.Page
//if (dataGridView1.RowHeadersVisible) dataGridView1.TopLeftHeaderCell.Value = "SPH/CYL"; //if (dataGridView1.RowHeadersVisible) dataGridView1.TopLeftHeaderCell.Value = "SPH/CYL";
#endregion #endregion
this.rbMaterial0.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 0).Value<string>("name");
this.rbMaterial1.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 1).Value<string>("name");
this.rbMaterial2.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 2).Value<string>("name");
this.rbMaterial3.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 3).Value<string>("name");
this.rbMaterial4.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 4).Value<string>("name");
this.rbMaterial5.Text = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 5).Value<string>("name");
initData(); initData();
} }
private void initData() private void initData()
@ -112,7 +119,7 @@ namespace LeatherApp.Page
{ {
clear(resetAll); clear(resetAll);
string[] codes= pcode.Split('-'); string[] codes= pcode.Split('-');
if (codes[0]=="0" || Config.SuedeList.Contains(codes[0])) if (codes[0]=="0" || Config.SuedeList1.Contains(codes[0]))
this.rbMaterial0.Checked = true; this.rbMaterial0.Checked = true;
else if (codes[0] == "1") else if (codes[0] == "1")
this.rbMaterial1.Checked = true; this.rbMaterial1.Checked = true;
@ -124,6 +131,9 @@ namespace LeatherApp.Page
this.rbMaterial4.Checked = true; this.rbMaterial4.Checked = true;
else if (codes[0] == "5") else if (codes[0] == "5")
this.rbMaterial5.Checked = true; this.rbMaterial5.Checked = true;
else
this.rbMaterial1.Checked = true;
this.cmbColor.SelectedValue = int.Parse(codes[1]); this.cmbColor.SelectedValue = int.Parse(codes[1]);
} }
else else
@ -327,6 +337,12 @@ namespace LeatherApp.Page
model.DefectCountLimit = int.Parse(numDefectCountLimit.Text.Trim()); model.DefectCountLimit = int.Parse(numDefectCountLimit.Text.Trim());
model.DefectPauseForUser = swcDefectPauseForUser.Active; model.DefectPauseForUser = swcDefectPauseForUser.Active;
model.OpenThicknessDetection = uiSwitch1.Active;
int ival;
if (int.TryParse(uiNumPadTextBox1.Text, out ival))
model.ThicknessDetectionStopDis = int.Parse(uiNumPadTextBox1.Text.Trim());
else
model.ThicknessDetectionStopDis = 0;
//datagrid //datagrid
if (model.QualifiedLimitList == null) if (model.QualifiedLimitList == null)
model.QualifiedLimitList = new List<Models.QualifiedLimit>(); model.QualifiedLimitList = new List<Models.QualifiedLimit>();
@ -344,8 +360,8 @@ namespace LeatherApp.Page
ContrastTop = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value) ? PercentToContrast(Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value)) : 0, ContrastTop = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value) ? PercentToContrast(Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_contrast_top"].Value)) : 0,
IsOR = Convert.ToBoolean(uiDataGridView1.Rows[i].Cells["col_IsOR"].Value), IsOR = Convert.ToBoolean(uiDataGridView1.Rows[i].Cells["col_IsOR"].Value),
//DefectWarnLength = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_Len"].Value) ? (int)Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_Len"].Value) : 0, DefectWarnLength = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_Len"].Value) ? (int)Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_Len"].Value) : 0,
//DefectWarnCnt = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_Cnt"].Value) ? (int)Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_Cnt"].Value) : 0, DefectWarnCnt = Utils.Util.IsDecimal(uiDataGridView1.Rows[i].Cells["col_Cnt"].Value) ? (int)Convert.ToDouble(uiDataGridView1.Rows[i].Cells["col_Cnt"].Value) : 0,
ModifyUserCode = Config.loginUser.Code, ModifyUserCode = Config.loginUser.Code,
CreateUserCode = Config.loginUser.Code CreateUserCode = Config.loginUser.Code

View File

@ -127,8 +127,10 @@ namespace LeatherApp.Page
private void btnExport_Click(object sender, EventArgs e) private void btnExport_Click(object sender, EventArgs e)
{ {
int err = 0;
try try
{ {
if (this.uiDataGridView1.CurrentRow == null) if (this.uiDataGridView1.CurrentRow == null)
return; return;
@ -140,6 +142,7 @@ namespace LeatherApp.Page
if (string.IsNullOrWhiteSpace(path)) if (string.IsNullOrWhiteSpace(path))
return; return;
err = 1;
//var list = uiDataGridView1.DataSource as List<Records>; //var list = uiDataGridView1.DataSource as List<Records>;
//var table = ExcelUtil.ConvertToDataTable<Records>(list); //var table = ExcelUtil.ConvertToDataTable<Records>(list);
@ -149,6 +152,7 @@ namespace LeatherApp.Page
//绘图1 //绘图1
double len = Math.Round(record.Len*100, 2);//cm double len = Math.Round(record.Len*100, 2);//cm
this.reDrawDefectPoints(record.DefectInfoList, new double[] { 0, Math.Round(record.FaceWidthMax + 0.005f, 2) }, new double[] { 0, len }); this.reDrawDefectPoints(record.DefectInfoList, new double[] { 0, Math.Round(record.FaceWidthMax + 0.005f, 2) }, new double[] { 0, len });
err = 2;
//绘图2 //绘图2
//var points = Array.ConvertAll(record.FaceWidthListStr.Split(new[] { ',', }, StringSplitOptions.RemoveEmptyEntries),Double.Parse).ToList(); //var points = Array.ConvertAll(record.FaceWidthListStr.Split(new[] { ',', }, StringSplitOptions.RemoveEmptyEntries),Double.Parse).ToList();
//reDrawFaceWidth(record.FacePointList, //reDrawFaceWidth(record.FacePointList,
@ -157,13 +161,13 @@ namespace LeatherApp.Page
reDrawFaceWidth(record.FacePointList, reDrawFaceWidth(record.FacePointList,
new double[] { 0, Math.Round(len + 0.005f, 2) }, new double[] { 0, Math.Round(len + 0.005f, 2) },
new double[] { 130, 160 }); new double[] { 130, 160 });
err = 3;
// //
foreach (var item in list) { foreach (var item in list) {
item.Name = Config.getDefectName(item.Code); item.Name = Config.getDefectName(item.Code);
//item.Height = item.Height / 100; //单位错误,保证单位一致 //item.Height = item.Height / 100; //单位错误,保证单位一致
} }
err = 4;
// //
string Grade = ""; string Grade = "";
if (record.Grade < 1) Grade = ""; if (record.Grade < 1) Grade = "";
@ -179,17 +183,20 @@ namespace LeatherApp.Page
Grade= Grade, Grade= Grade,
DateTime = record.CreateTime.ToString("yyyy年MM月dd日 HH:mm") DateTime = record.CreateTime.ToString("yyyy年MM月dd日 HH:mm")
}; };
err = 5;
data.DefectTotal = record.DefectInfoList.GroupBy(x => x.Name).Select(g => new JDefectTotal { Name = g.Key,Count=g.Count() }).ToList(); data.DefectTotal = record.DefectInfoList.GroupBy(x => x.Name).Select(g => new JDefectTotal { Name = g.Key,Count=g.Count() }).ToList();
data.DefectDetail = record.DefectInfoList.Select(x => new JDefectDetail { data.DefectDetail = record.DefectInfoList.Select(x => new JDefectDetail {
Index=x.PhotoIndex,Name=x.Name, X=x.X,Y=Math.Round(x.Y/100.0d,2),Width=x.Width * 10,Height=x.Height * 10,ZXD=x.ZXD,Area=x.Area * 100,Contrast=x.Contrast }) Index=x.PhotoIndex,Name=x.Name, X=x.X,Y=Math.Round(x.Y/100.0d,2),Width=x.Width * 10,Height=x.Height * 10,ZXD=x.ZXD,Area=x.Area * 100,Contrast=x.Contrast })
.OrderBy(x=>x.Index).ThenBy(x=>x.Y).ToList(); .OrderBy(x=>x.Index).ThenBy(x=>x.Y).ToList();
err = 6;
data.Pdt = productService.GetModelNav(record.ProductId); data.Pdt = productService.GetModelNav(record.ProductId);
data.xyPix = $"X:{Config.cm2px_x},Y:{Config.cm2px_y}"; data.xyPix = $"X:{Config.cm2px_x},Y:{Config.cm2px_y}";
err = 7;
var image1 = captureControl(this.lineChartDefect); var image1 = captureControl(this.lineChartDefect);
var image2 = captureControl(this.lineChartFaceWidth); var image2 = captureControl(this.lineChartFaceWidth);
var filePath = $"{path}缺陷列表_{record.BatchId}_{record.ReelId}.xlsx"; var filePath = $"{path}缺陷列表_{record.BatchId}_{record.ReelId}.xlsx";
err = 8;
exportTabel(data, image1, image2, filePath); exportTabel(data, image1, image2, filePath);
//if (!res) //if (!res)
// throw new Exception("导出失败!"); // throw new Exception("导出失败!");
@ -199,7 +206,7 @@ namespace LeatherApp.Page
} }
catch (Exception ex) catch (Exception ex)
{ {
UIMessageTip.ShowError(ex.Message, 2000); UIMessageTip.ShowError($"err:{err} + {ex.Message}", 2000);
API.OutputDebugString(ex.StackTrace); API.OutputDebugString(ex.StackTrace);
} }
} }
@ -819,6 +826,7 @@ namespace LeatherApp.Page
//series.Smooth = false; //series.Smooth = false;
} }
if(series != null)
series.Add(item.CentreX, item.CentreY / 100); //cm -> m series.Add(item.CentreX, item.CentreY / 100); //cm -> m
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.9")] [assembly: AssemblyVersion("1.0.2.10")]
[assembly: AssemblyFileVersion("1.0.2.9")] [assembly: AssemblyFileVersion("1.0.2.10")]

View File

@ -6,16 +6,166 @@ using System.Threading.Tasks;
using System.Xaml; using System.Xaml;
using DocumentFormat.OpenXml.Vml; using DocumentFormat.OpenXml.Vml;
using OpenCvSharp; using OpenCvSharp;
using OpenCvSharp.XImgProc;
namespace LeatherApp.Utils namespace LeatherApp.Utils
{ {
public class OpenCVUtil public class OpenCVUtil
{ {
#region
private static StructuredEdgeDetection _edgeDetect;
public static void LoadEdgeMode()
{
if (_edgeDetect == null)
_edgeDetect = OpenCvSharp.XImgProc.CvXImgProc.CreateStructuredEdgeDetection("model.yml");
}
/// <summary>
/// 模型寻边
/// </summary>
/// <param name="image"></param>
/// <param name="FindType"></param>
/// <param name="Roi"></param>
/// <param name="IsLeft"></param>
/// <returns></returns>
private static int EdgeClipping3(Mat image, int FindType, Rect Roi, bool IsLeft)
{
Mat mat_rgb = image.Clone(Roi);
int height = mat_rgb.Rows;
int width = mat_rgb.Cols;
int sf = 10; //缩放比例
int pix = 5; //获取均值区域长宽像素
int pointNum = 15; //获取找遍点数
int offsetGray = 5; //二值化偏差
int length_t = 0;
List<int> lines = new List<int>();
List<int> total_t = new List<int>();
//按比例缩放
double sf_height = height / sf;
double sf_width = width / sf;
Cv2.Resize(mat_rgb, mat_rgb, new Size(sf_width, sf_height), 0, 0, InterpolationFlags.Linear);
Mat himg = new Mat();
Mat edgeimg = new Mat();
Cv2.CvtColor(mat_rgb, edgeimg, ColorConversionCodes.BGR2RGB);
Mat edges = new Mat();
edgeimg.ConvertTo(edgeimg, MatType.CV_32F, 1 / 255.0);
if (_edgeDetect == null)
LoadEdgeMode();
//Cv2.Normalize(edgeimg, edgeimg, 1.0, 0, NormTypes.L2, -1);
_edgeDetect.DetectEdges(edgeimg, edges);
Mat image_Otsu = new Mat();
int hDis = (int)sf_height / (pointNum + 2); //去除边缘两点
edges.ConvertTo(image_Otsu, MatType.CV_8U, 255.0);
Cv2.Threshold(image_Otsu, image_Otsu, 0, 255, ThresholdTypes.Otsu);
// 定义空数组保存结果
int[] total = new int[pointNum];
// 平均截取pointNum行数据并处理图像
for (int i = 0; i < pointNum; i++)
{
// 截取当前行的图像
Rect roi = new Rect(0, hDis + hDis * i, (int)sf_width, 1);
Mat current_segment = image_Otsu.Clone(roi);
//Mat filled_image3 = current_segment.Clone();
Mat filled_image3 = current_segment;
#if true
//从左到右判断边和从右到左判断边
int numX = 0;
int tm = 0;
byte tempVal = 0;
bool findOne = false;
if (!IsLeft)
{
tempVal = filled_image3.At<byte>(0, 0);
//filled_image3.
for (int j = 0; j < filled_image3.Cols; j++)
{
if (filled_image3.At<byte>(0, j) != tempVal)
{
if (!findOne)
{
tm = j;
findOne = true;
tempVal = filled_image3.At<byte>(0, j);
}
else
{
//numX = j;
numX = (tm + j) / 2;
break;
}
}
}
}
else
{
tempVal = filled_image3.At<byte>(0, filled_image3.Cols - 1);
for (int j = filled_image3.Cols - 1; j >= 0; j--)
{
if (filled_image3.At<byte>(0, j) != tempVal)
{
if (!findOne)
{
tm = j;
findOne = true;
tempVal = filled_image3.At<byte>(0, j);
}
else
{
//numX = j;
numX = (tm + j) / 2;
break;
}
}
}
}
#else
int numX = Cv2.CountNonZero(filled_image3);
#endif
//length_t = (numX > (sf_width / 2)) ? numX :(int)(sf_width - numX);
length_t = numX;
total[i] = (length_t);
if (length_t > 0)
total_t.Add(length_t);
}
// 取平均值作为宽度
int length = 0;
if (total_t.Count > 0)
{
length = (int)total_t.Average();
if (IsLeft)
length = length - 0;
else
length = length + 0;
}
//乘上换算系数还原
length = length * sf + Roi.X;
return length;
}
#endregion
public static Mat resize(Mat mat, int width, int height, out int xw, out int xh) public static Mat resize(Mat mat, int width, int height, out int xw, out int xh)
{ {
OpenCvSharp.Size dsize = new OpenCvSharp.Size(width, height); OpenCvSharp.Size dsize = new OpenCvSharp.Size(width, height);
Mat mat2 = new Mat(); //Mat mat2 = new Mat();
//Cv2.Resize(mat, mat2, dsize); //Cv2.Resize(mat, mat2, dsize);
ResizeUniform(mat, dsize, out mat2, out xw, out xh); //ResizeUniform(mat, dsize, out mat2, out xw, out xh);
xw = xh = 0;
Mat mat2 = new Mat(height, width, MatType.CV_8UC3, new Scalar(114, 114, 114));
Rect roi = new Rect((width - mat.Cols) / 2, (height - mat.Rows) / 2, mat.Cols, mat.Rows);
mat.CopyTo(new Mat(mat2, roi));
return mat2; return mat2;
} }
public static int ResizeUniform(Mat src, Size dst_size, out Mat dst, out int xw, out int xh) public static int ResizeUniform(Mat src, Size dst_size, out Mat dst, out int xw, out int xh)
@ -368,7 +518,7 @@ namespace LeatherApp.Utils
else else
Roi = new Rect(0, 0, bian, mat_rgb.Height); Roi = new Rect(0, 0, bian, mat_rgb.Height);
int type = isLeft ? 1 : 0; int type = isLeft ? 1 : 0;
int len = EdgeClipping2(mat_rgb, type, Roi, isLeft); int len = EdgeClipping3(mat_rgb, type, Roi, isLeft);
#if false #if false
//Mat mat_rgb = new Mat("E:\\CPL\\测试代码\\边缘检测\\test\\test\\test\\img\\19.bmp"); //Mat mat_rgb = new Mat("E:\\CPL\\测试代码\\边缘检测\\test\\test\\test\\img\\19.bmp");
Mat image_gray = new Mat(); Mat image_gray = new Mat();
@ -448,6 +598,10 @@ namespace LeatherApp.Utils
return cutImage(mat_rgb, mat_rgb.Width - length + marginHoleWidth, 0, length - marginHoleWidth, mat_rgb.Height); return cutImage(mat_rgb, mat_rgb.Width - length + marginHoleWidth, 0, length - marginHoleWidth, mat_rgb.Height);
else else
return cutImage(mat_rgb, 0, 0, length - marginHoleWidth, mat_rgb.Height); return cutImage(mat_rgb, 0, 0, length - marginHoleWidth, mat_rgb.Height);
//if (isLeft)
// return cutImage(mat_rgb, length + marginHoleWidth, 0, length - marginHoleWidth, mat_rgb.Height);
//else
// return cutImage(mat_rgb, 0, 0, length - marginHoleWidth, mat_rgb.Height);
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,68 @@
[
{
"id": 0,
"code": "laji",
"name": "垃圾",
"color": "#0080FF"
},
{
"id": 1,
"code": "liangdian",
"name": "亮点",
"color": "Lime"
},
{
"id": 2,
"code": "wuyin",
"name": "污印",
"color": "DarkViolet"
},
{
"id": 3,
"code": "jietou",
"name": "接头",
"color": "Magenta"
},
{
"id": 4,
"code": "bmss",
"name": "表面损伤",
"color": "Orange"
},
{
"id": 5,
"code": "qipi",
"name": "起皮",
"color": "Blue"
},
{
"id": 6,
"code": "tiaohen",
"name": "条痕",
"color": "Red"
},
{
"id": 7,
"code": "yayin",
"name": "压印",
"color": "Green"
},
{
"id": 8,
"code": "zhouyin",
"name": "皱印",
"color": "Yellow"
},
{
"id": 9,
"code": "yisesi",
"name": "异色丝",
"color": "CadetBlue"
},
{
"id": 10,
"code": "chongying",
"name": "重影",
"color": "Salmon"
}
]

View File

@ -1,86 +1,80 @@
[ [
{ {
"id": 0, "id": 0,
"code": "jiangbban", "code": "jb",
"name": "浆斑", "name": "浆斑",
"color": "Red" "color": "Red"
}, },
{ {
"id": 1, "id": 1,
"code": "wuyin", "code": "wy",
"name": "污印", "name": "污印",
"color": "Lime" "color": "Lime"
}, },
{ {
"id": 2, "id": 2,
"code": "mianjie", "code": "mj",
"name": "棉结", "name": "棉结",
"color": "DarkViolet" "color": "DarkViolet"
}, },
{ {
"id": 3, "id": 3,
"code": "huangyin", "code": "hy",
"name": "黄印", "name": "黄印",
"color": "Magenta" "color": "Magenta"
}, },
{ {
"id": 4, "id": 4,
"code": "laji", "code": "lj",
"name": "垃圾", "name": "垃圾",
"color": "Orange" "color": "Orange"
}, },
{ {
"id": 5, "id": 5,
"code": "yisesi", "code": "yss",
"name": "异色丝", "name": "异色丝",
"color": "Brown" "color": "Brown"
}, },
{ {
"id": 6, "id": 6,
"code": "zhouyin", "code": "zy",
"name": "皱印", "name": "皱印",
"color": "Olive" "color": "Olive"
}, },
{ {
"id": 7, "id": 7,
"code": "wenchong", "code": "wc",
"name": "蚊虫", "name": "蚊虫",
"color": "PaleGreen" "color": "PaleGreen"
}, },
{ {
"id": 8, "id": 8,
"code": "cashang", "code": "cs",
"name": "擦伤", "name": "擦伤",
"color": "CadetBlue" "color": "CadetBlue"
}, },
{ {
"id": 9, "id": 9,
"code": "chongying", "code": "cy",
"name": "重影", "name": "重影",
"color": "Aqua" "color": "Aqua"
}, },
{ {
"id": 10, "id": 10,
"code": "tingcheyin", "code": "tcy",
"name": "停车印", "name": "停车印",
"color": "YellowGreen" "color": "YellowGreen"
}, },
{ {
"id": 11, "id": 11,
"code": "jietou", "code": "jt",
"name": "接头", "name": "接头",
"color": "Blue" "color": "Blue"
}, },
{ {
"id": 12, "id": 12,
"code": "hengdang", "code": "na",
"name": "横档", "name": "荆条",
"color": "Blue" "color": "pink"
},
{
"id": 13,
"code": "jiangyin",
"name": "浆印",
"color": "Blue"
} }
] ]

View File

@ -0,0 +1,68 @@
[
{
"id": 0,
"code": "laji",
"name": "垃圾",
"color": "#0080FF"
},
{
"id": 1,
"code": "liangdian",
"name": "亮点",
"color": "Lime"
},
{
"id": 2,
"code": "wuyin",
"name": "污印",
"color": "DarkViolet"
},
{
"id": 3,
"code": "jietou",
"name": "接头",
"color": "Magenta"
},
{
"id": 4,
"code": "bmss",
"name": "表面损伤",
"color": "Orange"
},
{
"id": 5,
"code": "qipi",
"name": "起皮",
"color": "Blue"
},
{
"id": 6,
"code": "tiaohen",
"name": "条痕",
"color": "Red"
},
{
"id": 7,
"code": "yayin",
"name": "压印",
"color": "Green"
},
{
"id": 7,
"code": "zhouyin",
"name": "皱印",
"color": "Yellow"
},
{
"id": 8,
"code": "yisesi",
"name": "异色丝",
"color": "CadetBlue"
},
{
"id": 7,
"code": "chongying",
"name": "重影",
"color": "Salmon"
},
]

View File

@ -0,0 +1,56 @@
[
{
"id": 0,
"code": "laji",
"name": "垃圾",
"color": "#0080FF"
},
{
"id": 1,
"code": "wuyin",
"name": "污印",
"color": "Lime"
},
{
"id": 2,
"code": "jiangyin",
"name": "浆印",
"color": "DarkViolet"
},
{
"id": 3,
"code": "zhouyin",
"name": "皱印",
"color": "Magenta"
},
{
"id": 4,
"code": "hengdang",
"name": "横档",
"color": "Orange"
},
{
"id": 5,
"code": "jietou",
"name": "接头",
"color": "Blue"
},
{
"id": 6,
"code": "chongying",
"name": "重影",
"color": "Lime"
},
{
"id": 7,
"code": "aokeng",
"name": "凹坑",
"color": "Lime"
},
{
"id": 8,
"code": "bmss",
"name": "表面损伤",
"color": "Lime"
}
]

View File

@ -44,3 +44,93 @@ Global捕获到未处理异常System.ArgumentException
在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2024-07-25 10:08:02
Global捕获到未处理异常System.NullReferenceException
异常信息:未将对象引用设置到对象的实例。
异常堆栈: 在 LeatherApp.UIExtend.UIDefectImage.uiComboBox1_SelectedIndexChanged(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\UIExtend\UIDefectImage.cs:行号 60
在 Sunny.UI.UIComboBox.Box_SelectedIndexChanged(Object sender, EventArgs e)
在 System.EventHandler.Invoke(Object sender, EventArgs e)
在 System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
在 Sunny.UI.ListBoxEx.OnSelectedIndexChanged(EventArgs e)
在 System.Windows.Forms.ListBox.ClearSelected()
在 System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
在 System.Windows.Forms.ListControl.set_SelectedValue(Object value)
在 Sunny.UI.UIComboBox.set_SelectedValue(Object value)
在 LeatherApp.UIExtend.UIDefectImage.set_Code(String value) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\UIExtend\UIDefectImage.cs:行号 45
在 LeatherApp.Page.FHome_Defect.<init>b__4_0(DefectInfo item) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 36
在 System.Collections.Generic.List`1.ForEach(Action`1 action)
在 LeatherApp.Page.FHome_Defect.init() 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 35
在 LeatherApp.Page.FHome_Defect..ctor(List`1 lst, Mat img) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 29
在 LeatherApp.Page.FHome.button1_Click(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome.cs:行号 2157
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2024-07-25 10:08:55
Global捕获到未处理异常System.NullReferenceException
异常信息:未将对象引用设置到对象的实例。
异常堆栈: 在 LeatherApp.UIExtend.UIDefectImage.uiComboBox1_SelectedIndexChanged(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\UIExtend\UIDefectImage.cs:行号 60
在 Sunny.UI.UIComboBox.Box_SelectedIndexChanged(Object sender, EventArgs e)
在 System.EventHandler.Invoke(Object sender, EventArgs e)
在 System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
在 Sunny.UI.ListBoxEx.OnSelectedIndexChanged(EventArgs e)
在 System.Windows.Forms.ListBox.ClearSelected()
在 System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
在 System.Windows.Forms.ListControl.set_SelectedValue(Object value)
在 Sunny.UI.UIComboBox.set_SelectedValue(Object value)
在 LeatherApp.UIExtend.UIDefectImage.set_Code(String value) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\UIExtend\UIDefectImage.cs:行号 45
在 LeatherApp.Page.FHome_Defect.<init>b__4_0(DefectInfo item) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 36
在 System.Collections.Generic.List`1.ForEach(Action`1 action)
在 LeatherApp.Page.FHome_Defect.init() 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 35
在 LeatherApp.Page.FHome_Defect..ctor(List`1 lst, Mat img) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 29
在 LeatherApp.Page.FHome.button1_Click(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome.cs:行号 2157
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2024-07-25 10:10:27
Global捕获到未处理异常System.NullReferenceException
异常信息:未将对象引用设置到对象的实例。
异常堆栈: 在 LeatherApp.UIExtend.UIDefectImage.uiComboBox1_SelectedIndexChanged(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\UIExtend\UIDefectImage.cs:行号 60
在 Sunny.UI.UIComboBox.Box_SelectedIndexChanged(Object sender, EventArgs e)
在 System.EventHandler.Invoke(Object sender, EventArgs e)
在 System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
在 Sunny.UI.ListBoxEx.OnSelectedIndexChanged(EventArgs e)
在 System.Windows.Forms.ListBox.ClearSelected()
在 System.Windows.Forms.ListBox.set_SelectedIndex(Int32 value)
在 System.Windows.Forms.ListControl.set_SelectedValue(Object value)
在 Sunny.UI.UIComboBox.set_SelectedValue(Object value)
在 LeatherApp.UIExtend.UIDefectImage.set_Code(String value) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\UIExtend\UIDefectImage.cs:行号 45
在 LeatherApp.Page.FHome_Defect.<init>b__4_0(DefectInfo item) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 36
在 System.Collections.Generic.List`1.ForEach(Action`1 action)
在 LeatherApp.Page.FHome_Defect.init() 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 35
在 LeatherApp.Page.FHome_Defect..ctor(List`1 lst, Mat img) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome_Defect.cs:行号 29
在 LeatherApp.Page.FHome.button1_Click(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome.cs:行号 2157
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2024-07-25 10:49:30
Global捕获到未处理异常System.NullReferenceException
异常信息:未将对象引用设置到对象的实例。
异常堆栈: 在 LeatherApp.Page.FHome.button1_Click(Object sender, EventArgs e) 位置 E:\CPL\迈沐智能项目\2023\革博士\源码\V1.0\LeatherProject\LeatherApp\Page\FHome.cs:行号 2174
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

View File

@ -1,14 +1,26 @@
[ [
{ {
"code": "SHNY-PX", "code": 0,
"name": "超纤皮" "name": "超纤皮"
}, },
{ {
"code": "AGNY-ST", "code": 1,
"name": "纤皮" "name": "纤皮"
}, },
{ {
"code": "", "code": 2,
"name": "未知"
},
{
"code": 3,
"name": "未知"
},
{
"code": 4,
"name": "未知"
},
{
"code": 5,
"name": "未知" "name": "未知"
} }
] ]

View File

@ -34,6 +34,13 @@ ImagePath=F:\LeatherApp\images\
SaveAllImage=False SaveAllImage=False
SaveDefectSourceImage=False SaveDefectSourceImage=False
SaveDefectCutImage=False SaveDefectCutImage=False
cm2px_x=90
cm2px_y=90
MarginHoleWidth=0
MiddleSuperposition=0
IsSaveAllImage=False
IsSaveDefectSourceImage=False
IsSaveDefectCutImage=False
[DB] [DB]
DBConStr=server=localhost;Database=LeatherDB;Uid=root;Pwd=123456; AllowLoadLocalInfile=true DBConStr=server=localhost;Database=LeatherDB;Uid=root;Pwd=123456; AllowLoadLocalInfile=true
[ErpDB] [ErpDB]

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 MiB

File diff suppressed because one or more lines are too long