diff --git a/HisenceYoloDetection.sln b/HisenceYoloDetection.sln
index 9433848..a288222 100644
--- a/HisenceYoloDetection.sln
+++ b/HisenceYoloDetection.sln
@@ -17,8 +17,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DE28139-2917-4B58-8240-4B4E11114730}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.ActiveCfg = Debug|Any CPU
- {0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.Build.0 = Debug|Any CPU
+ {0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.ActiveCfg = Debug|X64
+ {0DE28139-2917-4B58-8240-4B4E11114730}.Debug|X64.Build.0 = Debug|X64
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.Build.0 = Release|Any CPU
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.ActiveCfg = Release|X64
diff --git a/HisenceYoloDetection/CheckDiffSciHelper.cs b/HisenceYoloDetection/CheckDiffSciHelper.cs
index b26df86..41d1e64 100644
--- a/HisenceYoloDetection/CheckDiffSciHelper.cs
+++ b/HisenceYoloDetection/CheckDiffSciHelper.cs
@@ -72,7 +72,7 @@ namespace HisenceYoloDetection
/// 要对比的图像
/// 白板黑字为true
/// 存储路径
- public static bool CheckDiffSci(string path1, Mat MatDet, Rect sqlrect, Rect detrect, bool IfWhiteWord, string saveDir)
+ public static bool CheckDiffSci(string path1, Mat MatDet, ref Mat ResultMat,Rect sqlrect, Rect detrect, bool IfWhiteWord, string saveDir)
{
// 读取和处理第一张图片。。
Mat img1 = Cv2.ImRead(path1, ImreadModes.Color);
@@ -101,6 +101,7 @@ namespace HisenceYoloDetection
// 读取和处理第二张图片
Mat img2 = MatDet.Clone();
+ ResultMat= MatDet.Clone();
if (img2.Empty())
{
// Console.WriteLine($"Error loading image {path2}");
@@ -243,12 +244,14 @@ namespace HisenceYoloDetection
else
{
Rect boundingRect = Cv2.BoundingRect(contour);
+ Cv2.Resize(img2, img2, new Size(550, 270));
Cv2.Rectangle(img2, boundingRect, Scalar.Red, thickness: 2);
isMatch = false;
string savePath2 = Path.Combine("D:\\Hisence\\Test\\2\\ng", Path.GetFileNameWithoutExtension(path1) + filename + "_Rect.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2);
+ ResultMat = img2.Clone();
string savePath = Path.Combine("D:\\Hisence\\Test\\2\\ng", Path.GetFileNameWithoutExtension(path1) + filename + "_diff.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
diff --git a/HisenceYoloDetection/MainForm.Designer.cs b/HisenceYoloDetection/MainForm.Designer.cs
index 05f5877..127e624 100644
--- a/HisenceYoloDetection/MainForm.Designer.cs
+++ b/HisenceYoloDetection/MainForm.Designer.cs
@@ -150,6 +150,8 @@
StartDecBtn = new Button();
CloseDecBtn = new Button();
groupBox6 = new GroupBox();
+ textBox2 = new TextBox();
+ label37 = new Label();
textBox3 = new TextBox();
label25 = new Label();
label24 = new Label();
@@ -192,8 +194,6 @@
timer6 = new System.Windows.Forms.Timer(components);
richTextBox1 = new RichTextBox();
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
- label37 = new Label();
- textBox2 = new TextBox();
tabPage2.SuspendLayout();
panel1.SuspendLayout();
groupBox5.SuspendLayout();
@@ -1556,6 +1556,26 @@
groupBox6.TabStop = false;
groupBox6.Text = "基础信息";
//
+ // textBox2
+ //
+ textBox2.Location = new Point(128, 146);
+ textBox2.Margin = new Padding(4, 2, 4, 2);
+ textBox2.Name = "textBox2";
+ textBox2.ReadOnly = true;
+ textBox2.Size = new Size(115, 31);
+ textBox2.TabIndex = 23;
+ //
+ // label37
+ //
+ label37.AutoSize = true;
+ label37.Location = new Point(7, 146);
+ label37.Margin = new Padding(4, 0, 4, 0);
+ label37.Name = "label37";
+ label37.Size = new Size(96, 25);
+ label37.TabIndex = 22;
+ label37.Text = "旋钮颜色";
+ label37.Click += label37_Click;
+ //
// textBox3
//
textBox3.Location = new Point(128, 95);
@@ -1607,10 +1627,10 @@
// tabPage3
//
tabPage3.Controls.Add(panel2);
- tabPage3.Location = new Point(4, 33);
+ tabPage3.Location = new Point(4, 34);
tabPage3.Margin = new Padding(4, 2, 4, 2);
tabPage3.Name = "tabPage3";
- tabPage3.Size = new Size(1276, 816);
+ tabPage3.Size = new Size(1276, 815);
tabPage3.TabIndex = 4;
tabPage3.Text = "录入新型号";
tabPage3.UseVisualStyleBackColor = true;
@@ -1930,26 +1950,6 @@
richTextBox1.TabIndex = 1;
richTextBox1.Text = "";
//
- // label37
- //
- label37.AutoSize = true;
- label37.Location = new Point(7, 146);
- label37.Margin = new Padding(4, 0, 4, 0);
- label37.Name = "label37";
- label37.Size = new Size(96, 25);
- label37.TabIndex = 22;
- label37.Text = "旋钮颜色";
- label37.Click += label37_Click;
- //
- // textBox2
- //
- textBox2.Location = new Point(128, 146);
- textBox2.Margin = new Padding(4, 2, 4, 2);
- textBox2.Name = "textBox2";
- textBox2.ReadOnly = true;
- textBox2.Size = new Size(115, 31);
- textBox2.TabIndex = 23;
- //
// MainForm
//
AutoScaleDimensions = new SizeF(12F, 25F);
diff --git a/HisenceYoloDetection/MainForm.cs b/HisenceYoloDetection/MainForm.cs
index 8153961..042d51d 100644
--- a/HisenceYoloDetection/MainForm.cs
+++ b/HisenceYoloDetection/MainForm.cs
@@ -453,13 +453,14 @@ namespace HisenceYoloDetection
///
private void MainForm_Load(object sender, EventArgs e)
{
- string path22 = "D:\\Hisence\\test2\\222.jpg";
- Mat pathmat2 = Cv2.ImRead(path22);
- string path222 = "D:\\Hisence\\test2\\111.jpg";
- Rect rect1 = new Rect(0, 0, 0, 0);
+ //string path22 = "D:\\Hisence\\test2\\222.jpg";
+ //Mat pathmat2 = Cv2.ImRead(path22);
+ //Mat pathmat2result = Cv2.ImRead(path22);
+ //string path222 = "D:\\Hisence\\test2\\111.jpg";
+ //Rect rect1 = new Rect(0, 0, 0, 0);
- CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect1, rect1, true, "D://Hisence//test2");
+ //CheckDiffSciHelper.CheckDiffSci(path222, pathmat2,ref pathmat2result, rect1, rect1, true, "D://Hisence//test2");
Stopwatch sw = new Stopwatch();
@@ -1641,151 +1642,158 @@ namespace HisenceYoloDetection
myLog("ģɹ", DateTime.Now);
}
+
+
}
}
- string IOcrBAr = xKNow.OcrBar;
- //xKNow = GetModeFromBar(IOcrBAr);//ݿвѯֵ
- //ijɺͺŵĶԽ
- IfCam1TwoTriger = false;
-
-
- List xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
- if (xkWordList.Count() == 1)
+ bool MatchStr=false;
+ if (xKNow != null)
{
- xK_HisenceSQLWord = xkWordList[0];
+ string IOcrBAr = xKNow.OcrBar;
+ //xKNow = GetModeFromBar(IOcrBAr);//ݿвѯֵ
+ //ijɺͺŵĶԽ
+ IfCam1TwoTriger = false;
+
+
+ List xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
+ if (xkWordList.Count() == 1)
+ {
+ xK_HisenceSQLWord = xkWordList[0];
+ }
+
+ if (xKNow.Detect != "")
+ {
+
+ myLog("ͺƥɹ" + IOcrBAr, DateTime.Now);
+
+ }
+
+
+ //ݿƥſԽģƶ
+ //ͺźϴεͺһ Ͳûʶģll
+
+
+
+ //}
+ //1ڶ
+ // if (IfCam1TwoTriger && bBarTriger)
+ //{
+
+ //ʼ
+ Defet_OnDetectionDone(whiteMat, 1);
+ Defet_OnDetectionDone(whiteMat, 2);
+ Defet_OnDetectionDone(whiteMat, 3);
+ //Defet_OnDetectionDone(whiteMat, 4);
+ //Defet_OnDetectionDone(whiteMat, 5);
+ //Defet_OnDetectionDone(whiteMat, 6);
+ //Defet_OnDetectionDone(whiteMat, 7);
+
+ XK_HisenceWord xK_MatchDet = new XK_HisenceWord();
+ xK_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
+ AllDsums++;
+ //
+ MLRequest req = new MLRequest();
+ req.currentMat = Cam1ImgOne;
+ req.ResizeWidth = 640;
+ req.ResizeHeight = 640;
+ req.Score = 0.3f;
+ req.in_lable_path = LablePath;//ǩ·
+ req.confThreshold = 0.3f;//ģŶ
+ req.iouThreshold = 0.4f;//IOU
+ req.out_node_name = "output";
+ MLResult mL = simboObjectDetection.RunInferenceFixed(req);
+ MLResult mLButton = simboObjectDetButton.RunInferenceFixed(req);
+
+ DateTime dt = DateTime.Now;
+ //еĿü ʶַԱַ
+ List strMatListOne = new List();
+ List strMatFuzzyListOne = new List();
+ Mat mResultCut = req.currentMat.Clone();
+
+ if (mL.ResultMap != null)
+ {
+ mL.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
+ ResultMatShow.Image = mL.ResultMap;
+
+ }
+
+
+ List strMatListTwo = new List();
+ List strMatFuzzyListTwo = new List();
+ // Mat mResultCut2 = req2.currentMat.Clone();
+ Dictionary keyValueResult = new Dictionary();
+ Dictionary keyValueResult2 = new Dictionary();
+ #region ִжλȶ
+ //ִжλ
+ string[] listLabels = xKNow.Detect.Split(",");
+
+ MLResult MLsum = mL;
+ //for (int i = 0; i < mL2.ResultDetails.Count; i++)
+ //{
+ // MLsum.ResultDetails.Add((DetectionResultDetail)mL2.ResultDetails[i]);
+ //}
+
+ string[] RealCFLabels = new string[MLsum.ResultDetails.Count];
+
+ for (int i = 0; i < MLsum.ResultDetails.Count; i++)
+ {
+ RealCFLabels[i] = MLsum.ResultDetails[i].LabelName;
+
+
+ }
+
+ RealCFLabels = RealCFLabels.Distinct().ToArray();//ȥ
+ string detstr = string.Join(",", RealCFLabels); //Ϊabc-def-ghi -,Ҳʡ
+ //ȶԿ
+
+ MatchStr = listLabels.SequenceEqual(RealCFLabels);
+ if (MatchStr == false)
+
+ {
+ WAIsums++;
+ }
+ #endregion
+ //ȶ ϸȶ
+ if (MatchStr)
+ {
+ //Mat mCut = new Mat();
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+
+ 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);
+ sw.Stop();
+ //myLog("ʱ" + sw.ElapsedMilliseconds, DateTime.Now);
+
+ }
+
+
+
+
+ if (MatchStr)
+ {
+ //жϿֵǷкƥfalse
+ bool containsFalseValue = keyValueResult.ContainsValue(false);
+
+ if (containsFalseValue)
+ MatchStr = false;
+
+
+ }
}
-
- if (xKNow.Detect != "")
+ else
{
-
- myLog("ͺƥɹ" + IOcrBAr, DateTime.Now);
-
- }
-
-
- //ݿƥſԽģƶ
- //ͺźϴεͺһ Ͳûʶģll
-
-
-
- //}
- //1ڶ
- // if (IfCam1TwoTriger && bBarTriger)
- //{
-
- //ʼ
- Defet_OnDetectionDone(whiteMat, 1);
- Defet_OnDetectionDone(whiteMat, 2);
- Defet_OnDetectionDone(whiteMat, 3);
- //Defet_OnDetectionDone(whiteMat, 4);
- //Defet_OnDetectionDone(whiteMat, 5);
- //Defet_OnDetectionDone(whiteMat, 6);
- //Defet_OnDetectionDone(whiteMat, 7);
-
- XK_HisenceWord xK_MatchDet = new XK_HisenceWord();
- xK_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
- AllDsums++;
- //
- MLRequest req = new MLRequest();
- req.currentMat = Cam1ImgOne;
- req.ResizeWidth = 640;
- req.ResizeHeight = 640;
- req.Score = 0.3f;
- req.in_lable_path = LablePath;//ǩ·
- req.confThreshold = 0.3f;//ģŶ
- req.iouThreshold = 0.4f;//IOU
- req.out_node_name = "output";
- MLResult mL = simboObjectDetection.RunInferenceFixed(req);
- MLResult mLButton = simboObjectDetButton.RunInferenceFixed(req);
-
- DateTime dt = DateTime.Now;
- //еĿü ʶַԱַ
- List strMatListOne = new List();
- List strMatFuzzyListOne = new List();
- Mat mResultCut = req.currentMat.Clone();
-
- if (mL.ResultMap != null)
- {
- mL.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
- ResultMatShow.Image = mL.ResultMap;
-
- }
-
-
- List strMatListTwo = new List();
- List strMatFuzzyListTwo = new List();
- // Mat mResultCut2 = req2.currentMat.Clone();
- Dictionary keyValueResult = new Dictionary();
- Dictionary keyValueResult2 = new Dictionary();
- #region ִжλȶ
- //ִжλ
- string[] listLabels = xKNow.Detect.Split(",");
-
- MLResult MLsum = mL;
- //for (int i = 0; i < mL2.ResultDetails.Count; i++)
- //{
- // MLsum.ResultDetails.Add((DetectionResultDetail)mL2.ResultDetails[i]);
- //}
-
- string[] RealCFLabels = new string[MLsum.ResultDetails.Count];
-
- for (int i = 0; i < MLsum.ResultDetails.Count; i++)
- {
- RealCFLabels[i] = MLsum.ResultDetails[i].LabelName;
-
-
- }
-
- RealCFLabels = RealCFLabels.Distinct().ToArray();//ȥ
- string detstr = string.Join(",", RealCFLabels); //Ϊabc-def-ghi -,Ҳʡ
- //ȶԿ
-
- bool MatchStr = listLabels.SequenceEqual(RealCFLabels);
- if (MatchStr == false)
-
- {
- WAIsums++;
- }
- #endregion
- //ȶ ϸȶ
- if (MatchStr)
- {
- //Mat mCut = new Mat();
- Stopwatch sw = new Stopwatch();
- sw.Start();
-
- 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);
- sw.Stop();
- //myLog("ʱ" + sw.ElapsedMilliseconds, DateTime.Now);
-
- }
-
-
-
-
- if (MatchStr)
- {
- //жϿֵǷкƥfalse
- bool containsFalseValue = keyValueResult.ContainsValue(false);
-
- if (containsFalseValue)
- MatchStr = false;
-
-
+ MatchStr = true;
}
///ִбȶ Сͼ
//bool MatchStr = ManagerModelHelper.IsMatchSQLText(ref mCut, ref xK_HisenceSQLWord, ref xK_MatchDet);
- // int sqlblocksum=
-
-
melsecPLCTCPDriver.WriteInt("550", 0);//
if (MatchStr)
{
@@ -2596,7 +2604,8 @@ namespace HisenceYoloDetection
-
+ //if (xkWord.OneblockText.)
+ //{ }
InsertXKHisenceWordData(xkWord);//ؼֱвһ
string OcrTextone = strMatListOne.Join("##");
@@ -2604,6 +2613,10 @@ namespace HisenceYoloDetection
string detstr = "";
+ if (keyValueResult.Count<=1)
+ {
+ return;
+ }
for (int v = 0; v < keyValueResult.Count; v++)
{
@@ -3422,16 +3435,17 @@ namespace HisenceYoloDetection
textBox2.Text = color;
}));
- juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rectsql, rectDet, iswhite, "D://Hisence//Test");
+ Mat matresult = CutBlockMat.Clone();
+ juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat,ref matresult, rectsql, rectDet, iswhite, "D://Hisence//Test");
// juanjiMatch = true;
if (!OneIF1 || !juanjiMatch)
{
OneIF = false;
- DisplayResult(mLcut);
+ //DisplayResult(mLcut);
//ʾİ
// mLcut.ResultMap;
- Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 2);
+ Defet_OnDetectionDone(matresult, 2);
}
else
{
diff --git a/HisenceYoloDetection/ManagerModelHelper.cs b/HisenceYoloDetection/ManagerModelHelper.cs
index 1af0ee4..5ca09e1 100644
--- a/HisenceYoloDetection/ManagerModelHelper.cs
+++ b/HisenceYoloDetection/ManagerModelHelper.cs
@@ -104,83 +104,7 @@ namespace HisenceYoloDetection
return cslist;
}
- public static bool IsMatchSQLText(ref Mat detMat, ref XK_HisenceWord XKSQL, ref XK_HisenceWord XKDet)
- {
-
- try
- {
- string TwoRectstr = XKSQL.TwoRect;
- string oneBlockWordSql = XKSQL.OneblockMainWord;
- string twoBlockWordSql = XKSQL.TwoblockMainWord;
- string threeBlockWordSql = XKSQL.ThreeblockMainWord;
- string fourBlockWordSql = XKSQL.FourblockMainWord;
- string fiveBlockWordSql = XKSQL.FiveblockMainWord;
- string sixBlockWordSql = XKSQL.SixblockMainWord;
- string sevenBlockWordSql = XKSQL.SevenblockMainWord;
- string eightBlockWordSql = XKSQL.EightblockMainWord;
-
- string oneBlockWordDet = XKDet.OneblockMainWord;
- string twoBlockWordDet = XKDet.TwoblockMainWord;
- string threeBlockWordDet = XKDet.ThreeblockMainWord;
- string fourBlockWordDet = XKDet.FourblockMainWord;
- string fiveBlockWordDet = XKDet.FiveblockMainWord;
- string sixBlockWordDet = XKDet.SixblockMainWord;
- string sevenBlockWordDet = XKDet.SevenblockMainWord;
- string eightBlockWordDet = XKDet.EightblockMainWord;
-
-
-
- bool OneIF = isMatchStr(oneBlockWordSql, oneBlockWordDet);
- bool TwoIF = isMatchStr(twoBlockWordSql, twoBlockWordDet);
- bool ThreeIF = isMatchStr(threeBlockWordSql, threeBlockWordDet);
- bool FourIF = isMatchStr(fourBlockWordSql, fourBlockWordDet);
- bool FiveIF = isMatchStr(fiveBlockWordSql, fiveBlockWordDet);
- bool SixIF = isMatchStr(sixBlockWordSql, sixBlockWordDet);
- bool SenvenIF = isMatchStr(sevenBlockWordSql, sevenBlockWordDet);
- bool EightIF = isMatchStr(eightBlockWordSql, eightBlockWordDet);
- //第二快 卷积匹配
- string PathSql = XKSQL.TwoblockPath;
- //
-
- Rect rectsql = CheckDiffSciHelper.strChangeRect(TwoRectstr);
- Rect rectDet = CheckDiffSciHelper.strChangeRect(XKDet.TwoRect);
- bool twoif2 = CheckDiffSciHelper.CheckDiffSci(PathSql, detMat, rectsql, rectDet, (bool)XKSQL.TwoIFWhile, "D://Test");
- DateTime dt = DateTime.Now;
- using (StreamWriter sw = new StreamWriter("D://Hisence//logsMatch.log", true))
- {
- string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
- sw.WriteLine(filename + "\n");
- sw.WriteLine(oneBlockWordSql + " " + oneBlockWordDet + "\n");
- sw.WriteLine(twoBlockWordSql + " " + twoBlockWordDet + "\n");
- sw.WriteLine(threeBlockWordSql + " " + threeBlockWordDet + "\n");
- sw.WriteLine(fourBlockWordSql + " " + fourBlockWordDet + "\n");
- sw.WriteLine(fiveBlockWordSql + " " + fiveBlockWordDet + "\n");
- sw.WriteLine(sixBlockWordSql + " " + sixBlockWordDet + "\n");
- sw.WriteLine(sevenBlockWordSql + " " + sevenBlockWordDet + "\n");
- sw.WriteLine(eightBlockWordSql + " " + eightBlockWordDet + "\n");
- sw.WriteLine(" 卷积匹配 " + twoif2 + "\n");
- sw.Flush();
- }
- //第三块区域一直都是false
- if (OneIF && TwoIF && ThreeIF && FourIF && FiveIF && SixIF && SenvenIF && EightIF && twoif2)
- {
- return true;
- }
- else
- {
- return false;
- }
-
-
-
-
- }
- catch (Exception ex)
- {
- return false;
- }
-
- }
+
public static bool StrMatch(string SqlText,string DetText)
{
// 计算Levenshtein距离