diff --git a/HisenceYoloDetection/CheckDiffSciHelper.cs b/HisenceYoloDetection/CheckDiffSciHelper.cs
index ddea8f9..3f1e6f9 100644
--- a/HisenceYoloDetection/CheckDiffSciHelper.cs
+++ b/HisenceYoloDetection/CheckDiffSciHelper.cs
@@ -1,4 +1,5 @@
using OpenCvSharp;
+using OpenCvSharp.Flann;
using Sunny.UI.Win32;
using System;
using System.Collections.Generic;
@@ -10,7 +11,10 @@ using static System.Net.Mime.MediaTypeNames;
using Point = OpenCvSharp.Point;
using Size = OpenCvSharp.Size;
-
+using OpenCvSharp;
+using OpenCvSharp.Features2D;
+using OpenCvSharp.Flann;
+using System.Drawing;
namespace HisenceYoloDetection
{
@@ -57,6 +61,9 @@ namespace HisenceYoloDetection
return false;
}
// Cv2.Resize(img2, img2, new Size(550, 270));
+
+ Rect bottomleftRect= new Rect(0,img1.Height-30,30,30);
+ Scalar avgColor1 = Cv2.Mean(new Mat(img1,bottomleftRect));
Mat gimg2 = new Mat();
Cv2.CvtColor(img2, gimg2, ColorConversionCodes.BGR2GRAY);
Mat thr2 = new Mat();
@@ -73,9 +80,9 @@ namespace HisenceYoloDetection
//Rect area2 = new Rect(148,30,229,222);
sqlrect.Width += 20;
- sqlrect.Height += 60;
+ sqlrect.Height+= 100;
detrect.Width += 20;
- detrect.Height += 60;
+ detrect.Height+=100;
Mat matCutblack1 = new Mat(thr1, sqlrect);
if (IfWhiteWord)
@@ -100,14 +107,14 @@ namespace HisenceYoloDetection
DateTime dt = DateTime.Now;
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
- //string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr1.png");
- //// 保存结果
+ string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr1.png");
+ // 保存结果
- //Cv2.ImWrite(savePath4, thr1);
- //string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr2.png");
- //// 保存结果
+ Cv2.ImWrite(savePath4, thr1);
+ string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr2.png");
+ // 保存结果
- //Cv2.ImWrite(savePath3, thr2);
+ Cv2.ImWrite(savePath3, thr2);
// 创建卷积核
Mat filter1 = new Mat(15, 15, MatType.CV_32F, new Scalar(0));
@@ -128,12 +135,12 @@ namespace HisenceYoloDetection
//string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_final_result1.png");
- //// 保存结果
- ////string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
+ ////保存结果
+ //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
//Cv2.ImWrite(savePath2, final_result1);
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_final_result2.png");
- //// 保存结果
- ////string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
+ ////保存结果
+ //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
//Cv2.ImWrite(savePath, final_result2);
@@ -253,12 +260,14 @@ namespace HisenceYoloDetection
{
// 读取和处理第一张图片
Mat img1 = Cv2.ImRead(path1, ImreadModes.Color);
+
if (img1.Empty())
{
Console.WriteLine($"Error loading image {path1}");
return false;
}
// Cv2.Resize(img1, img1, new Size(550, 270));
+ img1 = RemoveBorders(img1);
Mat gimg1 = new Mat();
Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY);
Mat thr1 = new Mat();
@@ -283,6 +292,7 @@ namespace HisenceYoloDetection
return false;
}
// Cv2.Resize(img2, img2, new Size(550, 270));
+ img2 = RemoveBorders(img2);
Mat gimg2 = new Mat();
Cv2.CvtColor(img2, gimg2, ColorConversionCodes.BGR2GRAY);
Mat thr2 = new Mat();
@@ -338,7 +348,7 @@ namespace HisenceYoloDetection
Mat filter1 = new Mat(15, 15, MatType.CV_32F, new Scalar(0));
filter1.Row(7).SetTo(new Scalar(0.025));
- filter1.Row(7).SetTo(new Scalar(0.025));
+ filter1.Col(7).SetTo(new Scalar(0.025));
@@ -388,8 +398,8 @@ namespace HisenceYoloDetection
Cv2.ImWrite(savePathd1, devIMG_);
// 对差异图像应用阈值
- Cv2.Threshold(devIMG, devIMG, 9, 255, ThresholdTypes.Binary);
- Cv2.Threshold(devIMG_, devIMG_, 9, 255, ThresholdTypes.Binary);
+ Cv2.Threshold(devIMG, devIMG, 8, 255, ThresholdTypes.Binary);
+ Cv2.Threshold(devIMG_, devIMG_, 8, 255, ThresholdTypes.Binary);
// 结合差异
Mat sumIMG = new Mat();
@@ -433,7 +443,100 @@ namespace HisenceYoloDetection
Cv2.ImWrite(savePath, blackhatImg);
return isMatch;
}
+ static Mat RemoveBorders(Mat image)
+ {
+ // 将图像转换为灰度图
+ Mat grayImage = new Mat();
+ Cv2.CvtColor(image, grayImage, ColorConversionCodes.BGR2GRAY);
+
+ // 使用自适应二值化将图像变为黑白图
+ Mat binaryImage = new Mat();
+ Cv2.AdaptiveThreshold(grayImage, binaryImage, 255, AdaptiveThresholdTypes.MeanC, ThresholdTypes.Binary, 11, 2);
+
+ // 反转颜色
+ Mat invertedBinaryImage = new Mat();
+ Cv2.BitwiseNot(binaryImage, invertedBinaryImage);
+
+ // 查找轮廓
+ Point[][] contours;
+ HierarchyIndex[] hierarchy;
+ Cv2.FindContours(invertedBinaryImage, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxSimple);
+
+ // 找到包含最大面积的轮廓
+ double maxArea = 0;
+ Point[] maxContour = null;
+ foreach (var contour in contours)
+ {
+ double area = Cv2.ContourArea(contour);
+ if (area > maxArea)
+ {
+ maxArea = area;
+ maxContour = contour;
+ }
+ }
+
+ if (maxContour == null)
+ {
+ Console.WriteLine("未找到有效轮廓!");
+ return image;
+ }
+
+ // 找到平行四边形的四个顶点
+ Point[] approx = Cv2.ApproxPolyDP(maxContour, Cv2.ArcLength(maxContour, true) * 0.02, true);
+ Point2f[] srcPoints = approx.Select(p => new Point2f(p.X, p.Y)).ToArray();
+
+ if (srcPoints.Length != 4)
+ {
+ Console.WriteLine("未找到平行四边形的四个顶点!");
+ return image;
+ }
+
+ // 按顺时针顺序对顶点进行排序
+ srcPoints = OrderPoints(srcPoints);
+
+ // 确定目标图像的四个顶点
+ Point2f[] dstPoints = new Point2f[]
+ {
+ new Point2f(0, 0),
+ new Point2f(image.Width - 1, 0),
+ new Point2f(image.Width - 1, image.Height - 1),
+ new Point2f(0, image.Height - 1)
+ };
+
+ // 计算透视变换矩阵
+ Mat transformMatrix = Cv2.GetPerspectiveTransform(srcPoints, dstPoints);
+
+ // 应用透视变换
+ Mat warpedImage = new Mat();
+ Cv2.WarpPerspective(image, warpedImage, transformMatrix, new Size(image.Width, image.Height));
+
+ return warpedImage;
+ }
+
+ private static Point2f[] OrderPoints(Point2f[] points)
+ {
+ // 对顶点进行排序,顺时针顺序
+ Point2f[] orderedPoints = new Point2f[4];
+
+ // 计算质心
+ Point2f center = new Point2f(points.Average(p => p.X), points.Average(p => p.Y));
+
+ foreach (var point in points)
+ {
+ if (point.X < center.X && point.Y < center.Y)
+ orderedPoints[0] = point; // 左上
+ else if (point.X > center.X && point.Y < center.Y)
+ orderedPoints[1] = point; // 右上
+ else if (point.X > center.X && point.Y > center.Y)
+ orderedPoints[2] = point; // 右下
+ else if (point.X < center.X && point.Y > center.Y)
+ orderedPoints[3] = point; // 左下
+ }
+
+ return orderedPoints;
+ }
}
}
-}
+ }
+
\ No newline at end of file
diff --git a/HisenceYoloDetection/MainForm.Designer.cs b/HisenceYoloDetection/MainForm.Designer.cs
index cbbba00..915c796 100644
--- a/HisenceYoloDetection/MainForm.Designer.cs
+++ b/HisenceYoloDetection/MainForm.Designer.cs
@@ -29,6 +29,9 @@
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
+ OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat();
+ OpenCvSharp.Mat mat2 = new OpenCvSharp.Mat();
+ OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
tabPage2 = new TabPage();
panel1 = new Panel();
@@ -120,6 +123,9 @@
panel4 = new Panel();
panel5 = new Panel();
groupBox2 = new GroupBox();
+ canvas3 = new XKRS.UI.Canvas();
+ canvas2 = new XKRS.UI.Canvas();
+ canvas1 = new XKRS.UI.Canvas();
originMatShow = new PictureBox();
ResultMatShow = new PictureBox();
panel8 = new Panel();
@@ -178,6 +184,7 @@
timer6 = new System.Windows.Forms.Timer(components);
richTextBox1 = new RichTextBox();
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
+ CloseDecBtn = new Button();
tabPage2.SuspendLayout();
panel1.SuspendLayout();
groupBox5.SuspendLayout();
@@ -1188,6 +1195,9 @@
// groupBox2
//
groupBox2.AutoSize = true;
+ groupBox2.Controls.Add(canvas3);
+ groupBox2.Controls.Add(canvas2);
+ groupBox2.Controls.Add(canvas1);
groupBox2.Controls.Add(originMatShow);
groupBox2.Controls.Add(ResultMatShow);
groupBox2.Location = new Point(0, 0);
@@ -1200,6 +1210,70 @@
groupBox2.Text = "图片";
groupBox2.Enter += groupBox2_Enter;
//
+ // canvas3
+ //
+ canvas3.AllowSelectDefect = true;
+ canvas3.BrushColor = null;
+ canvas3.ImagePath = "";
+ mat1.IsEnabledDispose = true;
+ canvas3.ImaMAt = mat1;
+ canvas3.ImgData = null;
+ canvas3.Location = new Point(8, 467);
+ canvas3.MoveStep = 5F;
+ canvas3.Name = "canvas3";
+ canvas3.Route = 0D;
+ canvas3.Scale = 1D;
+ canvas3.Size = new Size(351, 223);
+ canvas3.TabIndex = 6;
+ canvas3.WholeScale = 0F;
+ canvas3.XMove = 0F;
+ canvas3.XScale = 0F;
+ canvas3.YMove = 0F;
+ canvas3.YScale = 0F;
+ //
+ // canvas2
+ //
+ canvas2.AllowSelectDefect = true;
+ canvas2.BrushColor = null;
+ canvas2.ImagePath = "";
+ mat2.IsEnabledDispose = true;
+ canvas2.ImaMAt = mat2;
+ canvas2.ImgData = null;
+ canvas2.Location = new Point(367, 240);
+ canvas2.MoveStep = 5F;
+ canvas2.Name = "canvas2";
+ canvas2.Route = 0D;
+ canvas2.Scale = 1D;
+ canvas2.Size = new Size(363, 205);
+ canvas2.TabIndex = 5;
+ canvas2.WholeScale = 0F;
+ canvas2.XMove = 0F;
+ canvas2.XScale = 0F;
+ canvas2.YMove = 0F;
+ canvas2.YScale = 0F;
+ //
+ // canvas1
+ //
+ canvas1.AllowSelectDefect = true;
+ canvas1.BrushColor = null;
+ canvas1.ImagePath = "";
+ mat3.IsEnabledDispose = true;
+ canvas1.ImaMAt = mat3;
+ canvas1.ImgData = null;
+ canvas1.Location = new Point(8, 237);
+ canvas1.MoveStep = 5F;
+ canvas1.Name = "canvas1";
+ canvas1.Route = 0D;
+ canvas1.Scale = 1D;
+ canvas1.Size = new Size(351, 208);
+ canvas1.TabIndex = 4;
+ canvas1.WholeScale = 0F;
+ canvas1.XMove = 0F;
+ canvas1.XScale = 0F;
+ canvas1.YMove = 0F;
+ canvas1.YScale = 0F;
+ canvas1.Load += canvas1_Load;
+ //
// originMatShow
//
originMatShow.Location = new Point(8, 21);
@@ -1222,6 +1296,7 @@
//
// panel8
//
+ panel8.Controls.Add(CloseDecBtn);
panel8.Controls.Add(label24);
panel8.Controls.Add(ScannerBox);
panel8.Controls.Add(textBox2);
@@ -1324,7 +1399,7 @@
//
// OKDNum
//
- OKDNum.Location = new Point(130, 196);
+ OKDNum.Location = new Point(129, 249);
OKDNum.Margin = new Padding(4, 2, 4, 2);
OKDNum.Name = "OKDNum";
OKDNum.ReadOnly = true;
@@ -1334,7 +1409,7 @@
// label20
//
label20.AutoSize = true;
- label20.Location = new Point(32, 201);
+ label20.Location = new Point(31, 254);
label20.Margin = new Padding(4, 0, 4, 0);
label20.Name = "label20";
label20.Size = new Size(56, 17);
@@ -1343,7 +1418,7 @@
//
// NGDNum
//
- NGDNum.Location = new Point(130, 153);
+ NGDNum.Location = new Point(129, 206);
NGDNum.Margin = new Padding(4, 2, 4, 2);
NGDNum.Name = "NGDNum";
NGDNum.ReadOnly = true;
@@ -1353,7 +1428,7 @@
// label19
//
label19.AutoSize = true;
- label19.Location = new Point(32, 156);
+ label19.Location = new Point(31, 209);
label19.Margin = new Padding(4, 0, 4, 0);
label19.Name = "label19";
label19.Size = new Size(57, 17);
@@ -1362,7 +1437,7 @@
//
// AllDSum
//
- AllDSum.Location = new Point(130, 111);
+ AllDSum.Location = new Point(129, 164);
AllDSum.Margin = new Padding(4, 2, 4, 2);
AllDSum.Name = "AllDSum";
AllDSum.ReadOnly = true;
@@ -1372,7 +1447,7 @@
// label18
//
label18.AutoSize = true;
- label18.Location = new Point(32, 114);
+ label18.Location = new Point(31, 167);
label18.Margin = new Padding(4, 0, 4, 0);
label18.Name = "label18";
label18.Size = new Size(50, 17);
@@ -1747,6 +1822,17 @@
richTextBox1.TabIndex = 1;
richTextBox1.Text = "";
//
+ // CloseDecBtn
+ //
+ CloseDecBtn.Location = new Point(170, 109);
+ CloseDecBtn.Margin = new Padding(4, 2, 4, 2);
+ CloseDecBtn.Name = "CloseDecBtn";
+ CloseDecBtn.Size = new Size(121, 40);
+ CloseDecBtn.TabIndex = 20;
+ CloseDecBtn.Text = "关闭检测";
+ CloseDecBtn.UseVisualStyleBackColor = true;
+ CloseDecBtn.Click += CloseDecBtn_Click;
+ //
// MainForm
//
AutoScaleDimensions = new SizeF(8F, 17F);
@@ -1955,8 +2041,8 @@
private Label label35;
private TextBox textBox2;
private Label label36;
- private XKRS.UI.Canvas canvas5;
- private XKRS.UI.Canvas canvas4;
+ //private XKRS.UI.Canvas canvas5;
+ //private XKRS.UI.Canvas canvas4;
private XKRS.UI.Canvas canvas3;
private XKRS.UI.Canvas canvas1;
private XKRS.UI.Canvas canvas6;
@@ -1964,5 +2050,6 @@
private Button button1;
private Label label24;
private TextBox ScannerBox;
+ private Button CloseDecBtn;
}
}
diff --git a/HisenceYoloDetection/MainForm.cs b/HisenceYoloDetection/MainForm.cs
index 98428dc..fc36a24 100644
--- a/HisenceYoloDetection/MainForm.cs
+++ b/HisenceYoloDetection/MainForm.cs
@@ -40,6 +40,11 @@ namespace HisenceYoloDetection
{
public partial class MainForm : Form
{
+ enum MeachineState
+ {
+ machine_opening,
+ machine_closing,
+ }
public MainForm()
{
InitializeComponent();
@@ -49,6 +54,7 @@ namespace HisenceYoloDetection
//OnDetectionDone += Defet_OnDetectionDone;
};
}
+ MeachineState meachineState= MeachineState.machine_closing;
MGSCameraDriver Cam1 = new MGSCameraDriver();
MGSCameraDriver Cam2 = new MGSCameraDriver();
public static string RootPath = "D:\\Hisence\\SQLImages\\";
@@ -340,18 +346,18 @@ namespace HisenceYoloDetection
// ȡڵַ
return response.Substring(startQuoteIndex + 1, endQuoteIndex - startQuoteIndex - 1);
}
-
- #region Post
- ///
- /// http Post
- ///
- ///
- /// ʵַ
- /// Ĭ application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary
- /// Ĭapplication/json
- ///
- public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json")
+
+ #region Post
+ ///
+ /// http Post
+ ///
+ ///
+ /// ʵַ
+ /// Ĭ application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary
+ /// Ĭapplication/json
+ ///
+ public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json")
{
try
{
@@ -408,8 +414,8 @@ namespace HisenceYoloDetection
string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
string jsonData = @"
{
- ""StartTime"": ""2024-07-15"",
- ""EndTime"": ""2024-07-15"",
+ ""StartTime"": ""2024-07-1"",
+ ""EndTime"": ""2024-07-22"",
""LineBody"": ""BZ-PC""
}";
@@ -421,30 +427,23 @@ namespace HisenceYoloDetection
string response = PostData(url, postData);
-
+ string productType = null;
// Ӧ
string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7); // Ŀ FinalDefID
- string productType = FindStringAfterColon(response, finalDefIdToFind);
- if (productType != null)
+ productType = FindStringAfterColon(response, finalDefIdToFind);
+ if (productType == null)
{
- Console.WriteLine($"{finalDefIdToFind}: {productType}");
-
- // дļ
-
-
-
- }
- else
- {
- Console.WriteLine($"FinalDefID {finalDefIdToFind} not found in response.");
+ finalDefIdToFind = finalDefIdToFind.Substring(0, finalDefIdToFind.Length - 6);
+ productType = FindStringAfterColon(response, finalDefIdToFind);
}
+
}
catch (Exception ex)
{
Console.WriteLine("Error occurred:");
Console.WriteLine(ex.Message);
}
-
+
}
///
@@ -454,52 +453,61 @@ 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);
+
+
+ CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect1, rect1, true, "D://Hisence//test2");
+
+
Stopwatch sw = new Stopwatch();
sw.Start();
- // string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
+ // string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
- // string jsonData = @"
- //{
- // ""StartTime"": ""2024-07-15"",
- // ""EndTime"": ""2024-07-15"",
- // ""LineBody"": ""BZ-PC""
- // }";
+ // string jsonData = @"
+ //{
+ // ""StartTime"": ""2024-07-15"",
+ // ""EndTime"": ""2024-07-15"",
+ // ""LineBody"": ""BZ-PC""
+ // }";
- // string postData = "inputvalue=" + Uri.EscapeDataString(jsonData);
+ // string postData = "inputvalue=" + Uri.EscapeDataString(jsonData);
- // try
- // {
- // string response = PostData(url, postData);
+ // try
+ // {
+ // string response = PostData(url, postData);
- // // Ӧ
- // string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7);
- // string productType = FindStringAfterColon(response, finalDefIdToFind);
- // if (productType != null)
- // {
- // Console.WriteLine($"{finalDefIdToFind}: {productType}");
+ // // Ӧ
+ // string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7);
+ // string productType = FindStringAfterColon(response, finalDefIdToFind);
+ // if (productType != null)
+ // {
+ // Console.WriteLine($"{finalDefIdToFind}: {productType}");
- // // дļ
+ // // дļ
+
+
+
+ // }
+ // else
+ // {
+ // Console.WriteLine($"FinalDefID {finalDefIdToFind} not found in response.");
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // Console.WriteLine("Error occurred:");
+ // Console.WriteLine(ex.Message);
+ // }
- // }
- // else
- // {
- // Console.WriteLine($"FinalDefID {finalDefIdToFind} not found in response.");
- // }
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("Error occurred:");
- // Console.WriteLine(ex.Message);
- // }
-
-
-
sw.Stop();
Console.WriteLine("ʱi" + sw.ElapsedMilliseconds);
@@ -897,7 +905,7 @@ namespace HisenceYoloDetection
try
{
//ʼ
-
+ meachineState = MeachineState.machine_opening;//״̬óOPen
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
//dataGridView1.DataSource = dataSet.Tables[0];
@@ -1440,7 +1448,7 @@ namespace HisenceYoloDetection
int iNum0 = 0;
int iNum3 = 0;
Thread.CurrentThread.Priority = ThreadPriority.Highest;
- while (true)
+ while (meachineState==MeachineState.machine_opening)
{
// myResetEvent.Set();
PLC548 = true;
@@ -1456,7 +1464,7 @@ namespace HisenceYoloDetection
}
if (iNum0 >= 1)
{
- while (true)
+ while (meachineState == MeachineState.machine_opening)
{
bTriger = false;
@@ -1470,7 +1478,7 @@ namespace HisenceYoloDetection
{
iNum1 = 0;
iNum3++;//ȡûﵽϴ»ϵĴ
-
+
}
if (iNum1 >= 2)
{
@@ -1485,12 +1493,12 @@ namespace HisenceYoloDetection
_runHandleBefore.WaitOne();
//ijɺͺŵĶԽ
string OcrBar = "";
- string FinalDefIDToFind = m_sKEYENCEBar.Substring(1, 18);// Ŀ FinalDefID
+ string FinalDefIDToFind = m_sKEYENCEBar;// Ŀ FinalDefID
this.Invoke(new Action(() =>
{
-
+
ScannerBox.Text = FinalDefIDToFind;
-
+
}));
myLog("ɨ" + m_sKEYENCEBar, DateTime.Now);
#if true
@@ -1504,7 +1512,8 @@ namespace HisenceYoloDetection
if (OcrBar.IsNullOrEmpty())
{
- break;
+ myLog("Mesϵͳͺ" + m_sKEYENCEBar, DateTime.Now);
+ //break;
}
xKNow = GetModeFromBar(OcrBar);//ݿвѯֵ
@@ -1514,13 +1523,13 @@ namespace HisenceYoloDetection
myLog("ݿûƥ" + m_sKEYENCEBar, DateTime.Now);
// break;
}
-
+
if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$"))
{
-
- // myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now);
-
+ // myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now);
+
+
}
}
@@ -1653,7 +1662,7 @@ namespace HisenceYoloDetection
}
- if(iNum3>=2)
+ if (iNum3 >= 2)
{
melsecPLCTCPDriver.WriteInt("550", 1);//
}
@@ -1712,7 +1721,7 @@ namespace HisenceYoloDetection
{
- // Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\\\1\\001.jpg"); ;
+ // Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\\\1\\001.jpg"); ;
Cam1ImgOne = cameraMat;
IfCam1OneTriger = true;
originMatShow.Image = cameraMat.ToBitmap();
@@ -1806,15 +1815,18 @@ namespace HisenceYoloDetection
// IOcrBAr = "W821PWMS27106WD2";
// IOcrBAr=
//ݿȶ
+ _runHandleAfter.Reset();
if (xKNow == null)
{
- myLog("δƥ" , DateTime.Now);
+ myLog("δƥ", DateTime.Now);
break;
}
if (xKNow.OcrBar == null)
{
myLog("δƥɹ" + xKNow.OcrBar, DateTime.Now);
+ myLog("ʼģ", DateTime.Now);
+ //Insert_auto();
break;
}
string IOcrBAr = xKNow.OcrBar;
@@ -1822,13 +1834,13 @@ namespace HisenceYoloDetection
//ijɺͺŵĶԽ
IfCam1TwoTriger = false;
- _runHandleAfter.Reset();
+
List xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
if (xkWordList.Count() == 1)
{
xK_HisenceSQLWord = xkWordList[0];
}
-
+
if (xKNow.Detect != "")
{
////ʱеϴ»Ǻ֮ǰһģ
@@ -1931,9 +1943,8 @@ namespace HisenceYoloDetection
}
//ȶԿ
- HashSet set1 = new HashSet(listLabels);
- HashSet set2 = new HashSet(RealLabels);
- bool MatchStr = set1.SetEquals(set2);
+
+ bool MatchStr = listLabels.SequenceEqual(RealLabels);
#endregion
//ȶ ϸȶ
if (MatchStr)
@@ -1958,7 +1969,7 @@ namespace HisenceYoloDetection
{
//жϿֵǷкƥfalse
bool containsFalseValue = keyValueResult.ContainsValue(false);
-
+
if (containsFalseValue)
MatchStr = false;
@@ -1970,7 +1981,7 @@ namespace HisenceYoloDetection
// int sqlblocksum=
-
+
melsecPLCTCPDriver.WriteInt("550", 0);//
if (MatchStr)
{
@@ -1987,49 +1998,57 @@ namespace HisenceYoloDetection
}
else
{
-
- melsecPLCTCPDriver.WriteInt(RedLightingAdress, 1);//
- melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);//Ƶ
- melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);//̵
- melsecPLCTCPDriver.WriteInt(WaringAdress, 1);//
-
-
-
- //ΪжǷNGϴ»
- DialogResult dr = MessageBox.Show("Ƿ죿", "Ƿ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
+ NGDsums++;
+ myLog("ƥʧ", DateTime.Now);
+ //ʾ
+ // InsertXK_HisenceWordMatchData(xK_MatchDet, true);
+ this.Invoke(new Action(() =>
{
+ OKOrNGShow.Image = NGbitmap;
+ }));
- melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//
- melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//Ƶ
- melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//
-
- OKDsums++;
- WUsums++;
- this.Invoke(new Action(() =>
- {
- double percent = (double)WUsums / AllDsums;
- string percentText = percent.ToString("0.0%");//percentTextֵΪ10.0%
- textBox1.Text = percentText;
- OKOrNGShow.Image = OKbitmap;
- }));
- myLog("ƥʧ", DateTime.Now);
- }
- else
- {
- NGDsums++;
-
- melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//
- melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//
- melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//Ƶ
+ //melsecPLCTCPDriver.WriteInt(RedLightingAdress, 1);//
+ //melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);//Ƶ
+ //melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);//̵
+ //melsecPLCTCPDriver.WriteInt(WaringAdress, 1);//
- this.Invoke(new Action(() =>
- {
- OKOrNGShow.Image = NGbitmap;
- }));
- myLog("ƥɹ", DateTime.Now);
- }
+
+ ////ΪжǷNGϴ»
+ //DialogResult dr = MessageBox.Show("Ƿ죿", "Ƿ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
+ //if (dr == DialogResult.OK)
+ //{
+
+ // melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//
+ // melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//̵
+ // melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//
+
+ // OKDsums++;
+ // WUsums++;
+ // this.Invoke(new Action(() =>
+ // {
+ // double percent = (double)WUsums / AllDsums;
+ // string percentText = percent.ToString("0.0%");//percentTextֵΪ10.0%
+ // textBox1.Text = percentText;
+ // OKOrNGShow.Image = OKbitmap;
+ // }));
+ // myLog("ƥʧ", DateTime.Now);
+ //}
+ //else
+ //{
+ // NGDsums++;
+
+ // melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//
+ // melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//
+ // melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//̵
+
+
+ // this.Invoke(new Action(() =>
+ // {
+ // OKOrNGShow.Image = NGbitmap;
+ // }));
+ // myLog("ƥɹ", DateTime.Now);
+ //}
@@ -2038,10 +2057,7 @@ namespace HisenceYoloDetection
}
}
- catch (Exception e)
- {
- throw e;
- }
+
finally
{
@@ -2061,7 +2077,8 @@ namespace HisenceYoloDetection
///
public void ThreadPost()
{
- Task.Run(() => {
+ Task.Run(() =>
+ {
while (true)
{
@@ -2316,30 +2333,30 @@ namespace HisenceYoloDetection
private void StartDecBtn_Click(object sender, EventArgs e)
{
- /*
- string path22 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628924614_Rect.png";
- Mat pathmat2 = Cv2.ImRead(path22);
- string path222 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628923102_Rect.png";
- Rect rect1 = new Rect(1929, 745, 396, 377);
-
- CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect, rect, true, "D://Hisence//Test2");
-
- string path = "D:\\Hisence\\Test1\\1.png";
- Mat pathmat =Cv2.ImRead(path);
- string path2 = "D:\\Hisence\\Test1\\2.png";
+ //string path22 = "D:\\Hisence\\test2\\002.jpg";
+ //Mat pathmat2 = Cv2.ImRead(path22);
+ //string path222 = "D:\\Hisence\\test2\\001.jpg";
+ //Rect rect1 = new Rect(1929, 745, 396, 377);
- Rect rect2 = new Rect(0, 0, 0, 0);
- CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
+ //CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect1, rect1, true, "D://Hisence//Test2");
+
+ //string path = "D:\\Hisence\\Test1\\1.png";
+ //Mat pathmat =Cv2.ImRead(path);
+ //string path2 = "D:\\Hisence\\Test1\\2.png";
+
+ //Rect rect2 = new Rect(0, 0, 0, 0);
+
+ //CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//test2");
+
- */
// OnGetBar();
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//̵
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);//Ƶ
-
-
+
+ meachineState = MeachineState.machine_opening;
TriggerCameral2();//紥 SNȡͺ ݿеõֵ
ReadyDetect();//պ߳
//ThreadPost();//պȡյͺ
@@ -2690,13 +2707,13 @@ namespace HisenceYoloDetection
}
public string FormBarType(string SN)
{
- string productType = "N/A";
+ string productType = "null";
string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
string jsonData = @"
{
- ""StartTime"": ""2024-07-15"",
- ""EndTime"": ""2024-07-15"",
+ ""StartTime"": ""2024-07-1"",
+ ""EndTime"": ""2024-07-22"",
""LineBody"": ""BZ-PC""
}";
@@ -2712,19 +2729,12 @@ namespace HisenceYoloDetection
// Ӧ
string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7); // Ŀ FinalDefID
productType = FindStringAfterColon(response, finalDefIdToFind);
- if (productType != null)
+ if (productType == null)
{
- Console.WriteLine($"{finalDefIdToFind}: {productType}");
-
- // дļ
-
-
-
- }
- else
- {
- Console.WriteLine($"FinalDefID {finalDefIdToFind} not found in response.");
+ finalDefIdToFind = finalDefIdToFind.Substring(0, finalDefIdToFind.Length - 6);
+ productType = FindStringAfterColon(response, finalDefIdToFind);
}
+
}
catch (Exception ex)
{
@@ -2735,6 +2745,121 @@ namespace HisenceYoloDetection
// sw.Stop();
// Console.WriteLine("ʱi" + sw.ElapsedMilliseconds);
}
+ public void Insert_auto(bool ifwhiteBan, Mat img, string SNtext, int MoveX, int MoveY, int MoveZ)
+ {
+ // PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel();
+ // IpaddleOcrModel.Load(ModelChangePath, "CPU");
+
+
+ string IOcrBAr = FormBarType(SNtext);
+ XK_HisenceWord xkWord = new XK_HisenceWord();
+ xkWord.OcrBar = IOcrBAr;
+ xkWord.TwoIFWhile = ifwhiteBan;
+ using (StreamWriter sw = new StreamWriter("D://123.log", true))
+ {
+ sw.WriteLine("\n");
+ sw.WriteLine(IOcrBAr);
+ sw.Flush();
+ }
+
+
+ //еĿü ʶַԱַ
+
+
+
+ //
+
+
+
+
+
+ //ӵһȫͼΧĿȻOCRʶ
+ MLRequest CamOneI = new MLRequest();
+ CamOneI.currentMat = Cv2.ImRead(Cam1OnePath);
+ CamOneI.ResizeWidth = 640;
+ CamOneI.ResizeHeight = 640;
+ CamOneI.Score = 0.3f;
+ CamOneI.in_lable_path = LablePath;//ǩ·
+ CamOneI.confThreshold = 0.3f;//ģŶ
+ CamOneI.iouThreshold = 0.4f;//IOU
+ CamOneI.out_node_name = "output";
+ MLResult mL3 = simboObjectDetection.RunInferenceFixed(CamOneI);
+ MLResult mLButton = simboObjectDetButton.RunInferenceFixed(CamOneI);
+ //if (mL3.IsSuccess)
+ //{
+ // DateTime dt = DateTime.Now;
+ // mL3.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
+
+ //}
+ List strMatListOne = new List();
+ List strMatFuzzyListOne = new List();
+ Mat mResultCut = CamOneI.currentMat.Clone();
+ //Mat mCut = new Mat();
+ Dictionary keyValueResult = new Dictionary();
+ InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
+
+
+
+
+
+ InsertXKHisenceWordData(xkWord);//ؼֱвһ
+ //ı
+ //List bingji = strMatListOne.Union(strMatListTwo).ToList();//ȫ
+ //List Fuzzybingji = strMatFuzzyListOne.Union(strMatFuzzyListTwo).ToList();//ȫ
+ string OcrTextone = strMatListOne.Join("##");
+ string OcrTextTwo = strMatFuzzyListOne.Join("##");
+
+ //string OcrTextinsert = "";
+ //List bingji = strMatListListOne.Union(strMatListListTwo).ToList();//ȫ
+ //for (int j = 0; j < bingji.Count; j++)
+ //{
+ // string jdetial = bingji[j];
+ // OcrTextinsert += jdetial + "##";
+ //}
+ string detstr = "";
+
+ //ҵʶ
+ MLResult MLsum = mL3;
+ //for (int v = 0; v < mL4.ResultDetails.Count; v++)
+ //{
+ // MLsum.ResultDetails.Add(mL4.ResultDetails[v]);
+ //}
+ for (int v = 0; v < MLsum.ResultDetails.Count; v++)
+ {
+
+ if (v < MLsum.ResultDetails.Count - 1)
+ {
+ detstr += MLsum.ResultDetails[v].LabelName + ",";
+ }
+ else
+ {
+ detstr += MLsum.ResultDetails[v].LabelName;
+
+ }
+
+ }
+
+ DateTime dt2 = DateTime.Now;
+ XKHisence xK = new XKHisence("1", IOcrBAr, MoveX, MoveY, MoveZ, detstr, OcrTextone, MoveX, MoveY, MoveZ, ModelChangePath, "", OcrTextTwo);
+ //string log="D:\\Hisence\\detImages\\" + dt2.Year.ToString() + dt2.Month.ToString() + dt2.Day.ToString() + dt2.Hour.ToString() + dt2.Minute.ToString() + dt2.Millisecond.ToString() + "2result.log";
+ // using (StreamWriter sw=new StreamWriter(log, true))
+ // {
+ // // sw.WriteLine(xK.OcrBar+"\n");
+ // sw.WriteLine(xK.OcrText);
+ // sw.WriteLine(xK.FuzzyOcrText);
+ // }
+ //IpaddleOcrModel.FreeModel();
+
+ string sql = "insert into XK_Hisence VALUES('" + xK.Type + "','" + xK.OcrBar + "'," + xK.MoveX + "," + xK.MoveY + "," + xK.MoveZ + ",'" + xK.Detect + "','" + xK.OcrText + "'," + xK.MoveTwoX + "," + xK.MoveTwoY + "," + xK.MoveTwoZ + ",'" + xK.OcrParm + "','" + xK.Language + "','" + xK.FuzzyOcrText + "')";
+ int i = SQLiteHelper.ExecuteSql(sql);
+ if (i == 1)
+ {
+ myLog("ɹ", DateTime.Now);
+ //MessageBox.Show("XK_Hisenceһ");
+ }
+ //bool ismatch = IsMatchOcrText("WF3S7021BB", strMatListListOne);
+ //ص
+ }
public void InsertXK_Hisence(bool ifwhiteBan, string SNtext, int MoveX, int MoveY, int MoveZ)
{
// PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel();
@@ -2949,7 +3074,7 @@ namespace HisenceYoloDetection
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
if (iv == 1)
{
- MessageBox.Show("ؼXK_HisenceWordһ");
+ //MessageBox.Show("ؼXK_HisenceWordһ");
}
}
public void InsertXK_HisenceWordMatchData(XK_HisenceWord xkWord, bool ifMatch)
@@ -3190,16 +3315,16 @@ namespace HisenceYoloDetection
canvas3.ImaMAt = detectionImage;
}
break;
- case 4:
- {
- canvas4.ImaMAt = detectionImage;
- }
- break;
- case 5:
- {
- canvas5.ImaMAt = detectionImage;
- }
- break;
+ //case 4:
+ // {
+ // canvas4.ImaMAt = detectionImage;
+ // }
+ // break;
+ //case 5:
+ // {
+ // canvas5.ImaMAt = detectionImage;
+ // }
+ // break;
case 6:
{
//canvas6.ImaMAt = detectionImage;
@@ -3242,6 +3367,7 @@ namespace HisenceYoloDetection
#if true
//try
//{
+ // ʼ־¼
string filename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
string txtLog = "D://Hisence//" + filename + "logsMatch.log";
using (StreamWriter sw = new StreamWriter(txtLog, true))
@@ -3249,64 +3375,77 @@ namespace HisenceYoloDetection
sw.WriteLine(filename + "\n");
sw.Flush();
}
+
+ // ¡ǰͼ
Mat mResultCut = currentMatC.Clone();
Rect areaBlack = new Rect();
- //ťλ
+
+ // ťλ
if (cam1Button.ResultDetails.Count == 1)
{
- Mat mResultCuti = mResultCut.Clone();
int rectsx = cam1Button.ResultDetails[0].Rect.X;
int rectsy = cam1Button.ResultDetails[0].Rect.Y;
int rectsWidth = cam1Button.ResultDetails[0].Rect.Width;
int rectsHeight = cam1Button.ResultDetails[0].Rect.Height;
+
+ // ťλãֹ
+ rectsx = Math.Max(rectsx, 0);
+ rectsy = Math.Max(rectsy, 0);
+ rectsWidth = Math.Min(rectsWidth, currentMatC.Width - rectsx);
+ rectsHeight = Math.Min(rectsHeight, currentMatC.Height - rectsy);
+
areaBlack = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
-
}
-
for (int i = 0; i < cam1TwoML.ResultDetails.Count; i++)
{
- Mat mResultCuti = mResultCut.Clone();
int rectsx = cam1TwoML.ResultDetails[i].Rect.X;
int rectsy = cam1TwoML.ResultDetails[i].Rect.Y;
int rectsWidth = cam1TwoML.ResultDetails[i].Rect.Width;
int rectsHeight = cam1TwoML.ResultDetails[i].Rect.Height;
+ // λãֹ
+ rectsx = Math.Max(rectsx, 0);
+ rectsy = Math.Max(rectsy, 0);
+ rectsWidth = Math.Min(rectsWidth, currentMatC.Width - rectsx);
+ rectsHeight = Math.Min(rectsHeight, currentMatC.Height - rectsy);
+
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
if (keyValueResult.Keys.Contains(blockIndex))
{
int indexof = keyValueResult.Keys.ToList().IndexOf(blockIndex);
-
int rectsxof = cam1TwoML.ResultDetails[indexof].Rect.X;
if (rectsx > rectsxof)
{
blockIndex = "3";
}
-
}
- Rect area2 = new Rect(0, 0, 0, 0);
- Mat matCut = new Mat();
- if (blockIndex == "2")//ťΧ
- {
- //ťڵťλþ0,0,0,0
+ Rect area2 = new Rect(0, 0, 0, 0);
+ if (blockIndex == "2") // ťΧ
+ {
if ((areaBlack.X + areaBlack.Width) < (rectsx + rectsWidth))
{
- areaBlack.X -= rectsx;
- areaBlack.Y -= rectsy;
+ areaBlack.X = Math.Max(areaBlack.X - rectsx, 0);
+ areaBlack.Y = Math.Max(areaBlack.Y - rectsy, 0);
+ areaBlack.Width = Math.Min(areaBlack.Width, currentMatC.Width - areaBlack.X);
+ areaBlack.Height = Math.Min(areaBlack.Height, currentMatC.Height - areaBlack.Y);
area2 = areaBlack;
}
string TwoRectStr = CheckDiffSciHelper.rectChangeStr(area2);
xK_HisenceWord.TwoRect = TwoRectStr;
-
}
+
Stopwatch sw = Stopwatch.StartNew();
sw.Start();
int extendHeight = 50;
rectsHeight += extendHeight;
+ rectsHeight = Math.Min(rectsHeight, currentMatC.Height - rectsy);
+
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
- matCut = new Mat(mResultCuti, area);
- //OCRʶüͼƬ
+ Mat matCut = new Mat(mResultCut, area);
+
+ // OCRʶüͼƬ
MLRequest reqcut = new MLRequest();
reqcut.currentMat = matCut.Clone();
MLResult mLCut = paddleOcrModel.RunInference(reqcut);
@@ -3316,10 +3455,8 @@ namespace HisenceYoloDetection
myLog("ÿҪʱ" + sw.ElapsedMilliseconds, DateTime.Now);
keyValueResult.Add(blockIndex, blockMatchI);
-
}
-
//}
//catch (Exception ex)
//{
@@ -3419,7 +3556,7 @@ namespace HisenceYoloDetection
for (int j = 0; j < mLcut.ResultDetails.Count; j++)
{
var resultDetail = mLcut.ResultDetails[j];
- if (resultDetail.Score > 0.8)
+ if (resultDetail.Score > 0.7)
{
string jdetial = mLcut.ResultDetails[j].LabelDisplay;
string result = Regex.Replace(jdetial, "[ \\[ \\] \\^ \\-_*DD(^)$%~!@#$&%+=<>!??:?`,.;/\"-]", "");
@@ -3545,157 +3682,157 @@ namespace HisenceYoloDetection
}
}
break;
- case "4"://ֽƥ
- {
- xK_HisenceWord.FourblockPath = CutSavePath;
- xK_HisenceWord.FourblockMainWord = MainWoidStr;
- xK_HisenceWord.FourblockText = TextWoidStr;
- if (!saveimage)
- {
- SQLStr = SQlxK_HisenceWord.FourblockMainWord;
- bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FourblockMainWord, SQlxK_HisenceWord.FourblockMainWord);
+ //case "4"://ֽƥ
+ // {
+ // xK_HisenceWord.FourblockPath = CutSavePath;
+ // xK_HisenceWord.FourblockMainWord = MainWoidStr;
+ // xK_HisenceWord.FourblockText = TextWoidStr;
+ // if (!saveimage)
+ // {
+ // SQLStr = SQlxK_HisenceWord.FourblockMainWord;
+ // bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FourblockMainWord, SQlxK_HisenceWord.FourblockMainWord);
- Rect rect = new Rect(0, 0, 0, 0);
- string PathSql = SQlxK_HisenceWord.FourblockPath;
+ // Rect rect = new Rect(0, 0, 0, 0);
+ // string PathSql = SQlxK_HisenceWord.FourblockPath;
- juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
- if (!OneIF1 || !juanjiMatch)
- {
- OneIF = false;
- DisplayResult(mLcut);
- //ʾİ
- // mLcut.ResultMap;
- Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 4);
- }
- else
- {
- OneIF = true;
- Defet_OnDetectionDone(OKMat, 4);
- }
+ // juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
+ // if (!OneIF1 || !juanjiMatch)
+ // {
+ // OneIF = false;
+ // DisplayResult(mLcut);
+ // //ʾİ
+ // // mLcut.ResultMap;
+ // Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 4);
+ // }
+ // else
+ // {
+ // OneIF = true;
+ // Defet_OnDetectionDone(OKMat, 4);
+ // }
- }
- }
- break;
- case "5"://ֽƥ
- {
- xK_HisenceWord.FiveblockPath = CutSavePath;
- xK_HisenceWord.FiveblockMainWord = MainWoidStr;
- xK_HisenceWord.FiveblockText = TextWoidStr;
- if (!saveimage)
- {
- SQLStr = SQlxK_HisenceWord.FiveblockMainWord;
- bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FiveblockMainWord, SQlxK_HisenceWord.FiveblockMainWord);
- Rect rect = new Rect(0, 0, 0, 0);
- string PathSql = SQlxK_HisenceWord.FiveblockMainWord;
+ // }
+ // }
+ // break;
+ //case "5"://ֽƥ
+ // {
+ // xK_HisenceWord.FiveblockPath = CutSavePath;
+ // xK_HisenceWord.FiveblockMainWord = MainWoidStr;
+ // xK_HisenceWord.FiveblockText = TextWoidStr;
+ // if (!saveimage)
+ // {
+ // SQLStr = SQlxK_HisenceWord.FiveblockMainWord;
+ // bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FiveblockMainWord, SQlxK_HisenceWord.FiveblockMainWord);
+ // Rect rect = new Rect(0, 0, 0, 0);
+ // string PathSql = SQlxK_HisenceWord.FiveblockMainWord;
- juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
- if (!OneIF1 || !juanjiMatch)
- {
- OneIF = false;
- DisplayResult(mLcut);
- //ʾİ
- // mLcut.ResultMap;
- Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 5);
- }
- else
- {
- OneIF = true;
- Defet_OnDetectionDone(OKMat, 5);
- }
- }
- }
- break;
- case "6"://ֽƥ
- {
- xK_HisenceWord.SixblockPath = CutSavePath;
- xK_HisenceWord.SixblockMainWord = MainWoidStr;
- xK_HisenceWord.SixblockText = TextWoidStr;
- if (!saveimage)
- {
- SQLStr = SQlxK_HisenceWord.SixblockMainWord;
- bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord);
- OneIF1 = false;//
- Rect rect = new Rect(0, 0, 0, 0);
- string PathSql = SQlxK_HisenceWord.SixblockPath;
- //һֱΪtrue
- juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
- juanjiMatch = true;
- if (!OneIF1 || !juanjiMatch)
- {
- OneIF = false;
- // DisplayResult(mLcut);
- //ʾİ
- // mLcut.ResultMap;
- Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 6);
- }
- else
- {
- OneIF = true;
- Defet_OnDetectionDone(OKMat, 6);
- }
+ // juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
+ // if (!OneIF1 || !juanjiMatch)
+ // {
+ // OneIF = false;
+ // DisplayResult(mLcut);
+ // //ʾİ
+ // // mLcut.ResultMap;
+ // Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 5);
+ // }
+ // else
+ // {
+ // OneIF = true;
+ // Defet_OnDetectionDone(OKMat, 5);
+ // }
+ // }
+ // }
+ // break;
+ //case "6"://ֽƥ
+ // {
+ // xK_HisenceWord.SixblockPath = CutSavePath;
+ // xK_HisenceWord.SixblockMainWord = MainWoidStr;
+ // xK_HisenceWord.SixblockText = TextWoidStr;
+ // if (!saveimage)
+ // {
+ // SQLStr = SQlxK_HisenceWord.SixblockMainWord;
+ // bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord);
+ // OneIF1 = false;//
+ // Rect rect = new Rect(0, 0, 0, 0);
+ // string PathSql = SQlxK_HisenceWord.SixblockPath;
+ // //һֱΪtrue
+ // juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
+ // juanjiMatch = true;
+ // if (!OneIF1 || !juanjiMatch)
+ // {
+ // OneIF = false;
+ // // DisplayResult(mLcut);
+ // //ʾİ
+ // // mLcut.ResultMap;
+ // Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 6);
+ // }
+ // else
+ // {
+ // OneIF = true;
+ // Defet_OnDetectionDone(OKMat, 6);
+ // }
- }
- }
- break;
- case "7"://ֽƥ
- {
- xK_HisenceWord.SevenblockPath = CutSavePath;
- xK_HisenceWord.SevenblockMainWord = MainWoidStr;
- xK_HisenceWord.SevenblockText = TextWoidStr;
- if (!saveimage)
- {
- SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
- bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
+ // }
+ // }
+ // break;
+ //case "7"://ֽƥ
+ // {
+ // xK_HisenceWord.SevenblockPath = CutSavePath;
+ // xK_HisenceWord.SevenblockMainWord = MainWoidStr;
+ // xK_HisenceWord.SevenblockText = TextWoidStr;
+ // if (!saveimage)
+ // {
+ // SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
+ // bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
- Rect rect = new Rect(0, 0, 0, 0);
- string PathSql = SQlxK_HisenceWord.SevenblockPath;
+ // Rect rect = new Rect(0, 0, 0, 0);
+ // string PathSql = SQlxK_HisenceWord.SevenblockPath;
- juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
- if (!OneIF1 || !juanjiMatch)
- {
- OneIF = false;
- //DisplayResult(mLcut);
- //ʾİ
- // mLcut.ResultMap;
- Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 7);
- }
- else
- {
- OneIF = true;
- Defet_OnDetectionDone(OKMat, 7);
- }
- }
- }
- break;
- case "8"://ֽƥ
- {
- xK_HisenceWord.EightblockPath = CutSavePath;
- xK_HisenceWord.EightblockMainWord = MainWoidStr;
- xK_HisenceWord.EightblockText = TextWoidStr;
- if (!saveimage)
- {
- SQLStr = SQlxK_HisenceWord.EightblockMainWord;
- bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.EightblockMainWord, SQlxK_HisenceWord.EightblockMainWord);
- Rect rect = new Rect(0, 0, 0, 0);
- string PathSql = SQlxK_HisenceWord.EightblockPath;
+ // juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
+ // if (!OneIF1 || !juanjiMatch)
+ // {
+ // OneIF = false;
+ // //DisplayResult(mLcut);
+ // //ʾİ
+ // // mLcut.ResultMap;
+ // Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 7);
+ // }
+ // else
+ // {
+ // OneIF = true;
+ // Defet_OnDetectionDone(OKMat, 7);
+ // }
+ // }
+ // }
+ // break;
+ //case "8"://ֽƥ
+ // {
+ // xK_HisenceWord.EightblockPath = CutSavePath;
+ // xK_HisenceWord.EightblockMainWord = MainWoidStr;
+ // xK_HisenceWord.EightblockText = TextWoidStr;
+ // if (!saveimage)
+ // {
+ // SQLStr = SQlxK_HisenceWord.EightblockMainWord;
+ // bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.EightblockMainWord, SQlxK_HisenceWord.EightblockMainWord);
+ // Rect rect = new Rect(0, 0, 0, 0);
+ // string PathSql = SQlxK_HisenceWord.EightblockPath;
- juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
- if (!OneIF1 || !juanjiMatch)
- {
- OneIF = false;
- // DisplayResult(mLcut);
- //ʾİ
- // mLcut.ResultMap;
- Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 8);
- }
- else
- {
- OneIF = true;
- Defet_OnDetectionDone(OKMat, 8);
- }
- }
- }
- break;
+ // juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
+ // if (!OneIF1 || !juanjiMatch)
+ // {
+ // OneIF = false;
+ // // DisplayResult(mLcut);
+ // //ʾİ
+ // // mLcut.ResultMap;
+ // Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 8);
+ // }
+ // else
+ // {
+ // OneIF = true;
+ // Defet_OnDetectionDone(OKMat, 8);
+ // }
+ // }
+ // }
+ // break;
}
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString();
string txtLog = "D://Hisence//" + filename + "logsMatch.log";
@@ -3787,9 +3924,27 @@ namespace HisenceYoloDetection
{
if (!m_sKEYENCEBar.IsNullOrEmpty())
{
- OcrBarBox.Text = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7);
+ OcrBarBox.Text = m_sKEYENCEBar;
}
}
+
+ private void canvas1_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void canvas7_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void CloseDecBtn_Click(object sender, EventArgs e)
+ {
+ meachineState = MeachineState.machine_closing;
+ melsecPLCTCPDriver.WriteInt("550", 0);
+ melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);
+ melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);
+ }
}
}
diff --git a/HisenceYoloDetection/MainForm.resx b/HisenceYoloDetection/MainForm.resx
index 607eb74..d1cc71b 100644
--- a/HisenceYoloDetection/MainForm.resx
+++ b/HisenceYoloDetection/MainForm.resx
@@ -142,7 +142,7 @@
733, 17
- 52
+ 25