程序无法正常运行,代码中数据改动较多
This commit is contained in:
parent
08ab697a02
commit
43a8668e7c
@ -77,6 +77,7 @@ namespace HisenceYoloDetection
|
||||
detrect.Width += 20;
|
||||
detrect.Height += 60;
|
||||
Mat matCutblack1 = new Mat(thr1, sqlrect);
|
||||
|
||||
if (IfWhiteWord)
|
||||
{
|
||||
matCutblack1.SetTo(Scalar.Black);
|
||||
@ -268,7 +269,7 @@ namespace HisenceYoloDetection
|
||||
}
|
||||
else
|
||||
{
|
||||
Cv2.Threshold(gimg1, thr1, 100, 255, ThresholdTypes.Binary );//| ThresholdTypes.Otsu
|
||||
Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
|
||||
}
|
||||
|
||||
|
||||
@ -292,7 +293,7 @@ namespace HisenceYoloDetection
|
||||
}
|
||||
else
|
||||
{
|
||||
Cv2.Threshold(gimg2, thr2, 100, 255, ThresholdTypes.Binary );//| ThresholdTypes.Otsu
|
||||
Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
|
||||
}
|
||||
|
||||
|
||||
@ -324,35 +325,36 @@ 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));
|
||||
filter1.Row(7).SetTo(new Scalar(0.025));
|
||||
filter1.Col(7).SetTo(new Scalar(0.025));
|
||||
|
||||
|
||||
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));
|
||||
|
||||
|
||||
|
||||
// 应用卷积
|
||||
Mat final_result1 = new Mat();
|
||||
Cv2.Filter2D(thr1, final_result1, -1, filter1, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
Cv2.Filter2D(final_result1, final_result1, -1, filter1, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
Cv2.Filter2D(final_result1, final_result1, -1, filter1, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
|
||||
|
||||
//Cv2.Filter2D(final_result1, final_result1, -1, filter2, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
|
||||
Mat final_result2 = new Mat();
|
||||
Cv2.Filter2D(thr2, final_result2, -1, filter1, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
Cv2.Filter2D(final_result2, final_result2, -1, filter1, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
Cv2.Filter2D(final_result2, final_result2, -1, filter1, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
|
||||
|
||||
//Cv2.Filter2D(final_result2, final_result2, -1, filter2, anchor: new Point(-1, -1), 0, BorderTypes.Reflect);
|
||||
//裁剪才行
|
||||
|
||||
@ -377,25 +379,25 @@ namespace HisenceYoloDetection
|
||||
Mat devIMG_ = new Mat();
|
||||
Cv2.Subtract(final_result1, final_result2, devIMG);
|
||||
Cv2.Subtract(final_result2, final_result1, devIMG_);
|
||||
//string savePathd = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "devIMG.png");
|
||||
//// 保存结果
|
||||
|
||||
//Cv2.ImWrite(savePathd, devIMG);
|
||||
//string savePathd1 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "devIMG_.png");
|
||||
//// 保存结果
|
||||
|
||||
//Cv2.ImWrite(savePathd1, devIMG_);
|
||||
string savePathd = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "devIMG.png");
|
||||
// 保存结果
|
||||
|
||||
Cv2.ImWrite(savePathd, devIMG);
|
||||
string savePathd1 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "devIMG_.png");
|
||||
// 保存结果
|
||||
|
||||
Cv2.ImWrite(savePathd1, devIMG_);
|
||||
// 对差异图像应用阈值
|
||||
Cv2.Threshold(devIMG, devIMG, 45, 255, ThresholdTypes.Binary);
|
||||
Cv2.Threshold(devIMG_, devIMG_, 45, 255, ThresholdTypes.Binary);
|
||||
Cv2.Threshold(devIMG, devIMG, 9, 255, ThresholdTypes.Binary);
|
||||
Cv2.Threshold(devIMG_, devIMG_, 9, 255, ThresholdTypes.Binary);
|
||||
|
||||
// 结合差异
|
||||
Mat sumIMG = new Mat();
|
||||
Cv2.Add(devIMG, devIMG_, sumIMG);
|
||||
//string savePaths = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "sumIMG.png");
|
||||
//// 保存结果
|
||||
string savePaths = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "sumIMG.png");
|
||||
// 保存结果
|
||||
|
||||
//Cv2.ImWrite(savePaths, sumIMG);
|
||||
Cv2.ImWrite(savePaths, sumIMG);
|
||||
// 应用形态学操作
|
||||
Mat kernelCL = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(3, 3));
|
||||
Mat blackhatImg = new Mat();
|
||||
@ -407,7 +409,7 @@ namespace HisenceYoloDetection
|
||||
bool isMatch = true;
|
||||
foreach (var contour in contours)
|
||||
{
|
||||
if (Cv2.ContourArea(contour) <= 100)
|
||||
if (Cv2.ContourArea(contour) <= 500)
|
||||
{
|
||||
Cv2.DrawContours(blackhatImg, new Point[][] { contour }, -1, Scalar.Black, thickness: Cv2.FILLED);
|
||||
// 框选轮廓
|
||||
@ -434,3 +436,4 @@ namespace HisenceYoloDetection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
288
HisenceYoloDetection/MainForm.Designer.cs
generated
288
HisenceYoloDetection/MainForm.Designer.cs
generated
@ -29,10 +29,10 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
OpenCvSharp.Mat mat4 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat2 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat2 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat4 = new OpenCvSharp.Mat();
|
||||
OpenCvSharp.Mat mat5 = new OpenCvSharp.Mat();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
tabPage2 = new TabPage();
|
||||
@ -125,9 +125,14 @@
|
||||
panel4 = new Panel();
|
||||
panel5 = new Panel();
|
||||
groupBox2 = new GroupBox();
|
||||
canvas4 = new XKRS.UI.Canvas();
|
||||
canvas3 = new XKRS.UI.Canvas();
|
||||
canvas2 = new XKRS.UI.Canvas();
|
||||
canvas1 = new XKRS.UI.Canvas();
|
||||
originMatShow = new PictureBox();
|
||||
ResultMatShow = new PictureBox();
|
||||
panel8 = new Panel();
|
||||
canvas5 = new XKRS.UI.Canvas();
|
||||
textBox2 = new TextBox();
|
||||
label36 = new Label();
|
||||
textBox1 = new TextBox();
|
||||
@ -189,11 +194,6 @@
|
||||
richTextBox1 = new RichTextBox();
|
||||
contextMenuStrip1 = new ContextMenuStrip(components);
|
||||
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||
canvas1 = new XKRS.UI.Canvas();
|
||||
canvas2 = new XKRS.UI.Canvas();
|
||||
canvas3 = new XKRS.UI.Canvas();
|
||||
canvas4 = new XKRS.UI.Canvas();
|
||||
canvas5 = new XKRS.UI.Canvas();
|
||||
tabPage2.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
groupBox5.SuspendLayout();
|
||||
@ -271,7 +271,7 @@
|
||||
DistanceShow.Margin = new Padding(4, 2, 4, 2);
|
||||
DistanceShow.Name = "DistanceShow";
|
||||
DistanceShow.ReadOnly = true;
|
||||
DistanceShow.Size = new Size(127, 23);
|
||||
DistanceShow.Size = new Size(117, 23);
|
||||
DistanceShow.TabIndex = 10;
|
||||
//
|
||||
// label21
|
||||
@ -322,11 +322,11 @@
|
||||
groupBox4.Controls.Add(label13);
|
||||
groupBox4.Controls.Add(label12);
|
||||
groupBox4.Controls.Add(label11);
|
||||
groupBox4.Location = new Point(786, 101);
|
||||
groupBox4.Location = new Point(622, 101);
|
||||
groupBox4.Margin = new Padding(4, 2, 4, 2);
|
||||
groupBox4.Name = "groupBox4";
|
||||
groupBox4.Padding = new Padding(4, 2, 4, 2);
|
||||
groupBox4.Size = new Size(716, 351);
|
||||
groupBox4.Size = new Size(880, 351);
|
||||
groupBox4.TabIndex = 13;
|
||||
groupBox4.TabStop = false;
|
||||
groupBox4.Text = "位置显示";
|
||||
@ -358,7 +358,7 @@
|
||||
SetlnEditmiZOP.Location = new Point(526, 296);
|
||||
SetlnEditmiZOP.Margin = new Padding(4, 2, 4, 2);
|
||||
SetlnEditmiZOP.Name = "SetlnEditmiZOP";
|
||||
SetlnEditmiZOP.Size = new Size(127, 23);
|
||||
SetlnEditmiZOP.Size = new Size(116, 23);
|
||||
SetlnEditmiZOP.TabIndex = 27;
|
||||
//
|
||||
// SetlnEditmiYOP
|
||||
@ -382,7 +382,7 @@
|
||||
SetlnEditmiZH.Location = new Point(526, 242);
|
||||
SetlnEditmiZH.Margin = new Padding(4, 2, 4, 2);
|
||||
SetlnEditmiZH.Name = "SetlnEditmiZH";
|
||||
SetlnEditmiZH.Size = new Size(127, 23);
|
||||
SetlnEditmiZH.Size = new Size(116, 23);
|
||||
SetlnEditmiZH.TabIndex = 23;
|
||||
//
|
||||
// SetlnEditmiYH
|
||||
@ -406,7 +406,7 @@
|
||||
lnEditmiZOP.Location = new Point(526, 189);
|
||||
lnEditmiZOP.Margin = new Padding(4, 2, 4, 2);
|
||||
lnEditmiZOP.Name = "lnEditmiZOP";
|
||||
lnEditmiZOP.Size = new Size(127, 23);
|
||||
lnEditmiZOP.Size = new Size(116, 23);
|
||||
lnEditmiZOP.TabIndex = 19;
|
||||
//
|
||||
// lnEditmiYOP
|
||||
@ -441,7 +441,7 @@
|
||||
lnEditmiZS.Margin = new Padding(4, 2, 4, 2);
|
||||
lnEditmiZS.Name = "lnEditmiZS";
|
||||
lnEditmiZS.ReadOnly = true;
|
||||
lnEditmiZS.Size = new Size(127, 23);
|
||||
lnEditmiZS.Size = new Size(116, 23);
|
||||
lnEditmiZS.TabIndex = 15;
|
||||
//
|
||||
// lnEditmiYS
|
||||
@ -478,7 +478,7 @@
|
||||
lnEditmiZHS.Margin = new Padding(4, 2, 4, 2);
|
||||
lnEditmiZHS.Name = "lnEditmiZHS";
|
||||
lnEditmiZHS.ReadOnly = true;
|
||||
lnEditmiZHS.Size = new Size(127, 23);
|
||||
lnEditmiZHS.Size = new Size(116, 23);
|
||||
lnEditmiZHS.TabIndex = 11;
|
||||
//
|
||||
// lnEditmiYHS
|
||||
@ -608,17 +608,17 @@
|
||||
ModeleShow.Margin = new Padding(4, 2, 4, 2);
|
||||
ModeleShow.Name = "ModeleShow";
|
||||
ModeleShow.Padding = new Padding(4, 2, 4, 2);
|
||||
ModeleShow.Size = new Size(744, 351);
|
||||
ModeleShow.Size = new Size(596, 351);
|
||||
ModeleShow.TabIndex = 12;
|
||||
ModeleShow.TabStop = false;
|
||||
ModeleShow.Text = "模组显示";
|
||||
//
|
||||
// handStopBtn
|
||||
//
|
||||
handStopBtn.Location = new Point(342, 250);
|
||||
handStopBtn.Location = new Point(323, 250);
|
||||
handStopBtn.Margin = new Padding(4, 2, 4, 2);
|
||||
handStopBtn.Name = "handStopBtn";
|
||||
handStopBtn.Size = new Size(161, 78);
|
||||
handStopBtn.Size = new Size(107, 78);
|
||||
handStopBtn.TabIndex = 23;
|
||||
handStopBtn.Text = "手动阻塞";
|
||||
handStopBtn.UseVisualStyleBackColor = true;
|
||||
@ -626,10 +626,10 @@
|
||||
//
|
||||
// HandRuningBtn
|
||||
//
|
||||
HandRuningBtn.Location = new Point(527, 250);
|
||||
HandRuningBtn.Location = new Point(466, 250);
|
||||
HandRuningBtn.Margin = new Padding(4, 2, 4, 2);
|
||||
HandRuningBtn.Name = "HandRuningBtn";
|
||||
HandRuningBtn.Size = new Size(161, 78);
|
||||
HandRuningBtn.Size = new Size(106, 78);
|
||||
HandRuningBtn.TabIndex = 22;
|
||||
HandRuningBtn.Text = "手动放行";
|
||||
HandRuningBtn.UseVisualStyleBackColor = true;
|
||||
@ -638,10 +638,10 @@
|
||||
// ZBackwardrbx
|
||||
//
|
||||
ZBackwardrbx.Appearance = Appearance.Button;
|
||||
ZBackwardrbx.Location = new Point(527, 169);
|
||||
ZBackwardrbx.Location = new Point(466, 169);
|
||||
ZBackwardrbx.Margin = new Padding(4, 2, 4, 2);
|
||||
ZBackwardrbx.Name = "ZBackwardrbx";
|
||||
ZBackwardrbx.Size = new Size(161, 58);
|
||||
ZBackwardrbx.Size = new Size(106, 58);
|
||||
ZBackwardrbx.TabIndex = 21;
|
||||
ZBackwardrbx.Text = "Z反向";
|
||||
ZBackwardrbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -651,10 +651,10 @@
|
||||
// YBackwardrbx
|
||||
//
|
||||
YBackwardrbx.Appearance = Appearance.Button;
|
||||
YBackwardrbx.Location = new Point(342, 169);
|
||||
YBackwardrbx.Location = new Point(323, 169);
|
||||
YBackwardrbx.Margin = new Padding(4, 2, 4, 2);
|
||||
YBackwardrbx.Name = "YBackwardrbx";
|
||||
YBackwardrbx.Size = new Size(161, 58);
|
||||
YBackwardrbx.Size = new Size(107, 58);
|
||||
YBackwardrbx.TabIndex = 20;
|
||||
YBackwardrbx.Text = "Y反向";
|
||||
YBackwardrbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -667,7 +667,7 @@
|
||||
XBackwardrbx.Location = new Point(162, 169);
|
||||
XBackwardrbx.Margin = new Padding(4, 2, 4, 2);
|
||||
XBackwardrbx.Name = "XBackwardrbx";
|
||||
XBackwardrbx.Size = new Size(161, 58);
|
||||
XBackwardrbx.Size = new Size(116, 58);
|
||||
XBackwardrbx.TabIndex = 19;
|
||||
XBackwardrbx.Text = "X反向";
|
||||
XBackwardrbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -677,10 +677,10 @@
|
||||
// ZForwardrbx
|
||||
//
|
||||
ZForwardrbx.Appearance = Appearance.Button;
|
||||
ZForwardrbx.Location = new Point(527, 98);
|
||||
ZForwardrbx.Location = new Point(466, 98);
|
||||
ZForwardrbx.Margin = new Padding(4, 2, 4, 2);
|
||||
ZForwardrbx.Name = "ZForwardrbx";
|
||||
ZForwardrbx.Size = new Size(161, 58);
|
||||
ZForwardrbx.Size = new Size(106, 58);
|
||||
ZForwardrbx.TabIndex = 18;
|
||||
ZForwardrbx.Text = "Z正向";
|
||||
ZForwardrbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -690,10 +690,10 @@
|
||||
// YForwardrbx
|
||||
//
|
||||
YForwardrbx.Appearance = Appearance.Button;
|
||||
YForwardrbx.Location = new Point(342, 96);
|
||||
YForwardrbx.Location = new Point(323, 97);
|
||||
YForwardrbx.Margin = new Padding(4, 2, 4, 2);
|
||||
YForwardrbx.Name = "YForwardrbx";
|
||||
YForwardrbx.Size = new Size(161, 58);
|
||||
YForwardrbx.Size = new Size(107, 58);
|
||||
YForwardrbx.TabIndex = 17;
|
||||
YForwardrbx.Text = "Y正向";
|
||||
YForwardrbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -706,7 +706,7 @@
|
||||
XForwardrbx.Location = new Point(162, 98);
|
||||
XForwardrbx.Margin = new Padding(4, 2, 4, 2);
|
||||
XForwardrbx.Name = "XForwardrbx";
|
||||
XForwardrbx.Size = new Size(161, 58);
|
||||
XForwardrbx.Size = new Size(116, 58);
|
||||
XForwardrbx.TabIndex = 16;
|
||||
XForwardrbx.Text = "X正向";
|
||||
XForwardrbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -716,10 +716,10 @@
|
||||
// ZZerorbx
|
||||
//
|
||||
ZZerorbx.Appearance = Appearance.Button;
|
||||
ZZerorbx.Location = new Point(527, 21);
|
||||
ZZerorbx.Location = new Point(466, 21);
|
||||
ZZerorbx.Margin = new Padding(4, 2, 4, 2);
|
||||
ZZerorbx.Name = "ZZerorbx";
|
||||
ZZerorbx.Size = new Size(161, 58);
|
||||
ZZerorbx.Size = new Size(106, 58);
|
||||
ZZerorbx.TabIndex = 15;
|
||||
ZZerorbx.Text = "Z归零";
|
||||
ZZerorbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -729,10 +729,10 @@
|
||||
// YZerorbx
|
||||
//
|
||||
YZerorbx.Appearance = Appearance.Button;
|
||||
YZerorbx.Location = new Point(342, 21);
|
||||
YZerorbx.Location = new Point(323, 20);
|
||||
YZerorbx.Margin = new Padding(4, 2, 4, 2);
|
||||
YZerorbx.Name = "YZerorbx";
|
||||
YZerorbx.Size = new Size(161, 58);
|
||||
YZerorbx.Size = new Size(107, 59);
|
||||
YZerorbx.TabIndex = 14;
|
||||
YZerorbx.Text = "Y归零";
|
||||
YZerorbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -745,7 +745,7 @@
|
||||
XZerorbx.Location = new Point(162, 21);
|
||||
XZerorbx.Margin = new Padding(4, 2, 4, 2);
|
||||
XZerorbx.Name = "XZerorbx";
|
||||
XZerorbx.Size = new Size(161, 58);
|
||||
XZerorbx.Size = new Size(116, 58);
|
||||
XZerorbx.TabIndex = 13;
|
||||
XZerorbx.Text = "X归零";
|
||||
XZerorbx.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@ -757,7 +757,7 @@
|
||||
PLCPostion.Location = new Point(8, 250);
|
||||
PLCPostion.Margin = new Padding(4, 2, 4, 2);
|
||||
PLCPostion.Name = "PLCPostion";
|
||||
PLCPostion.Size = new Size(125, 95);
|
||||
PLCPostion.Size = new Size(99, 95);
|
||||
PLCPostion.TabIndex = 2;
|
||||
PLCPostion.Text = "定位";
|
||||
PLCPostion.UseVisualStyleBackColor = true;
|
||||
@ -768,7 +768,7 @@
|
||||
PLCDiskZero.Location = new Point(8, 133);
|
||||
PLCDiskZero.Margin = new Padding(4, 2, 4, 2);
|
||||
PLCDiskZero.Name = "PLCDiskZero";
|
||||
PLCDiskZero.Size = new Size(125, 95);
|
||||
PLCDiskZero.Size = new Size(99, 95);
|
||||
PLCDiskZero.TabIndex = 1;
|
||||
PLCDiskZero.Text = "归零";
|
||||
PLCDiskZero.UseVisualStyleBackColor = true;
|
||||
@ -779,7 +779,7 @@
|
||||
PLCPowerON.Location = new Point(8, 21);
|
||||
PLCPowerON.Margin = new Padding(4, 2, 4, 2);
|
||||
PLCPowerON.Name = "PLCPowerON";
|
||||
PLCPowerON.Size = new Size(125, 95);
|
||||
PLCPowerON.Size = new Size(99, 95);
|
||||
PLCPowerON.TabIndex = 0;
|
||||
PLCPowerON.Text = "使能ON";
|
||||
PLCPowerON.UseVisualStyleBackColor = true;
|
||||
@ -1220,6 +1220,90 @@
|
||||
groupBox2.Text = "图片";
|
||||
groupBox2.Enter += groupBox2_Enter;
|
||||
//
|
||||
// canvas4
|
||||
//
|
||||
canvas4.AllowSelectDefect = true;
|
||||
canvas4.BrushColor = null;
|
||||
canvas4.ImagePath = "";
|
||||
mat1.IsEnabledDispose = true;
|
||||
canvas4.ImaMAt = mat1;
|
||||
canvas4.ImgData = null;
|
||||
canvas4.Location = new Point(367, 517);
|
||||
canvas4.MoveStep = 5F;
|
||||
canvas4.Name = "canvas4";
|
||||
canvas4.Route = 0D;
|
||||
canvas4.Scale = 1D;
|
||||
canvas4.Size = new Size(351, 198);
|
||||
canvas4.TabIndex = 7;
|
||||
canvas4.WholeScale = 0F;
|
||||
canvas4.XMove = 0F;
|
||||
canvas4.XScale = 0F;
|
||||
canvas4.YMove = 0F;
|
||||
canvas4.YScale = 0F;
|
||||
//
|
||||
// canvas3
|
||||
//
|
||||
canvas3.AllowSelectDefect = true;
|
||||
canvas3.BrushColor = null;
|
||||
canvas3.ImagePath = "";
|
||||
mat2.IsEnabledDispose = true;
|
||||
canvas3.ImaMAt = mat2;
|
||||
canvas3.ImgData = null;
|
||||
canvas3.Location = new Point(0, 515);
|
||||
canvas3.MoveStep = 5F;
|
||||
canvas3.Name = "canvas3";
|
||||
canvas3.Route = 0D;
|
||||
canvas3.Scale = 1D;
|
||||
canvas3.Size = new Size(351, 198);
|
||||
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 = "";
|
||||
mat3.IsEnabledDispose = true;
|
||||
canvas2.ImaMAt = mat3;
|
||||
canvas2.ImgData = null;
|
||||
canvas2.Location = new Point(367, 237);
|
||||
canvas2.MoveStep = 5F;
|
||||
canvas2.Name = "canvas2";
|
||||
canvas2.Route = 0D;
|
||||
canvas2.Scale = 1D;
|
||||
canvas2.Size = new Size(351, 198);
|
||||
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 = "";
|
||||
mat4.IsEnabledDispose = true;
|
||||
canvas1.ImaMAt = mat4;
|
||||
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, 198);
|
||||
canvas1.TabIndex = 4;
|
||||
canvas1.WholeScale = 0F;
|
||||
canvas1.XMove = 0F;
|
||||
canvas1.XScale = 0F;
|
||||
canvas1.YMove = 0F;
|
||||
canvas1.YScale = 0F;
|
||||
//
|
||||
// originMatShow
|
||||
//
|
||||
originMatShow.Location = new Point(8, 21);
|
||||
@ -1266,6 +1350,27 @@
|
||||
panel8.TabIndex = 2;
|
||||
panel8.Paint += panel8_Paint;
|
||||
//
|
||||
// canvas5
|
||||
//
|
||||
canvas5.AllowSelectDefect = true;
|
||||
canvas5.BrushColor = null;
|
||||
canvas5.ImagePath = "";
|
||||
mat5.IsEnabledDispose = true;
|
||||
canvas5.ImaMAt = mat5;
|
||||
canvas5.ImgData = null;
|
||||
canvas5.Location = new Point(7, 515);
|
||||
canvas5.MoveStep = 5F;
|
||||
canvas5.Name = "canvas5";
|
||||
canvas5.Route = 0D;
|
||||
canvas5.Scale = 1D;
|
||||
canvas5.Size = new Size(351, 198);
|
||||
canvas5.TabIndex = 18;
|
||||
canvas5.WholeScale = 0F;
|
||||
canvas5.XMove = 0F;
|
||||
canvas5.XScale = 0F;
|
||||
canvas5.YMove = 0F;
|
||||
canvas5.YScale = 0F;
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
textBox2.Location = new Point(437, 287);
|
||||
@ -1828,111 +1933,6 @@
|
||||
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
contextMenuStrip1.Size = new Size(61, 4);
|
||||
//
|
||||
// canvas1
|
||||
//
|
||||
canvas1.AllowSelectDefect = true;
|
||||
canvas1.BrushColor = null;
|
||||
canvas1.ImagePath = "";
|
||||
mat4.IsEnabledDispose = true;
|
||||
canvas1.ImaMAt = mat4;
|
||||
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, 198);
|
||||
canvas1.TabIndex = 4;
|
||||
canvas1.WholeScale = 0F;
|
||||
canvas1.XMove = 0F;
|
||||
canvas1.XScale = 0F;
|
||||
canvas1.YMove = 0F;
|
||||
canvas1.YScale = 0F;
|
||||
//
|
||||
// canvas2
|
||||
//
|
||||
canvas2.AllowSelectDefect = true;
|
||||
canvas2.BrushColor = null;
|
||||
canvas2.ImagePath = "";
|
||||
mat3.IsEnabledDispose = true;
|
||||
canvas2.ImaMAt = mat3;
|
||||
canvas2.ImgData = null;
|
||||
canvas2.Location = new Point(367, 237);
|
||||
canvas2.MoveStep = 5F;
|
||||
canvas2.Name = "canvas2";
|
||||
canvas2.Route = 0D;
|
||||
canvas2.Scale = 1D;
|
||||
canvas2.Size = new Size(351, 198);
|
||||
canvas2.TabIndex = 5;
|
||||
canvas2.WholeScale = 0F;
|
||||
canvas2.XMove = 0F;
|
||||
canvas2.XScale = 0F;
|
||||
canvas2.YMove = 0F;
|
||||
canvas2.YScale = 0F;
|
||||
//
|
||||
// canvas3
|
||||
//
|
||||
canvas3.AllowSelectDefect = true;
|
||||
canvas3.BrushColor = null;
|
||||
canvas3.ImagePath = "";
|
||||
mat2.IsEnabledDispose = true;
|
||||
canvas3.ImaMAt = mat2;
|
||||
canvas3.ImgData = null;
|
||||
canvas3.Location = new Point(0, 515);
|
||||
canvas3.MoveStep = 5F;
|
||||
canvas3.Name = "canvas3";
|
||||
canvas3.Route = 0D;
|
||||
canvas3.Scale = 1D;
|
||||
canvas3.Size = new Size(351, 198);
|
||||
canvas3.TabIndex = 6;
|
||||
canvas3.WholeScale = 0F;
|
||||
canvas3.XMove = 0F;
|
||||
canvas3.XScale = 0F;
|
||||
canvas3.YMove = 0F;
|
||||
canvas3.YScale = 0F;
|
||||
//
|
||||
// canvas4
|
||||
//
|
||||
canvas4.AllowSelectDefect = true;
|
||||
canvas4.BrushColor = null;
|
||||
canvas4.ImagePath = "";
|
||||
mat1.IsEnabledDispose = true;
|
||||
canvas4.ImaMAt = mat1;
|
||||
canvas4.ImgData = null;
|
||||
canvas4.Location = new Point(367, 517);
|
||||
canvas4.MoveStep = 5F;
|
||||
canvas4.Name = "canvas4";
|
||||
canvas4.Route = 0D;
|
||||
canvas4.Scale = 1D;
|
||||
canvas4.Size = new Size(351, 198);
|
||||
canvas4.TabIndex = 7;
|
||||
canvas4.WholeScale = 0F;
|
||||
canvas4.XMove = 0F;
|
||||
canvas4.XScale = 0F;
|
||||
canvas4.YMove = 0F;
|
||||
canvas4.YScale = 0F;
|
||||
//
|
||||
// canvas5
|
||||
//
|
||||
canvas5.AllowSelectDefect = true;
|
||||
canvas5.BrushColor = null;
|
||||
canvas5.ImagePath = "";
|
||||
mat5.IsEnabledDispose = true;
|
||||
canvas5.ImaMAt = mat5;
|
||||
canvas5.ImgData = null;
|
||||
canvas5.Location = new Point(7, 515);
|
||||
canvas5.MoveStep = 5F;
|
||||
canvas5.Name = "canvas5";
|
||||
canvas5.Route = 0D;
|
||||
canvas5.Scale = 1D;
|
||||
canvas5.Size = new Size(351, 198);
|
||||
canvas5.TabIndex = 18;
|
||||
canvas5.WholeScale = 0F;
|
||||
canvas5.XMove = 0F;
|
||||
canvas5.XScale = 0F;
|
||||
canvas5.YMove = 0F;
|
||||
canvas5.YScale = 0F;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 17F);
|
||||
|
@ -112,10 +112,10 @@ namespace HisenceYoloDetection
|
||||
string Cam1TwoPath = "";
|
||||
string ModelChangePath = "";
|
||||
//报警灯
|
||||
string GreenLightingAdress = "";
|
||||
string YellowLightingAdress = "";
|
||||
string RedLightingAdress = "";
|
||||
string WaringAdress = "";
|
||||
string GreenLightingAdress = "556";
|
||||
string YellowLightingAdress = "554";
|
||||
string RedLightingAdress = "552";
|
||||
string WaringAdress = "558";
|
||||
/// <summary>
|
||||
/// 查看相机列表
|
||||
/// </summary>
|
||||
@ -289,89 +289,121 @@ namespace HisenceYoloDetection
|
||||
/// <param name="ContentType">默认 application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param>
|
||||
/// <param name="Accept">默认application/json</param>
|
||||
/// <returns></returns>
|
||||
public string Post(string parameterData, string serviceUrl, string ContentType = "application/json", string Accept = "application/json")
|
||||
//public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json")
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// // 创建 Web 请求对象
|
||||
// HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
|
||||
// byte[] buf = Encoding.UTF8.GetBytes($"inputvalue={Uri.EscapeDataString(parameterData)}");
|
||||
|
||||
// myRequest.Method = "POST";
|
||||
// myRequest.Accept = accept;
|
||||
// myRequest.ContentType = contentType;
|
||||
// myRequest.ContentLength = buf.Length;
|
||||
|
||||
// // 发送请求
|
||||
// using (Stream stream = myRequest.GetRequestStream())
|
||||
// {
|
||||
// stream.Write(buf, 0, buf.Length);
|
||||
// }
|
||||
|
||||
// // 获取响应内容
|
||||
// using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
|
||||
// using (StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8))
|
||||
// {
|
||||
// return reader.ReadToEnd();
|
||||
// }
|
||||
// }
|
||||
// catch (WebException ex)
|
||||
// {
|
||||
// if (ex.Response != null)
|
||||
// {
|
||||
// using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
|
||||
// {
|
||||
// string errorResponse = reader.ReadToEnd();
|
||||
// Console.WriteLine("WebException: " + errorResponse);
|
||||
// return errorResponse;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("WebException: " + ex.Message);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine("Exception: " + ex.Message);
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
//先根据用户请求的uri构造请求地址
|
||||
//string serviceUrl = string.Format("{0}/{1}", this.BaseUri, uri);
|
||||
//string path3 = "D:\\Hisence\\Test1\\3.jpg";
|
||||
//Mat pathmat = Cv2.ImRead(path3);
|
||||
//string path2 = "D:\\Hisence\\Test1\\4-1.jpg";
|
||||
|
||||
//创建Web访问对象
|
||||
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
|
||||
//把用户传过来的数据转成“UTF-8”的字节流
|
||||
byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(parameterData);
|
||||
//Rect rect3 = new Rect(0, 0, 0, 0);
|
||||
|
||||
myRequest.Method = "POST";
|
||||
//myRequest.Accept = "application/json";
|
||||
//myRequest.ContentType = "application/json"; // //Content-Type: application/x-www-form-urlencoded
|
||||
myRequest.AutomaticDecompression = DecompressionMethods.GZip;
|
||||
myRequest.Accept = Accept;
|
||||
//myRequest.ContentType = ContentType;
|
||||
myRequest.ContentType = "application/json; charset=UTF-8";
|
||||
myRequest.ContentLength = buf.Length;
|
||||
myRequest.MaximumAutomaticRedirections = 1;
|
||||
myRequest.AllowAutoRedirect = true;
|
||||
//CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect3, rect3, false, "D://Hisence//Test1");
|
||||
//string path22 = "D:\\Hisence\\Test2\\2.jpg";
|
||||
//Mat pathmat2 = Cv2.ImRead(path22);
|
||||
//string path222 = "D:\\Hisence\\Test2\\3.jpg";
|
||||
//Rect rect = new Rect(0, 0, 0, 0);
|
||||
|
||||
//myRequest.Headers.Add("content-type", "application/json");
|
||||
//myRequest.Headers.Add("accept-encoding", "gzip");
|
||||
//myRequest.Headers.Add("accept-charset", "utf-8");
|
||||
|
||||
//发送请求
|
||||
Stream stream = myRequest.GetRequestStream();
|
||||
stream.Write(buf, 0, buf.Length);
|
||||
stream.Close();
|
||||
//CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect, rect, true, "D://Hisence//Test2");
|
||||
|
||||
//通过Web访问对象获取响应内容
|
||||
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
|
||||
//通过响应内容流创建StreamReader对象,因为StreamReader更高级更快
|
||||
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
|
||||
//string returnXml = HttpUtility.UrlDecode(reader.ReadToEnd());//如果有编码问题就用这个方法
|
||||
string returnData = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾
|
||||
// 报警地址
|
||||
//string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
|
||||
|
||||
reader.Close();
|
||||
myResponse.Close();
|
||||
//DateTime dt = DateTime.Now;
|
||||
//string today = dt.ToString("yyyy-MM-dd");
|
||||
|
||||
return returnData;
|
||||
}
|
||||
#endregion
|
||||
//string startTime = today;
|
||||
//string endTime = today;
|
||||
//string lineBody = "BZ-PC";
|
||||
//string materialDescript = "皂盒";
|
||||
|
||||
/// <summary>
|
||||
/// 主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
//报警地址
|
||||
//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")
|
||||
//JObject patientInfo = new JObject
|
||||
//{
|
||||
// string ProductType = jo["ProductType"].ToString();
|
||||
// string FinalDefIo = jo["FinalDefIo"].ToString();
|
||||
// //解析字段
|
||||
// ["StartTime"] = startTime,
|
||||
// ["EndTime"] = endTime,
|
||||
// ["LineBody"] = lineBody,
|
||||
// ["MaterialDescripts"] = new JArray { materialDescript }
|
||||
//};
|
||||
|
||||
//string sendData = patientInfo.ToString();
|
||||
//string resultData = Post(sendData, url, "application/x-www-form-urlencoded", "application/json");
|
||||
|
||||
//if (resultData != null)
|
||||
//{
|
||||
// JObject responseJson = JObject.Parse(resultData);
|
||||
// bool success = responseJson["success"] != null && (bool)responseJson["success"];
|
||||
// if (success)
|
||||
// {
|
||||
// string productType = responseJson["ProductType"] != null ? responseJson["ProductType"].ToString() : "N/A";
|
||||
// string finalDefIo = responseJson["FinalDefIo"] != null ? responseJson["FinalDefIo"].ToString() : "N/A";
|
||||
// // 解析字段
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// string returnMsg = responseJson["ReturnMsg"] != null ? responseJson["ReturnMsg"].ToString() : "Unknown error";
|
||||
// Console.WriteLine("请求失败:" + returnMsg);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Console.WriteLine("请求失败:未返回数据");
|
||||
//}
|
||||
if (_runHandleBefore == null)
|
||||
{
|
||||
@ -460,7 +492,7 @@ namespace HisenceYoloDetection
|
||||
OnSpeedShow();//线程开启将速度显示在界面上
|
||||
OnPostionShow();//线程开启将位置显示在界面上
|
||||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//黄灯
|
||||
|
||||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);//绿灯
|
||||
//t = new System.Timers.Timer(10000);//实例化Timer类,设置间隔时间为10000毫秒;
|
||||
//t.Elapsed += new System.Timers.ElapsedEventHandler(Execute);//到达时间的时候执行事件;
|
||||
//t.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
||||
@ -777,7 +809,7 @@ namespace HisenceYoloDetection
|
||||
Cam1.OnHImageOutput -= OnCameraMatOutPut;
|
||||
Cam1.OnHImageOutput += OnCameraMatOutPut;
|
||||
//Cam2.OnHImageOutput -= OnCameraMatOutPut2;
|
||||
// Cam2.OnHImageOutput += OnCameraMatOutPut2;
|
||||
// Cam2.OnHImageOutput += OnCameraMatOutPut2;
|
||||
|
||||
OKOrNGShow.Image = OKbitmap;
|
||||
//初始化扫码枪
|
||||
@ -1228,18 +1260,18 @@ namespace HisenceYoloDetection
|
||||
xKNow = GetModeFromBar("VWJ070541V0WW824F120223");//从数据库中查询到这个条码的四轴的值
|
||||
|
||||
|
||||
if (xKNow==null)
|
||||
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;
|
||||
// Old_xKNow = xKNow;
|
||||
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
|
||||
bBarTriger = true;
|
||||
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
|
||||
@ -1291,7 +1323,7 @@ namespace HisenceYoloDetection
|
||||
}
|
||||
#endregion
|
||||
int YPos = 14957;
|
||||
int ZPos = 4382;
|
||||
int ZPos = 1695;
|
||||
bool StopM = false;//第一次用信号挡
|
||||
/// <summary>
|
||||
/// 监听洗衣机544是否触发后面对射传感器 相机
|
||||
@ -1398,7 +1430,7 @@ namespace HisenceYoloDetection
|
||||
if (xKNow == null)
|
||||
{
|
||||
myLog("数据库没有条码匹配" + m_sKEYENCEBar, DateTime.Now);
|
||||
break;
|
||||
// break;
|
||||
}
|
||||
//if(xKNow.OcrBar!= Old_xKNow.OcrBar)
|
||||
//{
|
||||
@ -1408,21 +1440,21 @@ namespace HisenceYoloDetection
|
||||
{
|
||||
// Old_xKNow = xKNow;
|
||||
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
|
||||
|
||||
|
||||
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
|
||||
}
|
||||
|
||||
// break;
|
||||
// break;
|
||||
}
|
||||
Thread.Sleep(2);
|
||||
// Thread.Sleep(2);
|
||||
bBar = false;
|
||||
#if true
|
||||
|
||||
// if (bBarTriger)//证明读码器读到东西
|
||||
// if (bBarTriger)//证明读码器读到东西
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
myLog("第一次采集图像", DateTime.Now);
|
||||
//移动模组 读三次测距的地址 看是否往前移动
|
||||
@ -1448,7 +1480,7 @@ namespace HisenceYoloDetection
|
||||
{
|
||||
MoveToP(5815, YPos, ZPos + (int)(dismove));
|
||||
}
|
||||
|
||||
|
||||
Cam1.SnapshotCount = 0;
|
||||
Cam1.Snapshot();
|
||||
|
||||
@ -1460,8 +1492,8 @@ namespace HisenceYoloDetection
|
||||
//{
|
||||
// MoveToP(xKNow.MoveTwoX, xKNow.MoveTwoY, xKNow.MoveTwoZ);
|
||||
//}
|
||||
|
||||
// MoveToP(51043, YPos, ZPos + (int)(dismove));
|
||||
|
||||
// MoveToP(51043, YPos, ZPos + (int)(dismove));
|
||||
//Cam1.Snapshot();
|
||||
MoveToP(5815, YPos, ZPos);
|
||||
melsecPLCTCPDriver.WriteInt("550", 0);//方行
|
||||
@ -1609,13 +1641,13 @@ namespace HisenceYoloDetection
|
||||
//第二次拍照
|
||||
if (SnapshotCount == 2)
|
||||
{
|
||||
|
||||
Cam1ImgTwo = Cv2.ImRead("D:\\Hisence\\类型\\1\\002.jpg");
|
||||
|
||||
Cam1ImgTwo = Cv2.ImRead("D:\\Hisence\\类型\\1\\002.jpg");
|
||||
//Cam1ImgTwo = cameraMat;
|
||||
|
||||
IfCam1TwoTriger = true;
|
||||
//originMatShow2.Image = cameraMat.ToBitmap();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1698,7 +1730,7 @@ namespace HisenceYoloDetection
|
||||
{
|
||||
xK_HisenceSQLWord = xkWordList[0];
|
||||
}
|
||||
if(xKNow==null)
|
||||
if (xKNow == null)
|
||||
{
|
||||
myLog("未匹配条码" + IOcrBAr, DateTime.Now);
|
||||
break;
|
||||
@ -1728,7 +1760,7 @@ namespace HisenceYoloDetection
|
||||
|
||||
//}
|
||||
myLog("型号匹配成功" + IOcrBAr, DateTime.Now);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1739,7 +1771,7 @@ namespace HisenceYoloDetection
|
||||
|
||||
}
|
||||
//相机1第二次拍照
|
||||
// if (IfCam1TwoTriger && bBarTriger)
|
||||
// if (IfCam1TwoTriger && bBarTriger)
|
||||
{
|
||||
IfCam1TwoTriger = false;
|
||||
bBarTriger = false;//可能没什么用了
|
||||
@ -1752,7 +1784,7 @@ namespace HisenceYoloDetection
|
||||
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++;
|
||||
@ -1774,14 +1806,14 @@ namespace HisenceYoloDetection
|
||||
List<string> strMatListOne = new List<string>();
|
||||
List<string> strMatFuzzyListOne = new List<string>();
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
////进行推理
|
||||
//MLRequest req2 = new MLRequest();
|
||||
//req2.currentMat = Cam1ImgTwo;
|
||||
@ -1801,7 +1833,7 @@ namespace HisenceYoloDetection
|
||||
|
||||
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 先执行定位比对
|
||||
@ -1839,18 +1871,18 @@ namespace HisenceYoloDetection
|
||||
//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);
|
||||
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)
|
||||
{
|
||||
@ -1867,7 +1899,7 @@ namespace HisenceYoloDetection
|
||||
|
||||
|
||||
// int sqlblocksum=
|
||||
|
||||
|
||||
|
||||
melsecPLCTCPDriver.WriteInt("550", 0);//方行
|
||||
if (MatchStr)
|
||||
@ -1886,19 +1918,22 @@ 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)
|
||||
{
|
||||
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//红灯
|
||||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//黄灯
|
||||
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//报警
|
||||
OKDsums++;
|
||||
WUsums++;
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
double percent = (double)WUsums/ AllDsums;
|
||||
double percent = (double)WUsums / AllDsums;
|
||||
string percentText = percent.ToString("0.0%");//最后percentText的值为10.0%
|
||||
textBox1.Text = percentText;
|
||||
OKOrNGShow.Image = OKbitmap;
|
||||
@ -1906,11 +1941,12 @@ namespace HisenceYoloDetection
|
||||
myLog("匹配失败", DateTime.Now);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
NGDsums++;
|
||||
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//报警
|
||||
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//红灯
|
||||
|
||||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//黄灯
|
||||
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
OKOrNGShow.Image = NGbitmap;
|
||||
@ -1918,7 +1954,7 @@ namespace HisenceYoloDetection
|
||||
myLog("匹配成功", DateTime.Now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2005,7 +2041,7 @@ namespace HisenceYoloDetection
|
||||
//
|
||||
if (data.Length > 10)
|
||||
{
|
||||
m_sKEYENCEBar=string.Empty;
|
||||
m_sKEYENCEBar = string.Empty;
|
||||
m_sKEYENCEBar = System.Text.Encoding.UTF8.GetString(data);
|
||||
// myLog("型号Ocr" + m_sKEYENCEBar, DateTime.Now);
|
||||
_runHandleBefore.Set();
|
||||
@ -2193,21 +2229,22 @@ namespace HisenceYoloDetection
|
||||
Mat pathmat2 = Cv2.ImRead(path22);
|
||||
string path222 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628923102_Rect.png";
|
||||
Rect rect1 = new Rect(1929, 745, 396, 377);
|
||||
Rect rect = new Rect(368, 53, 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";
|
||||
|
||||
|
||||
Rect rect2 = new Rect(0, 0, 0, 0);
|
||||
|
||||
CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
|
||||
|
||||
*/
|
||||
// OnGetBar();
|
||||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//黄灯
|
||||
*/
|
||||
|
||||
// OnGetBar();
|
||||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//绿灯
|
||||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);//黄灯
|
||||
TriggerCameral2();
|
||||
ReadyDetect();
|
||||
myLog("开启流程成功", DateTime.Now);
|
||||
@ -2607,7 +2644,7 @@ namespace HisenceYoloDetection
|
||||
Mat mResultCut = CamOneI.currentMat.Clone();
|
||||
//Mat mCut = new Mat();
|
||||
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
|
||||
InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||||
InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||||
|
||||
|
||||
|
||||
@ -3041,7 +3078,7 @@ namespace HisenceYoloDetection
|
||||
break;
|
||||
case 7:
|
||||
{
|
||||
// canvas7.ImaMAt = detectionImage;
|
||||
// canvas7.ImaMAt = detectionImage;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
@ -3071,7 +3108,7 @@ namespace HisenceYoloDetection
|
||||
/// <param name="strMatList">返回的定位框的结果</param>
|
||||
/// <param name="strMatRefList"></param>
|
||||
/// <param name="IOcrModel"></param>
|
||||
public void InsertSqlRunDataButton(ref Dictionary<string, bool> keyValueResult, bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List<string> strMatList, ref List<string> strMatRefList, ref PaddleOcrModel IOcrModel)
|
||||
public void InsertSqlRunDataButton(ref Dictionary<string, bool> keyValueResult, bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List<string> strMatList, ref List<string> strMatRefList, ref PaddleOcrModel IOcrModel)
|
||||
{
|
||||
#if true
|
||||
//try
|
||||
@ -3480,7 +3517,7 @@ namespace HisenceYoloDetection
|
||||
{
|
||||
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;
|
||||
|
||||
@ -3603,6 +3640,14 @@ namespace HisenceYoloDetection
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
melsecPLCTCPDriver.WriteInt("550", 0);
|
||||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);
|
||||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);
|
||||
|
||||
}
|
||||
|
||||
private void panel1_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>29</value>
|
||||
<value>52</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">
|
||||
|
@ -11,7 +11,7 @@ using static OpenCvSharp.FileStorage;
|
||||
|
||||
|
||||
|
||||
public class MelsecPLCTCPDriver1
|
||||
public class MelsecPLCTCPDriver
|
||||
{
|
||||
private MelsecMcNet melsecMc = new MelsecMcNet();
|
||||
// private HslCommunication.ModBus.ModbusTcpNet melsecMc = new HslCommunication.ModBus.ModbusTcpNet();
|
||||
|
@ -12,7 +12,7 @@ using static OpenCvSharp.FileStorage;
|
||||
|
||||
|
||||
|
||||
public class MelsecPLCTCPDriver
|
||||
public class MelsecPLCTCPDriver1
|
||||
{
|
||||
// private MelsecMcNet melsecMc = new MelsecMcNet();
|
||||
// private HslCommunication.ModBus.ModbusTcpNet melsecMc = new HslCommunication.ModBus.ModbusTcpNet();
|
||||
|
Loading…
Reference in New Issue
Block a user