修改Mes逻辑
This commit is contained in:
parent
19da00146e
commit
ca2403b323
403
HisenceYoloDetection/MainForm.Designer.cs
generated
403
HisenceYoloDetection/MainForm.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -342,37 +342,37 @@ namespace HisenceYoloDetection
|
||||
{
|
||||
//报警地址
|
||||
//string url = "https://inner-apisix.hisense.com/mes-plus/api/Fcc/GetWorkOrderBOMlnfo?user_key=k7gzo1fsfcami7n5hmpxtybyluf9xeue";
|
||||
string url = "https://echo.hoppscotch.io";
|
||||
string PostUrl = url;
|
||||
DateTime dt= DateTime.Now;
|
||||
////string url = "https://echo.hoppscotch.io";
|
||||
//string PostUrl = url;
|
||||
//DateTime dt= DateTime.Now;
|
||||
|
||||
string starttime=string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017
|
||||
//string starttime=string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017
|
||||
|
||||
string startTime = starttime;
|
||||
string EndTime = starttime;
|
||||
string lineBody = "ZZ-P";
|
||||
string MaterialDescripts = "制冷器";
|
||||
string MaterialDescripts2 = "工艺管";
|
||||
JObject patientinfo = new JObject();
|
||||
JArray ids = new JArray();
|
||||
ids.Add(MaterialDescripts);
|
||||
ids.Add(MaterialDescripts2);
|
||||
patientinfo["startTime"] = startTime;
|
||||
patientinfo["EndTime"] = EndTime;
|
||||
patientinfo["lineBody"] = lineBody;
|
||||
patientinfo["MaterialDescripts"] = ids;
|
||||
string sendData = JsonConvert.SerializeObject(patientinfo);
|
||||
//eg: 发送Url需要的格式:sendData={"ids":[123],"Name":小黑}
|
||||
string resultData = Post(sendData, PostUrl);
|
||||
resultData = "{\r\n\t\"Result\": [],\r\n\t\"success\": false,\r\n\t\"ReturnMsg\": \"参数-starttime 不正确!\"\r\n}";
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(resultData);
|
||||
string sucessIf = jo["success"].ToString();
|
||||
if(sucessIf.ToLower()=="true")
|
||||
{
|
||||
string ProductType = jo["ProductType"].ToString();
|
||||
string FinalDefIo = jo["FinalDefIo"].ToString();
|
||||
//解析字段
|
||||
}
|
||||
//string startTime = starttime;
|
||||
//string EndTime = starttime;
|
||||
//string lineBody = "ZZ-P";
|
||||
//string MaterialDescripts = "制冷器";
|
||||
//string MaterialDescripts2 = "工艺管";
|
||||
//JObject patientinfo = new JObject();
|
||||
//JArray ids = new JArray();
|
||||
//ids.Add(MaterialDescripts);
|
||||
//ids.Add(MaterialDescripts2);
|
||||
//patientinfo["startTime"] = startTime;
|
||||
//patientinfo["EndTime"] = EndTime;
|
||||
//patientinfo["lineBody"] = lineBody;
|
||||
//patientinfo["MaterialDescripts"] = ids;
|
||||
//string sendData = JsonConvert.SerializeObject(patientinfo);
|
||||
////eg: 发送Url需要的格式:sendData={"ids":[123],"Name":小黑}
|
||||
//string resultData = Post(sendData, PostUrl);
|
||||
//resultData = "{\r\n\t\"Result\": [],\r\n\t\"success\": false,\r\n\t\"ReturnMsg\": \"参数-starttime 不正确!\"\r\n}";
|
||||
//JObject jo = (JObject)JsonConvert.DeserializeObject(resultData);
|
||||
//string sucessIf = jo["success"].ToString();
|
||||
//if(sucessIf.ToLower()=="true")
|
||||
//{
|
||||
// string ProductType = jo["ProductType"].ToString();
|
||||
// string FinalDefIo = jo["FinalDefIo"].ToString();
|
||||
// //解析字段
|
||||
//}
|
||||
if (_runHandleBefore == null)
|
||||
{
|
||||
_runHandleBefore = new AutoResetEvent(false);
|
||||
@ -1182,8 +1182,7 @@ namespace HisenceYoloDetection
|
||||
{
|
||||
_runHandleBefore.WaitOne();
|
||||
//这里改成和海信的对接需求
|
||||
|
||||
// if(Oldm_sKEYENCEBar!= m_sKEYENCEBar)
|
||||
#if false
|
||||
{
|
||||
// Oldm_sKEYENCEBar= m_sKEYENCEBar;
|
||||
//获取请求
|
||||
@ -1223,7 +1222,10 @@ namespace HisenceYoloDetection
|
||||
//解析字段
|
||||
}
|
||||
}
|
||||
//xKNow = GetModeFromBar("VWJ070633V0WW80F0120356");//从数据库中查询到这个条码的四轴的值
|
||||
#endif
|
||||
// if(Oldm_sKEYENCEBar!= m_sKEYENCEBar)
|
||||
|
||||
xKNow = GetModeFromBar("VWJ070541V0WW824F120223");//从数据库中查询到这个条码的四轴的值
|
||||
|
||||
|
||||
if (xKNow==null)
|
||||
@ -1288,8 +1290,8 @@ namespace HisenceYoloDetection
|
||||
// var resultMap = GetResultImage(resultMask, detectionResultShapes);
|
||||
}
|
||||
#endregion
|
||||
int YPos = 8715;
|
||||
int ZPos = 25000;
|
||||
int YPos = 14957;
|
||||
int ZPos = 4382;
|
||||
bool StopM = false;//第一次用信号挡
|
||||
/// <summary>
|
||||
/// 监听洗衣机544是否触发后面对射传感器 相机
|
||||
@ -1337,6 +1339,77 @@ namespace HisenceYoloDetection
|
||||
}
|
||||
if (iNum1 >= 2)
|
||||
{
|
||||
if (bBar)
|
||||
{
|
||||
_runHandleBefore.WaitOne();
|
||||
//这里改成和海信的对接需求
|
||||
#if false
|
||||
{
|
||||
// Oldm_sKEYENCEBar= m_sKEYENCEBar;
|
||||
//获取请求
|
||||
//报警地址
|
||||
string url = "https://inner-apisix.hisense.com/mes-plus/api/Fcc/GetWorkOrderBOMlnfo?user_key=k7gzo1fsfcami7n5hmpxtybyluf9xeue";
|
||||
// string url = "https://echo.hoppscotch.io";
|
||||
string PostUrl = url;
|
||||
DateTime dt = DateTime.Now;
|
||||
|
||||
string starttime = string.Format("{0:yyyy_mm_dd}", dt); //17 17 2017 2017
|
||||
|
||||
string startTime = starttime;
|
||||
string EndTime = starttime;
|
||||
string lineBody = "ZZ-P";//线体
|
||||
string MaterialDescripts = "制冷器";
|
||||
string MaterialDescripts2 = "工艺管";
|
||||
JObject patientinfo = new JObject();
|
||||
JArray ids = new JArray();
|
||||
ids.Add(MaterialDescripts);
|
||||
ids.Add(MaterialDescripts2);
|
||||
patientinfo["startTime"] = startTime;
|
||||
patientinfo["EndTime"] = EndTime;
|
||||
patientinfo["lineBody"] = lineBody;
|
||||
patientinfo["MaterialDescripts"] = ids;
|
||||
string sendData = JsonConvert.SerializeObject(patientinfo);
|
||||
//eg: 发送Url需要的格式:sendData={"ids":[123],"Name":小黑}
|
||||
string resultData = Post(sendData, PostUrl);
|
||||
resultData = "{\r\n\t\"Result\": [],\r\n\t\"success\": false,\r\n\t\"ReturnMsg\": \"参数-starttime 不正确!\"\r\n}";
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(resultData);
|
||||
string sucessIf = jo["success"].ToString();
|
||||
if (sucessIf.ToLower() == "true")
|
||||
{
|
||||
string ProductType = jo["ProductType"].ToString();
|
||||
string FinalDefIo = jo["FinalDefIo"].ToString();
|
||||
//WEBAPI得到条码
|
||||
xKNow = GetModeFromBar(ProductType);//从数据库中查询到这个条码的四轴的值
|
||||
//解析字段
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// if(Oldm_sKEYENCEBar!= m_sKEYENCEBar)
|
||||
|
||||
xKNow = GetModeFromBar("VWJ070541V0WW824F120223");//从数据库中查询到这个条码的四轴的值
|
||||
|
||||
|
||||
if (xKNow == null)
|
||||
{
|
||||
myLog("数据库没有条码匹配" + m_sKEYENCEBar, DateTime.Now);
|
||||
break;
|
||||
}
|
||||
//if(xKNow.OcrBar!= Old_xKNow.OcrBar)
|
||||
//{
|
||||
|
||||
//}
|
||||
if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$"))
|
||||
{
|
||||
// Old_xKNow = xKNow;
|
||||
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
|
||||
bBarTriger = true;
|
||||
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(2);
|
||||
bBar = false;
|
||||
#if true
|
||||
|
||||
if (bBarTriger)//证明读码器读到东西
|
||||
@ -1381,15 +1454,15 @@ namespace HisenceYoloDetection
|
||||
|
||||
//Cam2.SnapshotCount = 0;
|
||||
//Cam2.Snapshot();
|
||||
myLog("第二次采集图像", DateTime.Now);
|
||||
//myLog("第二次采集图像", DateTime.Now);
|
||||
|
||||
//if (xKNow != null)
|
||||
//{
|
||||
// MoveToP(xKNow.MoveTwoX, xKNow.MoveTwoY, xKNow.MoveTwoZ);
|
||||
//}
|
||||
|
||||
MoveToP(51043, YPos, ZPos + (int)(dismove));
|
||||
Cam1.Snapshot();
|
||||
// MoveToP(51043, YPos, ZPos + (int)(dismove));
|
||||
//Cam1.Snapshot();
|
||||
MoveToP(5815, YPos, ZPos);
|
||||
melsecPLCTCPDriver.WriteInt("550", 0);//方行
|
||||
//Thread.Sleep(300);//洗衣机可能过不去
|
||||
@ -1541,7 +1614,7 @@ namespace HisenceYoloDetection
|
||||
//Cam1ImgTwo = cameraMat;
|
||||
|
||||
IfCam1TwoTriger = true;
|
||||
originMatShow2.Image = cameraMat.ToBitmap();
|
||||
//originMatShow2.Image = cameraMat.ToBitmap();
|
||||
_runHandleAfter.Set();
|
||||
}
|
||||
|
||||
@ -1569,7 +1642,7 @@ namespace HisenceYoloDetection
|
||||
Cam2ImgShowBar = cameraMat;
|
||||
IfCam2Triger = true;
|
||||
|
||||
originMat2Show.Image = cameraMat.ToBitmap();
|
||||
//originMat2Show.Image = cameraMat.ToBitmap();
|
||||
//_runHandleAfter.Set();
|
||||
// CamShow2.ImaMAt = cameraMat;
|
||||
cameraMat.ImWrite(fitImageFolder + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1.jpg");
|
||||
@ -1709,26 +1782,26 @@ namespace HisenceYoloDetection
|
||||
|
||||
}
|
||||
|
||||
//进行推理
|
||||
MLRequest req2 = new MLRequest();
|
||||
req2.currentMat = Cam1ImgTwo;
|
||||
req2.ResizeWidth = 640;
|
||||
req2.ResizeHeight = 640;
|
||||
req2.Score = 0.3f;
|
||||
req2.in_lable_path = LablePath;//标签路径
|
||||
req2.confThreshold = 0.3f;//模型置信度
|
||||
req2.iouThreshold = 0.4f;//检测IOU
|
||||
req2.out_node_name = "output";
|
||||
MLResult mL2 = simboObjectDetection.RunInferenceFixed(req2);
|
||||
if (mL2.ResultMap != null)
|
||||
{
|
||||
mL2.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
|
||||
ResultMatShow2.Image = mL2.ResultMap;
|
||||
}
|
||||
////进行推理
|
||||
//MLRequest req2 = new MLRequest();
|
||||
//req2.currentMat = Cam1ImgTwo;
|
||||
//req2.ResizeWidth = 640;
|
||||
//req2.ResizeHeight = 640;
|
||||
//req2.Score = 0.3f;
|
||||
//req2.in_lable_path = LablePath;//标签路径
|
||||
//req2.confThreshold = 0.3f;//模型置信度
|
||||
//req2.iouThreshold = 0.4f;//检测IOU
|
||||
//req2.out_node_name = "output";
|
||||
//MLResult mL2 = simboObjectDetection.RunInferenceFixed(req2);
|
||||
//if (mL2.ResultMap != null)
|
||||
//{
|
||||
// mL2.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
|
||||
// ResultMatShow2.Image = mL2.ResultMap;
|
||||
//}
|
||||
|
||||
List<string> strMatListTwo = new List<string>();
|
||||
List<string> strMatFuzzyListTwo = new List<string>();
|
||||
Mat mResultCut2 = req2.currentMat.Clone();
|
||||
// Mat mResultCut2 = req2.currentMat.Clone();
|
||||
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
|
||||
Dictionary<string, bool> keyValueResult2 = new Dictionary<string, bool>();
|
||||
#region 先执行定位比对
|
||||
@ -1736,10 +1809,10 @@ namespace HisenceYoloDetection
|
||||
string[] listLabels = xKNow.Detect.Split(",");
|
||||
|
||||
MLResult MLsum = mL;
|
||||
for (int i = 0; i < mL2.ResultDetails.Count; i++)
|
||||
{
|
||||
MLsum.ResultDetails.Add((DetectionResultDetail)mL2.ResultDetails[i]);
|
||||
}
|
||||
//for (int i = 0; i < mL2.ResultDetails.Count; i++)
|
||||
//{
|
||||
// MLsum.ResultDetails.Add((DetectionResultDetail)mL2.ResultDetails[i]);
|
||||
//}
|
||||
string[] RealLabels = new string[MLsum.ResultDetails.Count];
|
||||
string detstr = "";
|
||||
for (int i = 0; i < MLsum.ResultDetails.Count; i++)
|
||||
@ -1770,7 +1843,7 @@ namespace HisenceYoloDetection
|
||||
InsertSqlRunDataButton(ref keyValueResult, false, ref mResultCut, mL, mLButton, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||||
|
||||
|
||||
InsertSqlRunData(ref keyValueResult2, false, ref mResultCut2, mL2, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
|
||||
// InsertSqlRunData(ref keyValueResult2, false, ref mResultCut2, mL2, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
|
||||
sw.Stop();
|
||||
myLog("插入面板时间" + sw.ElapsedMilliseconds, DateTime.Now);
|
||||
|
||||
@ -2133,7 +2206,7 @@ namespace HisenceYoloDetection
|
||||
CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
|
||||
|
||||
*/
|
||||
OnGetBar();
|
||||
// OnGetBar();
|
||||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//黄灯
|
||||
TriggerCameral2();
|
||||
ReadyDetect();
|
||||
@ -2538,36 +2611,36 @@ namespace HisenceYoloDetection
|
||||
|
||||
|
||||
|
||||
MLRequest CamTwoI = new MLRequest();
|
||||
CamTwoI.currentMat = Cv2.ImRead(Cam1TwoPath);
|
||||
CamTwoI.ResizeWidth = 640;
|
||||
CamTwoI.ResizeHeight = 640;
|
||||
CamTwoI.Score = 0.3f;
|
||||
CamTwoI.in_lable_path = LablePath;//标签路径
|
||||
CamTwoI.confThreshold = 0.3f;//模型置信度
|
||||
CamTwoI.iouThreshold = 0.4f;//检测IOU
|
||||
CamTwoI.out_node_name = "output";
|
||||
MLResult mL4 = simboObjectDetection.RunInferenceFixed(CamTwoI);
|
||||
//if (mL4.IsSuccess)
|
||||
//{
|
||||
// DateTime dt = DateTime.Now;
|
||||
// mL4.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
|
||||
//MLRequest CamTwoI = new MLRequest();
|
||||
//CamTwoI.currentMat = Cv2.ImRead(Cam1TwoPath);
|
||||
//CamTwoI.ResizeWidth = 640;
|
||||
//CamTwoI.ResizeHeight = 640;
|
||||
//CamTwoI.Score = 0.3f;
|
||||
//CamTwoI.in_lable_path = LablePath;//标签路径
|
||||
//CamTwoI.confThreshold = 0.3f;//模型置信度
|
||||
//CamTwoI.iouThreshold = 0.4f;//检测IOU
|
||||
//CamTwoI.out_node_name = "output";
|
||||
//MLResult mL4 = simboObjectDetection.RunInferenceFixed(CamTwoI);
|
||||
////if (mL4.IsSuccess)
|
||||
////{
|
||||
//// DateTime dt = DateTime.Now;
|
||||
//// mL4.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
|
||||
|
||||
//}
|
||||
List<string> strMatListTwo = new List<string>();
|
||||
List<string> strMatFuzzyListTwo = new List<string>();
|
||||
Mat mResultCut2 = CamTwoI.currentMat.Clone();
|
||||
Dictionary<string, bool> keyValueResult2 = new Dictionary<string, bool>();
|
||||
InsertSqlRunData(ref keyValueResult2, true, ref mResultCut2, mL4, ref xK_HisenceSQLWord, ref xkWord, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
|
||||
////}
|
||||
//List<string> strMatListTwo = new List<string>();
|
||||
//List<string> strMatFuzzyListTwo = new List<string>();
|
||||
//Mat mResultCut2 = CamTwoI.currentMat.Clone();
|
||||
//Dictionary<string, bool> keyValueResult2 = new Dictionary<string, bool>();
|
||||
//InsertSqlRunData(ref keyValueResult2, true, ref mResultCut2, mL4, ref xK_HisenceSQLWord, ref xkWord, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
|
||||
|
||||
|
||||
|
||||
InsertXKHisenceWordData(xkWord);//往关键字表中插入一条数据
|
||||
//文本区域
|
||||
List<string> bingji = strMatListOne.Union(strMatListTwo).ToList();//并(全)集
|
||||
List<string> Fuzzybingji = strMatFuzzyListOne.Union(strMatFuzzyListTwo).ToList();//并(全)集
|
||||
string OcrTextone = bingji.Join("##");
|
||||
string OcrTextTwo = Fuzzybingji.Join("##");
|
||||
//List<string> bingji = strMatListOne.Union(strMatListTwo).ToList();//并(全)集
|
||||
//List<string> Fuzzybingji = strMatFuzzyListOne.Union(strMatFuzzyListTwo).ToList();//并(全)集
|
||||
string OcrTextone = strMatListOne.Join("##");
|
||||
string OcrTextTwo = strMatFuzzyListOne.Join("##");
|
||||
|
||||
//string OcrTextinsert = "";
|
||||
//List<string> bingji = strMatListListOne.Union(strMatListListTwo).ToList();//并(全)集
|
||||
@ -2580,10 +2653,10 @@ namespace HisenceYoloDetection
|
||||
|
||||
//找到识别区域
|
||||
MLResult MLsum = mL3;
|
||||
for (int v = 0; v < mL4.ResultDetails.Count; v++)
|
||||
{
|
||||
MLsum.ResultDetails.Add(mL4.ResultDetails[v]);
|
||||
}
|
||||
//for (int v = 0; v < mL4.ResultDetails.Count; v++)
|
||||
//{
|
||||
// MLsum.ResultDetails.Add(mL4.ResultDetails[v]);
|
||||
//}
|
||||
for (int v = 0; v < MLsum.ResultDetails.Count; v++)
|
||||
{
|
||||
|
||||
|
@ -142,7 +142,7 @@
|
||||
<value>733, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
<value>29</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
@ -18,10 +18,10 @@ namespace HisenceYoloDetection
|
||||
public void Strart()
|
||||
{
|
||||
client = new TcpClient();
|
||||
// client.Host = "192.168.3.100";
|
||||
// client.Port= 9004;
|
||||
client.Host = "127.0.0.1";
|
||||
client.Port = 9000;
|
||||
client.Host = "192.168.3.100";
|
||||
client.Port= 9004;
|
||||
//client.Host = "127.0.0.1";
|
||||
//client.Port = 9000;
|
||||
client.Connect();
|
||||
|
||||
client.OnDataReceived += Client_OnDataReceived;
|
||||
|
Loading…
Reference in New Issue
Block a user