修改卷积

This commit is contained in:
xhm\HP 2024-06-11 11:40:47 +08:00
parent 85ba963a93
commit c1c0e0697c
17 changed files with 2884 additions and 1407 deletions

View File

@ -0,0 +1,331 @@
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Point = OpenCvSharp.Point;
using Size = OpenCvSharp.Size;
namespace HisenceYoloDetection
{
public static class CheckDiffSciHelper
{
/// <summary>
///
/// </summary>
/// <param name="path1">标准图像</param>
/// <param name="path2">要对比的图像</param>
/// <param name="IfWhiteWord"> 白板黑字为true </param>
/// <param name="saveDir">存储路径</param>
public static bool CheckDiffSci(string path1, Mat MatDet,Rect sqlrect,Rect detrect, bool IfWhiteWord, string saveDir)
{
// 读取和处理第一张图片
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));
Mat gimg1 = new Mat();
Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY);
Mat thr1 = new Mat();
if(IfWhiteWord)
{
Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
}
else
{
Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
}
// 读取和处理第二张图片
Mat img2 = MatDet.Clone();
if (img2.Empty())
{
// Console.WriteLine($"Error loading image {path2}");
return false;
}
Cv2.Resize(img2, img2, new Size(550, 270));
Mat gimg2 = new Mat();
Cv2.CvtColor(img2, gimg2, ColorConversionCodes.BGR2GRAY);
Mat thr2 = new Mat();
//Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
if (IfWhiteWord)
{
Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
}
else
{
Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
}
// Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
//Rect area2 = new Rect(148,30,229,222);
sqlrect.Width += 20;
detrect.Width += 20;
Mat matCutblack1 = new Mat(thr1, sqlrect);
if (IfWhiteWord)
{
matCutblack1.SetTo(Scalar.Black);
}
else
{
matCutblack1.SetTo(Scalar.Black);
}
Mat matCutblack2 = new Mat(thr2, detrect);
if (IfWhiteWord)
{
matCutblack2.SetTo(Scalar.Black);
}
else
{
matCutblack2.SetTo(Scalar.Black);
}
string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_thr1.png");
// 保存结果
Cv2.ImWrite(savePath4, thr1);
string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_thr2.png");
// 保存结果
Cv2.ImWrite(savePath3, thr2);
// 创建卷积核
Mat filter1 = new Mat(17, 17, MatType.CV_32F, new Scalar(0));
filter1.Row(8).SetTo(new Scalar(0.025));
filter1.Col(8).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);
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);
//裁剪才行
//string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_final_result1.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");
//Cv2.ImWrite(savePath, final_result2);
// 计算图像差异
Mat devIMG = new Mat();
Mat devIMG_ = new Mat();
Cv2.Subtract(final_result1, final_result2, devIMG);
Cv2.Subtract(final_result2, final_result1, devIMG_);
// 对差异图像应用阈值
Cv2.Threshold(devIMG, devIMG, 50, 255, ThresholdTypes.Binary);
Cv2.Threshold(devIMG_, devIMG_, 50, 255, ThresholdTypes.Binary);
// 结合差异
Mat sumIMG = new Mat();
Cv2.Add(devIMG, devIMG_, sumIMG);
// 应用形态学操作
Mat kernelCL = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(3, 3));
Mat blackhatImg = new Mat();
Cv2.Dilate(sumIMG, blackhatImg, kernelCL);
// 处理轮廓和保存结果
Point[][] contours = new Point[10000][];
Cv2.FindContours(blackhatImg, out contours, out _, RetrievalModes.Tree, ContourApproximationModes.ApproxSimple);
bool isMatch = true;
foreach (var contour in contours)
{
if (Cv2.ContourArea(contour) <= 100)
{
Cv2.DrawContours(blackhatImg, new Point[][] { contour }, -1, Scalar.Black, thickness: Cv2.FILLED);
// 框选轮廓
}
else
{
Rect boundingRect = Cv2.BoundingRect(contour);
Cv2.Rectangle(img2, boundingRect, Scalar.Red, thickness: 2);
isMatch= false;
}
}
string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_Rect.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2);
string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_diff.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath, blackhatImg);
return isMatch;
}
public static Rect strChangeRect(string strrect)
{
string[] rectstr = strrect.Split(",");
int areaX = int.Parse(rectstr[0]);
int areaY = int.Parse(rectstr[1]);
int areaWidth = int.Parse(rectstr[2]);
int areaHeight = int.Parse(rectstr[3]);
Rect rect = new Rect(areaX, areaY, areaWidth, areaHeight);
return rect;
}
public static string rectChangeStr(Rect area)
{
string[] rectsql = new string[4];
rectsql[0] = Convert.ToString(area.X);
rectsql[1] = Convert.ToString(area.Y);
rectsql[2] = Convert.ToString(area.Width);
rectsql[3] = Convert.ToString(area.Height);
string strrect = rectsql.Join(",");
return strrect;
}
//public static void CheckDiffSci(string path1, string path2, bool IfWhiteWord, string saveDir)
//{
// // 读取和处理第一张图片
// Mat img1 = Cv2.ImRead(path1, ImreadModes.Color);
// if (img1.Empty())
// {
// Console.WriteLine($"Error loading image {path1}");
// return;
// }
// Cv2.Resize(img1, img1, new Size(550, 270));
// Mat gimg1 = new Mat();
// Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY);
// Mat thr1 = new Mat();
// if (IfWhiteWord)
// {
// Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
// }
// else
// {
// Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
// }
// string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_thr1.png");
// // 保存结果
// //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
// Cv2.ImWrite(savePath4, thr1);
// // 读取和处理第二张图片
// Mat img2 = Cv2.ImRead(path2, ImreadModes.Color);
// if (img2.Empty())
// {
// Console.WriteLine($"Error loading image {path2}");
// return;
// }
// Cv2.Resize(img2, img2, new Size(550, 270));
// Mat gimg2 = new Mat();
// Cv2.CvtColor(img2, gimg2, ColorConversionCodes.BGR2GRAY);
// Mat thr2 = new Mat();
// //Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
// if (IfWhiteWord)
// {
// Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
// }
// else
// {
// Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
// }
// // Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
// string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_thr2.png");
// // 保存结果
// //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
// Cv2.ImWrite(savePath3, thr2);
// // 创建卷积核
// Mat filter1 = new Mat(17, 17, MatType.CV_32F, new Scalar(0));
// filter1.Row(8).SetTo(new Scalar(0.025));
// filter1.Col(8).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);
// 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);
// // 计算图像差异
// Mat devIMG = new Mat();
// Mat devIMG_ = new Mat();
// Cv2.Subtract(final_result1, final_result2, devIMG);
// Cv2.Subtract(final_result2, final_result1, devIMG_);
// // 对差异图像应用阈值
// Cv2.Threshold(devIMG, devIMG, 50, 255, ThresholdTypes.Binary);
// Cv2.Threshold(devIMG_, devIMG_, 50, 255, ThresholdTypes.Binary);
// // 结合差异
// Mat sumIMG = new Mat();
// Cv2.Add(devIMG, devIMG_, sumIMG);
// // 应用形态学操作
// Mat kernelCL = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(3, 3));
// Mat blackhatImg = new Mat();
// Cv2.Dilate(sumIMG, blackhatImg, kernelCL);
// // 处理轮廓和保存结果
// Point[][] contours = new Point[10000][];
// Cv2.FindContours(blackhatImg, out contours, out _, RetrievalModes.Tree, ContourApproximationModes.ApproxSimple);
// foreach (var contour in contours)
// {
// if (Cv2.ContourArea(contour) <= 100)
// {
// Cv2.DrawContours(blackhatImg, new Point[][] { contour }, -1, Scalar.Black, thickness: Cv2.FILLED);
// // 框选轮廓
// }
// else
// {
// Rect boundingRect = Cv2.BoundingRect(contour);
// Cv2.Rectangle(img2, boundingRect, Scalar.Red, thickness: 2);
// }
// }
// string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_Rect.png");
// // 保存结果
// //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
// Cv2.ImWrite(savePath2, img2);
// string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
// // 保存结果
// //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
// Cv2.ImWrite(savePath, blackhatImg);
//}
}
}

763
HisenceYoloDetection/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,763 @@
namespace HisenceYoloDetection
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
tableLayoutPanel1 = new TableLayoutPanel();
panel1 = new Panel();
groupBox5 = new GroupBox();
DistanceShow = new TextBox();
label21 = new Label();
txtSetValue = new TextBox();
groupBox4 = new GroupBox();
SetAutoSpeed = new Button();
SetHandleSpeed = new Button();
SetlnEditmiZOP = new TextBox();
SetlnEditmiYOP = new TextBox();
SetlnEditmiXOP = new TextBox();
SetlnEditmiZH = new TextBox();
SetlnEditmiYH = new TextBox();
SetlnEditmiXH = new TextBox();
lnEditmiZOP = new TextBox();
lnEditmiYOP = new TextBox();
lnEditmiXOP = new TextBox();
label17 = new Label();
lnEditmiZS = new TextBox();
lnEditmiYS = new TextBox();
lnEditmiXS = new TextBox();
label16 = new Label();
lnEditmiZHS = new TextBox();
lnEditmiYHS = new TextBox();
lnEditmiXHS = new TextBox();
label15 = new Label();
ZPostion = new Label();
YPostion = new Label();
XPostion = new Label();
XCurrentPostion = new Label();
label14 = new Label();
label13 = new Label();
label12 = new Label();
label11 = new Label();
ModeleShow = new GroupBox();
ZBackwardrbx = new RadioButton();
YBackwardrbx = new RadioButton();
XBackwardrbx = new RadioButton();
ZForwardrbx = new RadioButton();
YForwardrbx = new RadioButton();
XForwardrbx = new RadioButton();
ZZerorbx = new RadioButton();
YZerorbx = new RadioButton();
XZerorbx = new RadioButton();
PLCPostion = new Button();
PLCDiskZero = new Button();
PLCPowerON = new Button();
writePLCValue = new TextBox();
label9 = new Label();
label10 = new Label();
wirteAdressBtn = new Button();
PLCValue = new TextBox();
WriteAdress = new TextBox();
label6 = new Label();
label3 = new Label();
ConnectPLC = new Button();
readAdress = new Button();
showPLC = new TextBox();
readPLc = new TextBox();
tableLayoutPanel1.SuspendLayout();
panel1.SuspendLayout();
groupBox5.SuspendLayout();
groupBox4.SuspendLayout();
ModeleShow.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.ColumnCount = 1;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel1.Controls.Add(panel1, 0, 0);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 1;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel1.Size = new Size(1057, 450);
tableLayoutPanel1.TabIndex = 0;
//
// panel1
//
panel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
panel1.AutoSize = true;
panel1.Controls.Add(groupBox5);
panel1.Controls.Add(txtSetValue);
panel1.Controls.Add(groupBox4);
panel1.Controls.Add(ModeleShow);
panel1.Controls.Add(writePLCValue);
panel1.Controls.Add(label9);
panel1.Controls.Add(label10);
panel1.Controls.Add(wirteAdressBtn);
panel1.Controls.Add(PLCValue);
panel1.Controls.Add(WriteAdress);
panel1.Controls.Add(label6);
panel1.Controls.Add(label3);
panel1.Controls.Add(ConnectPLC);
panel1.Controls.Add(readAdress);
panel1.Controls.Add(showPLC);
panel1.Controls.Add(readPLc);
panel1.Location = new Point(3, 3);
panel1.Name = "panel1";
panel1.Size = new Size(1051, 444);
panel1.TabIndex = 5;
//
// groupBox5
//
groupBox5.Controls.Add(DistanceShow);
groupBox5.Controls.Add(label21);
groupBox5.Location = new Point(806, 10);
groupBox5.Name = "groupBox5";
groupBox5.Size = new Size(356, 100);
groupBox5.TabIndex = 15;
groupBox5.TabStop = false;
groupBox5.Text = "实时显示";
//
// DistanceShow
//
DistanceShow.Location = new Point(86, 30);
DistanceShow.Name = "DistanceShow";
DistanceShow.ReadOnly = true;
DistanceShow.Size = new Size(100, 23);
DistanceShow.TabIndex = 10;
//
// label21
//
label21.AutoSize = true;
label21.Location = new Point(28, 33);
label21.Name = "label21";
label21.Size = new Size(32, 17);
label21.TabIndex = 0;
label21.Text = "测距";
//
// txtSetValue
//
txtSetValue.Location = new Point(670, 78);
txtSetValue.Name = "txtSetValue";
txtSetValue.Size = new Size(100, 23);
txtSetValue.TabIndex = 14;
//
// groupBox4
//
groupBox4.Controls.Add(SetAutoSpeed);
groupBox4.Controls.Add(SetHandleSpeed);
groupBox4.Controls.Add(SetlnEditmiZOP);
groupBox4.Controls.Add(SetlnEditmiYOP);
groupBox4.Controls.Add(SetlnEditmiXOP);
groupBox4.Controls.Add(SetlnEditmiZH);
groupBox4.Controls.Add(SetlnEditmiYH);
groupBox4.Controls.Add(SetlnEditmiXH);
groupBox4.Controls.Add(lnEditmiZOP);
groupBox4.Controls.Add(lnEditmiYOP);
groupBox4.Controls.Add(lnEditmiXOP);
groupBox4.Controls.Add(label17);
groupBox4.Controls.Add(lnEditmiZS);
groupBox4.Controls.Add(lnEditmiYS);
groupBox4.Controls.Add(lnEditmiXS);
groupBox4.Controls.Add(label16);
groupBox4.Controls.Add(lnEditmiZHS);
groupBox4.Controls.Add(lnEditmiYHS);
groupBox4.Controls.Add(lnEditmiXHS);
groupBox4.Controls.Add(label15);
groupBox4.Controls.Add(ZPostion);
groupBox4.Controls.Add(YPostion);
groupBox4.Controls.Add(XPostion);
groupBox4.Controls.Add(XCurrentPostion);
groupBox4.Controls.Add(label14);
groupBox4.Controls.Add(label13);
groupBox4.Controls.Add(label12);
groupBox4.Controls.Add(label11);
groupBox4.Location = new Point(611, 107);
groupBox4.Name = "groupBox4";
groupBox4.Size = new Size(557, 373);
groupBox4.TabIndex = 13;
groupBox4.TabStop = false;
groupBox4.Text = "位置显示";
//
// SetAutoSpeed
//
SetAutoSpeed.Location = new Point(8, 315);
SetAutoSpeed.Name = "SetAutoSpeed";
SetAutoSpeed.Size = new Size(88, 23);
SetAutoSpeed.TabIndex = 29;
SetAutoSpeed.Text = "设置自动速度";
SetAutoSpeed.UseVisualStyleBackColor = true;
//
// SetHandleSpeed
//
SetHandleSpeed.Location = new Point(8, 258);
SetHandleSpeed.Name = "SetHandleSpeed";
SetHandleSpeed.Size = new Size(88, 23);
SetHandleSpeed.TabIndex = 28;
SetHandleSpeed.Text = "设置手动速度";
SetHandleSpeed.UseVisualStyleBackColor = true;
//
// SetlnEditmiZOP
//
SetlnEditmiZOP.Location = new Point(409, 315);
SetlnEditmiZOP.Name = "SetlnEditmiZOP";
SetlnEditmiZOP.Size = new Size(100, 23);
SetlnEditmiZOP.TabIndex = 27;
//
// SetlnEditmiYOP
//
SetlnEditmiYOP.Location = new Point(256, 315);
SetlnEditmiYOP.Name = "SetlnEditmiYOP";
SetlnEditmiYOP.Size = new Size(100, 23);
SetlnEditmiYOP.TabIndex = 26;
//
// SetlnEditmiXOP
//
SetlnEditmiXOP.Location = new Point(107, 315);
SetlnEditmiXOP.Name = "SetlnEditmiXOP";
SetlnEditmiXOP.Size = new Size(100, 23);
SetlnEditmiXOP.TabIndex = 25;
//
// SetlnEditmiZH
//
SetlnEditmiZH.Location = new Point(409, 258);
SetlnEditmiZH.Name = "SetlnEditmiZH";
SetlnEditmiZH.Size = new Size(100, 23);
SetlnEditmiZH.TabIndex = 23;
//
// SetlnEditmiYH
//
SetlnEditmiYH.Location = new Point(256, 258);
SetlnEditmiYH.Name = "SetlnEditmiYH";
SetlnEditmiYH.Size = new Size(100, 23);
SetlnEditmiYH.TabIndex = 22;
//
// SetlnEditmiXH
//
SetlnEditmiXH.Location = new Point(107, 258);
SetlnEditmiXH.Name = "SetlnEditmiXH";
SetlnEditmiXH.Size = new Size(100, 23);
SetlnEditmiXH.TabIndex = 21;
//
// lnEditmiZOP
//
lnEditmiZOP.Location = new Point(409, 200);
lnEditmiZOP.Name = "lnEditmiZOP";
lnEditmiZOP.Size = new Size(100, 23);
lnEditmiZOP.TabIndex = 19;
//
// lnEditmiYOP
//
lnEditmiYOP.Location = new Point(256, 200);
lnEditmiYOP.Name = "lnEditmiYOP";
lnEditmiYOP.Size = new Size(100, 23);
lnEditmiYOP.TabIndex = 18;
//
// lnEditmiXOP
//
lnEditmiXOP.Location = new Point(107, 200);
lnEditmiXOP.Name = "lnEditmiXOP";
lnEditmiXOP.Size = new Size(100, 23);
lnEditmiXOP.TabIndex = 17;
//
// label17
//
label17.AutoSize = true;
label17.Location = new Point(32, 203);
label17.Name = "label17";
label17.Size = new Size(56, 17);
label17.TabIndex = 16;
label17.Text = "定位位置";
//
// lnEditmiZS
//
lnEditmiZS.Location = new Point(409, 144);
lnEditmiZS.Name = "lnEditmiZS";
lnEditmiZS.ReadOnly = true;
lnEditmiZS.Size = new Size(100, 23);
lnEditmiZS.TabIndex = 15;
//
// lnEditmiYS
//
lnEditmiYS.Location = new Point(256, 144);
lnEditmiYS.Name = "lnEditmiYS";
lnEditmiYS.ReadOnly = true;
lnEditmiYS.Size = new Size(100, 23);
lnEditmiYS.TabIndex = 14;
//
// lnEditmiXS
//
lnEditmiXS.Location = new Point(107, 144);
lnEditmiXS.Name = "lnEditmiXS";
lnEditmiXS.ReadOnly = true;
lnEditmiXS.Size = new Size(100, 23);
lnEditmiXS.TabIndex = 13;
//
// label16
//
label16.AutoSize = true;
label16.Location = new Point(8, 147);
label16.Name = "label16";
label16.Size = new Size(80, 17);
label16.TabIndex = 12;
label16.Text = "当前定位速度";
//
// lnEditmiZHS
//
lnEditmiZHS.Location = new Point(409, 87);
lnEditmiZHS.Name = "lnEditmiZHS";
lnEditmiZHS.ReadOnly = true;
lnEditmiZHS.Size = new Size(100, 23);
lnEditmiZHS.TabIndex = 11;
//
// lnEditmiYHS
//
lnEditmiYHS.Location = new Point(256, 87);
lnEditmiYHS.Name = "lnEditmiYHS";
lnEditmiYHS.ReadOnly = true;
lnEditmiYHS.Size = new Size(100, 23);
lnEditmiYHS.TabIndex = 10;
//
// lnEditmiXHS
//
lnEditmiXHS.Location = new Point(107, 87);
lnEditmiXHS.Name = "lnEditmiXHS";
lnEditmiXHS.ReadOnly = true;
lnEditmiXHS.Size = new Size(100, 23);
lnEditmiXHS.TabIndex = 9;
//
// label15
//
label15.AutoSize = true;
label15.Location = new Point(8, 90);
label15.Name = "label15";
label15.Size = new Size(80, 17);
label15.TabIndex = 8;
label15.Text = "当前手动速度";
//
// ZPostion
//
ZPostion.AutoSize = true;
ZPostion.Location = new Point(451, 45);
ZPostion.Name = "ZPostion";
ZPostion.Size = new Size(15, 17);
ZPostion.TabIndex = 7;
ZPostion.Text = "0";
//
// YPostion
//
YPostion.AutoSize = true;
YPostion.Location = new Point(300, 45);
YPostion.Name = "YPostion";
YPostion.Size = new Size(15, 17);
YPostion.TabIndex = 6;
YPostion.Text = "0";
//
// XPostion
//
XPostion.AutoSize = true;
XPostion.Location = new Point(144, 45);
XPostion.Name = "XPostion";
XPostion.Size = new Size(15, 17);
XPostion.TabIndex = 5;
XPostion.Text = "0";
//
// XCurrentPostion
//
XCurrentPostion.AutoSize = true;
XCurrentPostion.Location = new Point(132, 45);
XCurrentPostion.Name = "XCurrentPostion";
XCurrentPostion.Size = new Size(0, 17);
XCurrentPostion.TabIndex = 4;
//
// label14
//
label14.AutoSize = true;
label14.Location = new Point(451, 22);
label14.Name = "label14";
label14.Size = new Size(15, 17);
label14.TabIndex = 3;
label14.Text = "Z";
//
// label13
//
label13.AutoSize = true;
label13.Location = new Point(300, 19);
label13.Name = "label13";
label13.Size = new Size(15, 17);
label13.TabIndex = 2;
label13.Text = "Y";
//
// label12
//
label12.AutoSize = true;
label12.Location = new Point(143, 19);
label12.Name = "label12";
label12.Size = new Size(16, 17);
label12.TabIndex = 1;
label12.Text = "X";
//
// label11
//
label11.AutoSize = true;
label11.Location = new Point(32, 45);
label11.Name = "label11";
label11.Size = new Size(56, 17);
label11.TabIndex = 0;
label11.Text = "当前位置";
//
// ModeleShow
//
ModeleShow.Controls.Add(ZBackwardrbx);
ModeleShow.Controls.Add(YBackwardrbx);
ModeleShow.Controls.Add(XBackwardrbx);
ModeleShow.Controls.Add(ZForwardrbx);
ModeleShow.Controls.Add(YForwardrbx);
ModeleShow.Controls.Add(XForwardrbx);
ModeleShow.Controls.Add(ZZerorbx);
ModeleShow.Controls.Add(YZerorbx);
ModeleShow.Controls.Add(XZerorbx);
ModeleShow.Controls.Add(PLCPostion);
ModeleShow.Controls.Add(PLCDiskZero);
ModeleShow.Controls.Add(PLCPowerON);
ModeleShow.Location = new Point(14, 107);
ModeleShow.Name = "ModeleShow";
ModeleShow.Size = new Size(579, 373);
ModeleShow.TabIndex = 12;
ModeleShow.TabStop = false;
ModeleShow.Text = "模组显示";
//
// ZBackwardrbx
//
ZBackwardrbx.Appearance = Appearance.Button;
ZBackwardrbx.Location = new Point(410, 180);
ZBackwardrbx.Name = "ZBackwardrbx";
ZBackwardrbx.Size = new Size(125, 62);
ZBackwardrbx.TabIndex = 21;
ZBackwardrbx.Text = "Z反向";
ZBackwardrbx.TextAlign = ContentAlignment.MiddleCenter;
ZBackwardrbx.UseVisualStyleBackColor = true;
//
// YBackwardrbx
//
YBackwardrbx.Appearance = Appearance.Button;
YBackwardrbx.Location = new Point(266, 180);
YBackwardrbx.Name = "YBackwardrbx";
YBackwardrbx.Size = new Size(125, 62);
YBackwardrbx.TabIndex = 20;
YBackwardrbx.Text = "Y反向";
YBackwardrbx.TextAlign = ContentAlignment.MiddleCenter;
YBackwardrbx.UseVisualStyleBackColor = true;
//
// XBackwardrbx
//
XBackwardrbx.Appearance = Appearance.Button;
XBackwardrbx.Location = new Point(126, 180);
XBackwardrbx.Name = "XBackwardrbx";
XBackwardrbx.Size = new Size(125, 62);
XBackwardrbx.TabIndex = 19;
XBackwardrbx.Text = "X反向";
XBackwardrbx.TextAlign = ContentAlignment.MiddleCenter;
XBackwardrbx.UseVisualStyleBackColor = true;
//
// ZForwardrbx
//
ZForwardrbx.Appearance = Appearance.Button;
ZForwardrbx.Location = new Point(410, 105);
ZForwardrbx.Name = "ZForwardrbx";
ZForwardrbx.Size = new Size(125, 62);
ZForwardrbx.TabIndex = 18;
ZForwardrbx.Text = "Z正向";
ZForwardrbx.TextAlign = ContentAlignment.MiddleCenter;
ZForwardrbx.UseVisualStyleBackColor = true;
//
// YForwardrbx
//
YForwardrbx.Appearance = Appearance.Button;
YForwardrbx.Location = new Point(266, 102);
YForwardrbx.Name = "YForwardrbx";
YForwardrbx.Size = new Size(125, 62);
YForwardrbx.TabIndex = 17;
YForwardrbx.Text = "Y正向";
YForwardrbx.TextAlign = ContentAlignment.MiddleCenter;
YForwardrbx.UseVisualStyleBackColor = true;
//
// XForwardrbx
//
XForwardrbx.Appearance = Appearance.Button;
XForwardrbx.Location = new Point(126, 105);
XForwardrbx.Name = "XForwardrbx";
XForwardrbx.Size = new Size(125, 62);
XForwardrbx.TabIndex = 16;
XForwardrbx.Text = "X正向";
XForwardrbx.TextAlign = ContentAlignment.MiddleCenter;
XForwardrbx.UseVisualStyleBackColor = true;
//
// ZZerorbx
//
ZZerorbx.Appearance = Appearance.Button;
ZZerorbx.Location = new Point(410, 22);
ZZerorbx.Name = "ZZerorbx";
ZZerorbx.Size = new Size(125, 62);
ZZerorbx.TabIndex = 15;
ZZerorbx.Text = "Z归零";
ZZerorbx.TextAlign = ContentAlignment.MiddleCenter;
ZZerorbx.UseVisualStyleBackColor = true;
//
// YZerorbx
//
YZerorbx.Appearance = Appearance.Button;
YZerorbx.Location = new Point(266, 22);
YZerorbx.Name = "YZerorbx";
YZerorbx.Size = new Size(125, 62);
YZerorbx.TabIndex = 14;
YZerorbx.Text = "Y归零";
YZerorbx.TextAlign = ContentAlignment.MiddleCenter;
YZerorbx.UseVisualStyleBackColor = true;
//
// XZerorbx
//
XZerorbx.Appearance = Appearance.Button;
XZerorbx.Location = new Point(126, 22);
XZerorbx.Name = "XZerorbx";
XZerorbx.Size = new Size(125, 62);
XZerorbx.TabIndex = 13;
XZerorbx.Text = "X归零";
XZerorbx.TextAlign = ContentAlignment.MiddleCenter;
XZerorbx.UseVisualStyleBackColor = true;
//
// PLCPostion
//
PLCPostion.Location = new Point(6, 258);
PLCPostion.Name = "PLCPostion";
PLCPostion.Size = new Size(97, 101);
PLCPostion.TabIndex = 2;
PLCPostion.Text = "定位";
PLCPostion.UseVisualStyleBackColor = true;
//
// PLCDiskZero
//
PLCDiskZero.Location = new Point(6, 141);
PLCDiskZero.Name = "PLCDiskZero";
PLCDiskZero.Size = new Size(97, 101);
PLCDiskZero.TabIndex = 1;
PLCDiskZero.Text = "归零";
PLCDiskZero.UseVisualStyleBackColor = true;
//
// PLCPowerON
//
PLCPowerON.Location = new Point(6, 22);
PLCPowerON.Name = "PLCPowerON";
PLCPowerON.Size = new Size(97, 101);
PLCPowerON.TabIndex = 0;
PLCPowerON.Text = "使能ON";
PLCPowerON.UseVisualStyleBackColor = true;
//
// writePLCValue
//
writePLCValue.Location = new Point(670, 10);
writePLCValue.Name = "writePLCValue";
writePLCValue.Size = new Size(100, 23);
writePLCValue.TabIndex = 11;
//
// label9
//
label9.AutoSize = true;
label9.Location = new Point(400, 52);
label9.Name = "label9";
label9.Size = new Size(20, 17);
label9.TabIndex = 10;
label9.Text = "值";
//
// label10
//
label10.AutoSize = true;
label10.Location = new Point(400, 16);
label10.Name = "label10";
label10.Size = new Size(32, 17);
label10.TabIndex = 9;
label10.Text = "地址";
//
// wirteAdressBtn
//
wirteAdressBtn.Location = new Point(574, 13);
wirteAdressBtn.Name = "wirteAdressBtn";
wirteAdressBtn.Size = new Size(75, 23);
wirteAdressBtn.TabIndex = 7;
wirteAdressBtn.Text = "写地址INT";
wirteAdressBtn.UseVisualStyleBackColor = true;
//
// PLCValue
//
PLCValue.Location = new Point(449, 46);
PLCValue.Name = "PLCValue";
PLCValue.Size = new Size(100, 23);
PLCValue.TabIndex = 8;
//
// WriteAdress
//
WriteAdress.Location = new Point(449, 13);
WriteAdress.Name = "WriteAdress";
WriteAdress.Size = new Size(100, 23);
WriteAdress.TabIndex = 6;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(126, 55);
label6.Name = "label6";
label6.Size = new Size(20, 17);
label6.TabIndex = 5;
label6.Text = "值";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(126, 19);
label3.Name = "label3";
label3.Size = new Size(32, 17);
label3.TabIndex = 4;
label3.Text = "地址";
//
// ConnectPLC
//
ConnectPLC.Location = new Point(14, 16);
ConnectPLC.Name = "ConnectPLC";
ConnectPLC.Size = new Size(99, 56);
ConnectPLC.TabIndex = 0;
ConnectPLC.Text = "链接PLC";
ConnectPLC.UseVisualStyleBackColor = true;
//
// readAdress
//
readAdress.Location = new Point(300, 16);
readAdress.Name = "readAdress";
readAdress.Size = new Size(75, 23);
readAdress.TabIndex = 2;
readAdress.Text = "读地址INT";
readAdress.UseVisualStyleBackColor = true;
//
// showPLC
//
showPLC.Location = new Point(175, 49);
showPLC.Name = "showPLC";
showPLC.Size = new Size(100, 23);
showPLC.TabIndex = 3;
//
// readPLc
//
readPLc.Location = new Point(175, 16);
readPLc.Name = "readPLc";
readPLc.Size = new Size(100, 23);
readPLc.TabIndex = 1;
//
// Form1
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1057, 450);
Controls.Add(tableLayoutPanel1);
Name = "Form1";
Text = "Form1";
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
panel1.ResumeLayout(false);
panel1.PerformLayout();
groupBox5.ResumeLayout(false);
groupBox5.PerformLayout();
groupBox4.ResumeLayout(false);
groupBox4.PerformLayout();
ModeleShow.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private TableLayoutPanel tableLayoutPanel1;
private Panel panel1;
private GroupBox groupBox5;
private TextBox DistanceShow;
private Label label21;
private TextBox txtSetValue;
private GroupBox groupBox4;
private Button SetAutoSpeed;
private Button SetHandleSpeed;
private TextBox SetlnEditmiZOP;
private TextBox SetlnEditmiYOP;
private TextBox SetlnEditmiXOP;
private TextBox SetlnEditmiZH;
private TextBox SetlnEditmiYH;
private TextBox SetlnEditmiXH;
private TextBox lnEditmiZOP;
private TextBox lnEditmiYOP;
private TextBox lnEditmiXOP;
private Label label17;
private TextBox lnEditmiZS;
private TextBox lnEditmiYS;
private TextBox lnEditmiXS;
private Label label16;
private TextBox lnEditmiZHS;
private TextBox lnEditmiYHS;
private TextBox lnEditmiXHS;
private Label label15;
private Label ZPostion;
private Label YPostion;
private Label XPostion;
private Label XCurrentPostion;
private Label label14;
private Label label13;
private Label label12;
private Label label11;
private GroupBox ModeleShow;
private RadioButton ZBackwardrbx;
private RadioButton YBackwardrbx;
private RadioButton XBackwardrbx;
private RadioButton ZForwardrbx;
private RadioButton YForwardrbx;
private RadioButton XForwardrbx;
private RadioButton ZZerorbx;
private RadioButton YZerorbx;
private RadioButton XZerorbx;
private Button PLCPostion;
private Button PLCDiskZero;
private Button PLCPowerON;
private TextBox writePLCValue;
private Label label9;
private Label label10;
private Button wirteAdressBtn;
private TextBox PLCValue;
private TextBox WriteAdress;
private Label label6;
private Label label3;
private Button ConnectPLC;
private Button readAdress;
private TextBox showPLC;
private TextBox readPLc;
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HisenceYoloDetection
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,394 +0,0 @@
namespace HisenceYoloDetection
{
partial class InsertSqlFrm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
button1 = new Button();
OpenTwoDirBtn = new Button();
OpenDirBtn = new Button();
Cam2MatCbx = new TextBox();
label3 = new Label();
Cam1MatCbx = new TextBox();
label4 = new Label();
QueryoneBtn = new Button();
DetectBArMatbox = new TextBox();
label11 = new Label();
InsertBtn = new Button();
moveTwoZbox = new TextBox();
label5 = new Label();
moveTwoYbox = new TextBox();
label9 = new Label();
moveTwoXbox = new TextBox();
label10 = new Label();
moveZbox = new TextBox();
label6 = new Label();
moveYbox = new TextBox();
label7 = new Label();
moveXbox = new TextBox();
label8 = new Label();
OcrBarBox = new TextBox();
label2 = new Label();
TypeBox = new TextBox();
queryALLBtn = new Button();
label1 = new Label();
InsertDataDgv = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)InsertDataDgv).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(button1);
panel1.Controls.Add(OpenTwoDirBtn);
panel1.Controls.Add(OpenDirBtn);
panel1.Controls.Add(Cam2MatCbx);
panel1.Controls.Add(label3);
panel1.Controls.Add(Cam1MatCbx);
panel1.Controls.Add(label4);
panel1.Controls.Add(QueryoneBtn);
panel1.Controls.Add(DetectBArMatbox);
panel1.Controls.Add(label11);
panel1.Controls.Add(InsertBtn);
panel1.Controls.Add(moveTwoZbox);
panel1.Controls.Add(label5);
panel1.Controls.Add(moveTwoYbox);
panel1.Controls.Add(label9);
panel1.Controls.Add(moveTwoXbox);
panel1.Controls.Add(label10);
panel1.Controls.Add(moveZbox);
panel1.Controls.Add(label6);
panel1.Controls.Add(moveYbox);
panel1.Controls.Add(label7);
panel1.Controls.Add(moveXbox);
panel1.Controls.Add(label8);
panel1.Controls.Add(OcrBarBox);
panel1.Controls.Add(label2);
panel1.Controls.Add(TypeBox);
panel1.Controls.Add(queryALLBtn);
panel1.Controls.Add(label1);
panel1.Controls.Add(InsertDataDgv);
panel1.Location = new Point(0, -3);
panel1.Name = "panel1";
panel1.Size = new Size(934, 533);
panel1.TabIndex = 0;
//
// button1
//
button1.Location = new Point(696, 152);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 32;
button1.Text = "打开文件";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// OpenTwoDirBtn
//
OpenTwoDirBtn.Location = new Point(696, 241);
OpenTwoDirBtn.Name = "OpenTwoDirBtn";
OpenTwoDirBtn.Size = new Size(75, 23);
OpenTwoDirBtn.TabIndex = 31;
OpenTwoDirBtn.Text = "打开文件";
OpenTwoDirBtn.UseVisualStyleBackColor = true;
OpenTwoDirBtn.Click += OpenTwoDirBtn_Click;
//
// OpenDirBtn
//
OpenDirBtn.Location = new Point(696, 193);
OpenDirBtn.Name = "OpenDirBtn";
OpenDirBtn.Size = new Size(75, 23);
OpenDirBtn.TabIndex = 30;
OpenDirBtn.Text = "打开文件";
OpenDirBtn.UseVisualStyleBackColor = true;
OpenDirBtn.Click += OpenDirBtn_Click;
//
// Cam2MatCbx
//
Cam2MatCbx.Location = new Point(478, 244);
Cam2MatCbx.Name = "Cam2MatCbx";
Cam2MatCbx.Size = new Size(188, 23);
Cam2MatCbx.TabIndex = 29;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(371, 244);
label3.Name = "label3";
label3.Size = new Size(80, 17);
label3.TabIndex = 28;
label3.Text = "面板第二张图";
//
// Cam1MatCbx
//
Cam1MatCbx.Location = new Point(478, 193);
Cam1MatCbx.Name = "Cam1MatCbx";
Cam1MatCbx.Size = new Size(188, 23);
Cam1MatCbx.TabIndex = 27;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(372, 199);
label4.Name = "label4";
label4.Size = new Size(80, 17);
label4.TabIndex = 26;
label4.Text = "面板第一张图";
//
// QueryoneBtn
//
QueryoneBtn.Location = new Point(827, 108);
QueryoneBtn.Name = "QueryoneBtn";
QueryoneBtn.Size = new Size(93, 23);
QueryoneBtn.TabIndex = 25;
QueryoneBtn.Text = "条件查询";
QueryoneBtn.UseVisualStyleBackColor = true;
QueryoneBtn.Click += QueryoneBtn_Click;
//
// DetectBArMatbox
//
DetectBArMatbox.Location = new Point(477, 152);
DetectBArMatbox.Name = "DetectBArMatbox";
DetectBArMatbox.Size = new Size(188, 23);
DetectBArMatbox.TabIndex = 24;
//
// label11
//
label11.AutoSize = true;
label11.Location = new Point(402, 158);
label11.Name = "label11";
label11.Size = new Size(56, 17);
label11.TabIndex = 23;
label11.Text = "条码录入";
//
// InsertBtn
//
InsertBtn.Location = new Point(827, 18);
InsertBtn.Name = "InsertBtn";
InsertBtn.Size = new Size(93, 23);
InsertBtn.TabIndex = 22;
InsertBtn.Text = "插入";
InsertBtn.UseVisualStyleBackColor = true;
InsertBtn.Click += InsertBtn_Click;
//
// moveTwoZbox
//
moveTwoZbox.Location = new Point(477, 101);
moveTwoZbox.Name = "moveTwoZbox";
moveTwoZbox.Size = new Size(188, 23);
moveTwoZbox.TabIndex = 21;
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(371, 107);
label5.Name = "label5";
label5.Size = new Size(87, 17);
label5.TabIndex = 20;
label5.Text = "第二次拍照Z轴";
//
// moveTwoYbox
//
moveTwoYbox.Location = new Point(477, 54);
moveTwoYbox.Name = "moveTwoYbox";
moveTwoYbox.Size = new Size(188, 23);
moveTwoYbox.TabIndex = 19;
//
// label9
//
label9.AutoSize = true;
label9.Location = new Point(371, 60);
label9.Name = "label9";
label9.Size = new Size(87, 17);
label9.TabIndex = 18;
label9.Text = "第二次拍照Y轴";
//
// moveTwoXbox
//
moveTwoXbox.Location = new Point(477, 12);
moveTwoXbox.Name = "moveTwoXbox";
moveTwoXbox.Size = new Size(188, 23);
moveTwoXbox.TabIndex = 17;
//
// label10
//
label10.AutoSize = true;
label10.Location = new Point(371, 18);
label10.Name = "label10";
label10.Size = new Size(88, 17);
label10.TabIndex = 16;
label10.Text = "第二次拍照X轴";
//
// moveZbox
//
moveZbox.Location = new Point(111, 193);
moveZbox.Name = "moveZbox";
moveZbox.Size = new Size(188, 23);
moveZbox.TabIndex = 15;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(17, 199);
label6.Name = "label6";
label6.Size = new Size(87, 17);
label6.TabIndex = 14;
label6.Text = "第一次拍照Z轴";
//
// moveYbox
//
moveYbox.Location = new Point(111, 146);
moveYbox.Name = "moveYbox";
moveYbox.Size = new Size(188, 23);
moveYbox.TabIndex = 13;
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(17, 152);
label7.Name = "label7";
label7.Size = new Size(87, 17);
label7.TabIndex = 12;
label7.Text = "第一次拍照Y轴";
//
// moveXbox
//
moveXbox.Location = new Point(111, 104);
moveXbox.Name = "moveXbox";
moveXbox.Size = new Size(188, 23);
moveXbox.TabIndex = 11;
//
// label8
//
label8.AutoSize = true;
label8.Location = new Point(17, 110);
label8.Name = "label8";
label8.Size = new Size(88, 17);
label8.TabIndex = 10;
label8.Text = "第一次拍照X轴";
//
// OcrBarBox
//
OcrBarBox.Location = new Point(111, 54);
OcrBarBox.Name = "OcrBarBox";
OcrBarBox.Size = new Size(188, 23);
OcrBarBox.TabIndex = 5;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(14, 60);
label2.Name = "label2";
label2.Size = new Size(32, 17);
label2.TabIndex = 4;
label2.Text = "条码";
//
// TypeBox
//
TypeBox.Location = new Point(111, 12);
TypeBox.Name = "TypeBox";
TypeBox.Size = new Size(188, 23);
TypeBox.TabIndex = 3;
TypeBox.TextChanged += TypeBox_TextChanged;
//
// queryALLBtn
//
queryALLBtn.Location = new Point(827, 59);
queryALLBtn.Name = "queryALLBtn";
queryALLBtn.Size = new Size(93, 23);
queryALLBtn.TabIndex = 2;
queryALLBtn.Text = "查询全部";
queryALLBtn.UseVisualStyleBackColor = true;
queryALLBtn.Click += queryALLBtn_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(14, 18);
label1.Name = "label1";
label1.Size = new Size(32, 17);
label1.TabIndex = 1;
label1.Text = "类型";
//
// InsertDataDgv
//
InsertDataDgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
InsertDataDgv.Location = new Point(12, 281);
InsertDataDgv.Name = "InsertDataDgv";
InsertDataDgv.RowTemplate.Height = 25;
InsertDataDgv.Size = new Size(919, 235);
InsertDataDgv.TabIndex = 0;
//
// InsertSqlFrm
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(946, 525);
Controls.Add(panel1);
Name = "InsertSqlFrm";
Text = "InsertSqlFrm";
panel1.ResumeLayout(false);
panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)InsertDataDgv).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button queryALLBtn;
private Label label1;
private DataGridView InsertDataDgv;
private TextBox moveZbox;
private Label label6;
private TextBox moveYbox;
private Label label7;
private TextBox moveXbox;
private Label label8;
private TextBox OcrBarBox;
private Label label2;
private TextBox TypeBox;
private TextBox DetectBArMatbox;
private Label label11;
private Button InsertBtn;
private TextBox moveTwoZbox;
private Label label5;
private TextBox moveTwoYbox;
private Label label9;
private TextBox moveTwoXbox;
private Label label10;
private Button QueryoneBtn;
private TextBox Cam2MatCbx;
private Label label3;
private TextBox Cam1MatCbx;
private Label label4;
private Button button1;
private Button OpenTwoDirBtn;
private Button OpenDirBtn;
}
}

View File

@ -1,198 +0,0 @@
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using XKRS.Device.SimboVision.SimboHelper;
namespace HisenceYoloDetection
{
public partial class InsertSqlFrm : Form
{
public InsertSqlFrm()
{
InitializeComponent();
}
public SimboObjectDetection simboObjectDetection;
public PaddleOcrModel paddleOcrModel ;
public PaddleOcrModelCountry paddleOcrModelCountry ;
private void TypeBox_TextChanged(object sender, EventArgs e)
{
}
string BarPath = "";
string Cam1OnePath = "";
string Cam1TwoPath = "";
private void InsertBtn_Click(object sender, EventArgs e)
{
try
{
string type = TypeBox.Text;
string OcrBar = OcrBarBox.Text;
string moveX = moveXbox.Text;
string moveY = moveYbox.Text;
string moveZ = moveZbox.Text;
string Detect = DetectBArMatbox.Text;
string movetwoX = moveTwoXbox.Text;
string movetwoY = moveTwoYbox.Text;
string movetwoZ = moveTwoZbox.Text;
if (!Regex.IsMatch(moveX, @"^[0-9]+$"))
{
MessageBox.Show("第一次拍照移动的X只能是数字");
return;
}
if (!Regex.IsMatch(moveY, @"^[0-9]+$"))
{
MessageBox.Show("第一次拍照移动的Y只能是数字");
return;
}
if (!Regex.IsMatch(moveZ, @"^[0-9]+$"))
{
MessageBox.Show("第一次拍照移动的Z只能是数字");
return;
}
if (!Regex.IsMatch(movetwoX, @"^[0-9]+$"))
{
MessageBox.Show("第二次拍照移动的X只能是数字");
return;
}
if (!Regex.IsMatch(movetwoY, @"^[0-9]+$"))
{
MessageBox.Show("第二次拍照移动的Y只能是数字");
return;
}
if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$"))
{
MessageBox.Show("第二次拍照移动的Z只能是数字");
return;
}
if (OcrBar != "" && Detect != "")
{
string sql = "insert into XK_Hisence VALUES('" + type + "','" + OcrBar + "',null,null," + moveX + "," + moveY + "," + moveZ + ",'" + Detect + "',null," + movetwoX + "," + movetwoY + "," + movetwoZ + ")";
SQLiteHelper.ExecuteSql(sql);
}
else
{
MessageBox.Show("插入的数据不能为NULL");
}
}
catch (Exception es)
{
}
}
private void queryALLBtn_Click(object sender, EventArgs e)
{
try
{
DataSet dataSet = SQLiteHelper.Query("select * from XK_Hisence");
InsertDataDgv.DataSource = dataSet.Tables[0];
}
catch (Exception es)
{
}
}
private void QueryoneBtn_Click(object sender, EventArgs e)
{
try
{
string type = TypeBox.Text;
string OcrBar = OcrBarBox.Text;
string moveX = moveXbox.Text;
string moveY = moveYbox.Text;
string moveZ = moveZbox.Text;
string Detect = DetectBArMatbox.Text;
string movetwoX = moveTwoXbox.Text;
string movetwoY = moveTwoYbox.Text;
string movetwoZ = moveTwoZbox.Text;
string sql = "select * from XK_Hisence where type='" + type + "' or OcrBar='" + OcrBar + "'";
DataSet dataSet = SQLiteHelper.Query(sql);
InsertDataDgv.DataSource = dataSet.Tables[0];
}
catch (Exception es)
{
}
}
/// <summary>
/// 打开条码的图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请打开图片";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fName = openFileDialog.FileName;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
DetectBArMatbox.Text = fName;
BarPath = fName;
}
}
private void OpenDirBtn_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请打开图片";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fName = openFileDialog.FileName;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
Cam1MatCbx.Text = fName;
Cam1OnePath = fName;
}
}
private void OpenTwoDirBtn_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请打开图片";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fName = openFileDialog.FileName;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
Cam2MatCbx.Text = fName;
Cam1TwoPath = fName;
}
}
}
}

View File

@ -143,6 +143,10 @@
ResultMatShow = new PictureBox();
tabPage3 = new TabPage();
panel2 = new Panel();
WhiteBanCbx = new CheckBox();
label33 = new Label();
label28 = new Label();
button1 = new Button();
openModelBtn = new Button();
modelChangeCbx = new TextBox();
label34 = new Label();
@ -164,7 +168,6 @@
moveTwoXbox = new TextBox();
label27 = new Label();
moveZbox = new TextBox();
label28 = new Label();
moveYbox = new TextBox();
label29 = new Label();
moveXbox = new TextBox();
@ -1343,6 +1346,10 @@
//
// panel2
//
panel2.Controls.Add(WhiteBanCbx);
panel2.Controls.Add(label33);
panel2.Controls.Add(label28);
panel2.Controls.Add(button1);
panel2.Controls.Add(openModelBtn);
panel2.Controls.Add(modelChangeCbx);
panel2.Controls.Add(label34);
@ -1364,7 +1371,6 @@
panel2.Controls.Add(moveTwoXbox);
panel2.Controls.Add(label27);
panel2.Controls.Add(moveZbox);
panel2.Controls.Add(label28);
panel2.Controls.Add(moveYbox);
panel2.Controls.Add(label29);
panel2.Controls.Add(moveXbox);
@ -1379,6 +1385,46 @@
panel2.Name = "panel2";
panel2.Size = new Size(1260, 533);
panel2.TabIndex = 1;
panel2.Paint += panel2_Paint;
//
// WhiteBanCbx
//
WhiteBanCbx.AutoSize = true;
WhiteBanCbx.Checked = true;
WhiteBanCbx.CheckState = CheckState.Checked;
WhiteBanCbx.Location = new Point(577, 245);
WhiteBanCbx.Name = "WhiteBanCbx";
WhiteBanCbx.Size = new Size(39, 21);
WhiteBanCbx.TabIndex = 40;
WhiteBanCbx.Text = "是";
WhiteBanCbx.UseVisualStyleBackColor = true;
//
// label33
//
label33.AutoSize = true;
label33.Location = new Point(373, 245);
label33.Name = "label33";
label33.Size = new Size(140, 17);
label33.TabIndex = 39;
label33.Text = "面板第二块区域是白板吗";
//
// label28
//
label28.AutoSize = true;
label28.Location = new Point(18, 199);
label28.Name = "label28";
label28.Size = new Size(87, 17);
label28.TabIndex = 14;
label28.Text = "第一次拍照Z轴";
//
// button1
//
button1.Location = new Point(896, 110);
button1.Name = "button1";
button1.Size = new Size(93, 23);
button1.TabIndex = 38;
button1.Text = "识别到log";
button1.UseVisualStyleBackColor = true;
//
// openModelBtn
//
@ -1409,7 +1455,7 @@
//
// button4
//
button4.Location = new Point(696, 152);
button4.Location = new Point(691, 110);
button4.Name = "button4";
button4.Size = new Size(75, 23);
button4.TabIndex = 32;
@ -1419,7 +1465,7 @@
//
// OpenTwoDirBtn
//
OpenTwoDirBtn.Location = new Point(696, 241);
OpenTwoDirBtn.Location = new Point(691, 199);
OpenTwoDirBtn.Name = "OpenTwoDirBtn";
OpenTwoDirBtn.Size = new Size(75, 23);
OpenTwoDirBtn.TabIndex = 31;
@ -1429,7 +1475,7 @@
//
// OpenDirBtn
//
OpenDirBtn.Location = new Point(696, 193);
OpenDirBtn.Location = new Point(691, 151);
OpenDirBtn.Name = "OpenDirBtn";
OpenDirBtn.Size = new Size(75, 23);
OpenDirBtn.TabIndex = 30;
@ -1439,16 +1485,16 @@
//
// Cam2MatCbx
//
Cam2MatCbx.Location = new Point(478, 244);
Cam2MatCbx.Location = new Point(473, 202);
Cam2MatCbx.Name = "Cam2MatCbx";
Cam2MatCbx.Size = new Size(218, 23);
Cam2MatCbx.TabIndex = 29;
Cam2MatCbx.Text = "D:\\Hisence\\4\\202452915599711.jpg";
Cam2MatCbx.Text = "D:\\Hisence\\类型\\Lp\\002jpg";
//
// label22
//
label22.AutoSize = true;
label22.Location = new Point(371, 244);
label22.Location = new Point(366, 202);
label22.Name = "label22";
label22.Size = new Size(80, 17);
label22.TabIndex = 28;
@ -1456,16 +1502,16 @@
//
// Cam1MatCbx
//
Cam1MatCbx.Location = new Point(478, 193);
Cam1MatCbx.Location = new Point(473, 151);
Cam1MatCbx.Name = "Cam1MatCbx";
Cam1MatCbx.Size = new Size(218, 23);
Cam1MatCbx.TabIndex = 27;
Cam1MatCbx.Text = "D:\\Hisence\\4\\202452915596701.jpg";
Cam1MatCbx.Text = "D:\\Hisence\\类型\\Lp\\001.jpg";
//
// label23
//
label23.AutoSize = true;
label23.Location = new Point(372, 199);
label23.Location = new Point(367, 157);
label23.Name = "label23";
label23.Size = new Size(80, 17);
label23.TabIndex = 26;
@ -1483,16 +1529,16 @@
//
// DetectBArMatbox
//
DetectBArMatbox.Location = new Point(477, 152);
DetectBArMatbox.Location = new Point(472, 110);
DetectBArMatbox.Name = "DetectBArMatbox";
DetectBArMatbox.Size = new Size(219, 23);
DetectBArMatbox.TabIndex = 24;
DetectBArMatbox.Text = "D:\\Hisence\\202452414231.jpg";
DetectBArMatbox.Text = "D:\\Hisence\\类型\\Lp202452414231.jpg";
//
// label24
//
label24.AutoSize = true;
label24.Location = new Point(402, 158);
label24.Location = new Point(397, 116);
label24.Name = "label24";
label24.Size = new Size(56, 17);
label24.TabIndex = 23;
@ -1510,7 +1556,7 @@
//
// moveTwoZbox
//
moveTwoZbox.Location = new Point(477, 101);
moveTwoZbox.Location = new Point(472, 59);
moveTwoZbox.Name = "moveTwoZbox";
moveTwoZbox.Size = new Size(219, 23);
moveTwoZbox.TabIndex = 21;
@ -1519,7 +1565,7 @@
// label25
//
label25.AutoSize = true;
label25.Location = new Point(371, 107);
label25.Location = new Point(366, 65);
label25.Name = "label25";
label25.Size = new Size(87, 17);
label25.TabIndex = 20;
@ -1527,7 +1573,7 @@
//
// moveTwoYbox
//
moveTwoYbox.Location = new Point(477, 54);
moveTwoYbox.Location = new Point(472, 12);
moveTwoYbox.Name = "moveTwoYbox";
moveTwoYbox.Size = new Size(213, 23);
moveTwoYbox.TabIndex = 19;
@ -1536,7 +1582,7 @@
// label26
//
label26.AutoSize = true;
label26.Location = new Point(371, 60);
label26.Location = new Point(366, 18);
label26.Name = "label26";
label26.Size = new Size(87, 17);
label26.TabIndex = 18;
@ -1544,7 +1590,7 @@
//
// moveTwoXbox
//
moveTwoXbox.Location = new Point(477, 12);
moveTwoXbox.Location = new Point(122, 242);
moveTwoXbox.Name = "moveTwoXbox";
moveTwoXbox.Size = new Size(213, 23);
moveTwoXbox.TabIndex = 17;
@ -1553,7 +1599,7 @@
// label27
//
label27.AutoSize = true;
label27.Location = new Point(371, 18);
label27.Location = new Point(16, 248);
label27.Name = "label27";
label27.Size = new Size(88, 17);
label27.TabIndex = 16;
@ -1563,24 +1609,15 @@
//
moveZbox.Location = new Point(111, 193);
moveZbox.Name = "moveZbox";
moveZbox.Size = new Size(188, 23);
moveZbox.Size = new Size(224, 23);
moveZbox.TabIndex = 15;
moveZbox.Text = "0";
//
// label28
//
label28.AutoSize = true;
label28.Location = new Point(12, 199);
label28.Name = "label28";
label28.Size = new Size(87, 17);
label28.TabIndex = 14;
label28.Text = "第一次拍照Z轴";
//
// moveYbox
//
moveYbox.Location = new Point(111, 146);
moveYbox.Name = "moveYbox";
moveYbox.Size = new Size(188, 23);
moveYbox.Size = new Size(224, 23);
moveYbox.TabIndex = 13;
moveYbox.Text = "0";
//
@ -1597,7 +1634,7 @@
//
moveXbox.Location = new Point(111, 104);
moveXbox.Name = "moveXbox";
moveXbox.Size = new Size(188, 23);
moveXbox.Size = new Size(224, 23);
moveXbox.TabIndex = 11;
moveXbox.Text = "8974";
//
@ -1614,7 +1651,7 @@
//
OcrBarBox.Location = new Point(111, 54);
OcrBarBox.Name = "OcrBarBox";
OcrBarBox.Size = new Size(188, 23);
OcrBarBox.Size = new Size(224, 23);
OcrBarBox.TabIndex = 5;
OcrBarBox.Text = "1234567890";
//
@ -1631,7 +1668,7 @@
//
TypeBox.Location = new Point(111, 12);
TypeBox.Name = "TypeBox";
TypeBox.Size = new Size(188, 23);
TypeBox.Size = new Size(224, 23);
TypeBox.TabIndex = 3;
TypeBox.Text = "1";
//
@ -1895,5 +1932,8 @@
private Button openModelBtn;
private TextBox modelChangeCbx;
private Label label34;
private Button button1;
private Label label33;
private CheckBox WhiteBanCbx;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,479 @@
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using XKRS.Device.SimboVision.SimboHelper;
using System.Diagnostics.Eventing.Reader;
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Drawing;
using Microsoft.VisualBasic;
namespace HisenceYoloDetection
{
public static class ManagerModelHelper
{
public static string RootPath = "D:\\Hisence\\SQLImages\\";
/// <summary>
/// 全图洗衣机 裁剪之后 OCR识别的结果
/// </summary>
/// <param name="saveimage"></param>
/// <param name="CutMat"></param>
/// <param name="currentMatC">全图图片</param>
/// <param name="cam1TwoML">全局图片上的目标定位结果(包括定位矩形框)</param>
/// <param name="cam1Button"></param>
/// <param name="xK_HisenceWord"></param>
/// <param name="strMatList">返回的定位框的结果</param>
/// <param name="strMatRefList"></param>
/// <param name="IOcrModel"></param>
public static void InsertSqlRunDataButton(bool saveimage,ref Mat CutMat, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord xK_HisenceWord, /*ref List<string> strMatList, ref List<string> strMatRefList, */ref PaddleOcrModel IOcrModel)
{
#if true
//try
//{
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;
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;
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
Rect area2 = new Rect();
if (blockIndex == "2")//根据旋钮扩大范围
{
areaBlack.X -= rectsx;
areaBlack.Y -= rectsy;
area2 = areaBlack;
string TwoRectStr= CheckDiffSciHelper.rectChangeStr(area2);
xK_HisenceWord.TwoRect = TwoRectStr;
//Mat matCutblack = new Mat(mResultCuti, area2);
//if((bool)xK_HisenceWord.TwoIFWhile)
//{
// matCutblack.SetTo(Scalar.Black);
//}
//else
//{
// matCutblack.SetTo(Scalar.Black);
//}
//rectsx -= rectsWidth;
//rectsy -= 50;
//rectsWidth = rectsWidth + 2 * rectsWidth;
//rectsHeight = rectsHeight + 2 + 50;
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
Mat matCut = new Mat(mResultCuti, area);
CutMat = matCut.Clone();
//Mat TwoCut = new Mat(mResultCuti, area2);
//TwoCut.SetTo(Scalar.Black);
//OCR识别裁剪图片
MLRequest reqcut = new MLRequest();
reqcut.currentMat = matCut.Clone();
MLResult mLCut = IOcrModel.RunInferenceFixed(reqcut);
//if (mLCut.IsSuccess)
//{
// DateTime dt = DateTime.Now;
// mLCut.ResultMap.Save("D:\\Hisence\\detImages\\OCR" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
//}
BlockChangeFun(saveimage, blockIndex, ref matCut, ref mLCut, ref xK_HisenceWord);
}
else
{
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
Mat matCut = new Mat(mResultCuti, area);
//OCR识别裁剪图片
MLRequest reqcut = new MLRequest();
reqcut.currentMat = matCut.Clone();
MLResult mLCut = IOcrModel.RunInferenceFixed(reqcut);
//if (mLCut.IsSuccess)
//{
// DateTime dt = DateTime.Now;
// mLCut.ResultMap.Save("D:\\Hisence\\detImages\\OCR" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
//}
BlockChangeFun(saveimage, blockIndex, ref matCut, ref mLCut, ref xK_HisenceWord);
}
//插入数据库
}
//}
//catch (Exception ex)
//{
//}
#endif
}
/// <summary>
/// 全图洗衣机 裁剪之后 OCR识别的结果
/// </summary>
/// <param name="currentMatC">全图图片</param>
/// <param name="cam1TwoML">全局图片上的目标定位结果(包括定位矩形框)</param>
/// <param name="strMatList">返回的定位框的结果</param>
public static void InsertSqlRunData(bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, ref XK_HisenceWord xK_HisenceWord, /*ref List<string> strMatList, ref List<string> strMatRefList,*/ ref PaddleOcrModel IOcrModel)
{
#if true
//try
//{
Mat mResultCut = currentMatC.Clone();
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;
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
Mat matCut = new Mat(mResultCuti, area);
//OCR识别裁剪图片
MLRequest reqcut = new MLRequest();
reqcut.currentMat = matCut.Clone();
MLResult mLCut = IOcrModel.RunInferenceFixed(reqcut);
//if (mLCut.IsSuccess)
//{
// DateTime dt = DateTime.Now;
// mLCut.ResultMap.Save("D:\\Hisence\\detImages\\OCR" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
//}
BlockChangeFun(saveimage, blockIndex, ref matCut, ref mLCut, ref xK_HisenceWord);
//插入数据库
}
//}
//catch (Exception ex)
//{
//}
#endif
}
/// <summary>
///
/// </summary>
/// <param name="saveimage">是否保存</param>
/// <param name="blockIndex">裁剪的一块索引</param>
/// <param name="CutBlockMat">裁剪的一张图片</param>
/// <param name="mLcut">裁剪图片的一些信息</param>
/// <param name="xK_HisenceWord">要存储入数据库的东西</param>
public static void BlockChangeFun(bool saveimage, string blockIndex, ref Mat CutBlockMat, ref MLResult mLcut, ref XK_HisenceWord xK_HisenceWord)
{
string ocrBar = xK_HisenceWord.OcrBar;
//存放关键字和所有字符串
List<string> OcrTextinsert = new List<string>();//存放关键字
List<string> OcrFuzzyTextInsert = new List<string>();//存放模糊字
string CutSavePath = "";
CombineMessage(saveimage, ocrBar, blockIndex, ref CutBlockMat, ref mLcut, ref OcrTextinsert, ref OcrFuzzyTextInsert, ref CutSavePath);
switch (blockIndex)
{
case "1"://完全匹配 重量信息
{
xK_HisenceWord.OneblockPath = CutSavePath;
xK_HisenceWord.OneblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.OneblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "2"://控制面板 匹配
{
xK_HisenceWord.TwoblockPath = CutSavePath;
xK_HisenceWord.TwoblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.TwoblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "3"://第三块板匹配
{
xK_HisenceWord.ThreeblockPath = CutSavePath;
xK_HisenceWord.ThreeblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.ThreeblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "4"://贴纸匹配
{
xK_HisenceWord.FourblockPath = CutSavePath;
xK_HisenceWord.FourblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.FourblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "5"://贴纸匹配
{
xK_HisenceWord.FiveblockPath = CutSavePath;
xK_HisenceWord.FiveblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.FiveblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "6"://贴纸匹配
{
xK_HisenceWord.SixblockPath = CutSavePath;
xK_HisenceWord.SixblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.SixblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "7"://贴纸匹配
{
xK_HisenceWord.SevenblockPath = CutSavePath;
xK_HisenceWord.SevenblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.SevenblockText = OcrFuzzyTextInsert.Join("##");
}
break;
case "8"://贴纸匹配
{
xK_HisenceWord.EightblockPath = CutSavePath;
xK_HisenceWord.EightblockMainWord = OcrTextinsert.Join("##");
xK_HisenceWord.EightblockText = OcrFuzzyTextInsert.Join("##");
}
break;
}
}
/// <summary>
///
/// </summary>
/// <param name="saveimage">是否保存本地图片</param>
/// <param name="OcrBar">唯一条形码</param>
/// <param name="blockIndex">区块号</param>
/// <param name="CutBlockMat">图像</param>
/// <param name="mLcut">图像上的数据</param>
/// <param name="OcrTextinsert">关键字</param>
/// <param name="OcrFuzzyTextInsert">所有字</param>
/// <param name="cutSavepath">图片保存路径</param>
public static void CombineMessage(bool saveimage, string OcrBar, string blockIndex, ref Mat CutBlockMat, ref MLResult mLcut, ref List<string> OcrTextinsert, ref List<string> OcrFuzzyTextInsert, ref string cutSavepath)
{
//在这里面找到带数字的关键字 将所有字也存放在数据库中
for (int j = 0; j < mLcut.ResultDetails.Count; j++)
{
string jdetial = mLcut.ResultDetails[j].LabelDisplay;
string result = Regex.Replace(jdetial, "[ \\[ \\] \\^ \\-_*×――(^)$%~!@#$…&%¥—+=<>《》!??:?`·、。,;,.;/\"‘’“”-]", "");
if (Regex.IsMatch(result, @"\d"))
{
OcrTextinsert.Add(result);
}
OcrFuzzyTextInsert.Add(result);
}
if (saveimage)
{
DateTime dt = DateTime.Now;
string namecutSavepath = OcrBar + "\\" + blockIndex + "\\" + OcrBar + "result.jpg";
cutSavepath = Path.Combine(RootPath, namecutSavepath);
//得到目录
if (!Directory.Exists(Path.GetDirectoryName(cutSavepath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(cutSavepath));
}
Cv2.ImWrite(cutSavepath, CutBlockMat);
}
}
public static List<XK_HisenceWord> GetModeWordFromBar(string SkBar)
{
List<XK_HisenceWord> cslist = SQLiteHelper.ExecuteQuery($"select * from XK_HisenceWord where OCRBar='{SkBar}' ", r => new XK_HisenceWord
{
OcrBar = r["OcrBar"].ToString(),
OneblockPath = r["OneblockPath"].ToString(),
OneblockMainWord = r["OneblockMainWord"].ToString(),
OneblockText = r["OneblockText"].ToString(),
TwoRect = r["TwoRect"].ToString(),
TwoIFWhile = r["TwoIFWhile"].ToBool(),
TwoblockPath = r["TwoblockPath"].ToString(),
TwoblockMainWord = r["TwoblockMainWord"].ToString(),
TwoblockText = r["TwoblockText"].ToString(),
ThreeblockPath = r["ThreeblockPath"].ToString(),
ThreeblockMainWord = r["ThreeblockMainWord"].ToString(),
ThreeblockText = r["ThreeblockText"].ToString(),
FourblockPath = r["FourblockPath"].ToString(),
FourblockMainWord = r["FourblockMainWord"].ToString(),
FourblockText = r["FourblockText"].ToString(),
FiveblockPath = r["FiveblockPath"].ToString(),
FiveblockMainWord = r["FiveblockMainWord"].ToString(),
FiveblockText = r["FiveblockText"].ToString(),
SixblockPath = r["SixblockPath"].ToString(),
SixblockMainWord = r["SixblockMainWord"].ToString(),
SixblockText = r["SixblockText"].ToString(),
SevenblockPath = r["SevenblockPath"].ToString(),
SevenblockMainWord = r["SevenblockMainWord"].ToString(),
SevenblockText = r["SevenblockText"].ToString(),
EightblockPath = r["EightblockPath"].ToString(),
EightblockMainWord = r["EightblockMainWord"].ToString(),
EightblockText = r["EightblockText"].ToString()
});
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://");
//第三块区域一直都是false
if (OneIF && TwoIF && ThreeIF && FourIF && FiveIF && SixIF && SenvenIF && EightIF&& twoif2)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
}
public static bool isMatchStr(string SqlText, string DetText)
{
if (SqlText.Contains("##") && DetText.Contains("##"))
{
// 计算Levenshtein距离
int distance = LevenshteinDistance(SqlText, DetText);
// 计算相似度相似度等于1减去标准化的Levenshtein距离
double similarity = 1 - ((double)distance / Math.Max(SqlText.Length, DetText.Length));
bool areEqual = false;
if (similarity<0.5)
{
areEqual = false;
}
else
{
areEqual = true;
}
//string[] sArraysql = Regex.Split(SqlText, "##", RegexOptions.IgnoreCase);
//string[] sArraydet = Regex.Split(DetText, "##", RegexOptions.IgnoreCase);
//bool areEqual = sArraysql.OrderBy(x => x).SequenceEqual(sArraydet.OrderBy(x => x));
return areEqual;
}
else if ((SqlText == "" || SqlText == null) && (DetText == "" || DetText == null))
{
return true;
}
else
{
return false;
}
}
// 计算Levenshtein距离
static int LevenshteinDistance(string string1, string string2)
{
int[,] dp = new int[string1.Length + 1, string2.Length + 1];
for (int i = 0; i <= string1.Length; i++)
dp[i, 0] = i;
for (int j = 0; j <= string2.Length; j++)
dp[0, j] = j;
for (int i = 1; i <= string1.Length; i++)
{
for (int j = 1; j <= string2.Length; j++)
{
int cost = string1[i - 1] == string2[j - 1] ? 0 : 1;
dp[i, j] = Math.Min(Math.Min(dp[i - 1, j] + 1, dp[i, j - 1] + 1), dp[i - 1, j - 1] + cost);
}
}
return dp[string1.Length, string2.Length];
}
}
}

View File

@ -11,7 +11,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();

View File

@ -111,7 +111,7 @@ namespace XKRS.Device.SimboVision.SimboHelper
#endif
[HandleProcessCorruptedStateExceptions]
public MLResultModel RunInference(MLRequest req)
public MLResult RunInference(MLRequest req)
{
#if USE_MULTI_THREAD
MLResult mlResult = null;
@ -139,7 +139,7 @@ namespace XKRS.Device.SimboVision.SimboHelper
}
private void ConvertJsonResult(string json, ref MLResultModel result)
private void ConvertJsonResult(string json, ref MLResult result)
{
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
//
@ -199,9 +199,9 @@ namespace XKRS.Device.SimboVision.SimboHelper
[HandleProcessCorruptedStateExceptions]
public MLResultModel RunInferenceFixed(MLRequest req)
public MLResult RunInferenceFixed(MLRequest req)
{
MLResultModel mlResult = new MLResultModel();
MLResult mlResult = new MLResult();
Mat originMat = new Mat();
try
@ -237,7 +237,7 @@ namespace XKRS.Device.SimboVision.SimboHelper
mlResult.ResultMap = BitmapConverter.ToBitmap(maskWeighted);//4ms
//将字节数组转换为字符串
mlResult.ResultMap = originMat.ToBitmap();//4ms
//mlResult.ResultMap = originMat.ToBitmap();//4ms
string strGet = System.Text.Encoding.Default.GetString(labellist, 0, labellist.Length);

View File

@ -111,7 +111,7 @@ namespace XKRS.Device.SimboVision.SimboHelper
#endif
[HandleProcessCorruptedStateExceptions]
public MLResultModel RunInference(MLRequest req)
public MLResult RunInference(MLRequest req)
{
#if USE_MULTI_THREAD
MLResult mlResult = null;
@ -139,7 +139,7 @@ namespace XKRS.Device.SimboVision.SimboHelper
}
private void ConvertJsonResult(string json, ref MLResultModel result)
private void ConvertJsonResult(string json, ref MLResult result)
{
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
//
@ -220,9 +220,9 @@ namespace XKRS.Device.SimboVision.SimboHelper
[HandleProcessCorruptedStateExceptions]
public MLResultModel RunInferenceFixed(MLRequest req)
public MLResult RunInferenceFixed(MLRequest req)
{
MLResultModel mlResult = new MLResultModel();
MLResult mlResult = new MLResult();
Mat originMat = new Mat();
try

View File

@ -3,6 +3,7 @@ namespace HisenceYoloDetection
internal static class Program
{
static MainForm? mainFrm = null;
static Form1? form1 = null;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -17,6 +18,8 @@ namespace HisenceYoloDetection
ApplicationConfiguration.Initialize();
mainFrm = new MainForm();
Application.Run(mainFrm);
//form1 = new Form1();
//Application.Run(form1);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
}catch (Exception ex)

View File

@ -4,6 +4,8 @@ using System.Collections.Specialized;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.SqlTypes;
public class SQLiteHelper
@ -358,8 +360,33 @@ using System.Configuration;
return ds;
}
}
// 执行一个查询,并将结果集映射到一个对象列表
public static List<T> ExecuteQuery<T>(string SQLString, Func<IDataRecord, T> selector, params SQLiteParameter[] parameters)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
{
// 添加参数
cmd.Parameters.AddRange(parameters);
// 打开连接
connection.Open();
// 创建DataReader对象并读取数据将每行数据映射到对象并添加到列表中
using (SQLiteDataReader reader = cmd.ExecuteReader())
{
List<T> list = new List<T>();
while (reader.Read())
{
list.Add(selector(reader));
}
return list;
}
}
}
}
public static DataSet Query(string SQLString, string TableName)
public static DataSet Query(string SQLString, string TableName)
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{

View File

@ -6,6 +6,74 @@ using System.Drawing;
using System.Runtime.InteropServices;
public class XK_HisenceWord
{
public string? OcrBar;
public string? OneblockPath;
public string? OneblockMainWord;
public string? OneblockText;
public string? TwoRect;
public bool? TwoIFWhile;
public string? TwoblockPath;
public string? TwoblockMainWord;
public string? TwoblockText;
public string? ThreeblockPath;
public string? ThreeblockMainWord;
public string? ThreeblockText;
public string? FourblockPath;
public string? FourblockMainWord;
public string? FourblockText;
public string? FiveblockPath;
public string? FiveblockMainWord;
public string? FiveblockText;
public string? SixblockPath;
public string? SixblockMainWord;
public string? SixblockText;
public string? SevenblockPath;
public string? SevenblockMainWord;
public string? SevenblockText;
public string? EightblockPath;
public string? EightblockMainWord;
public string? EightblockText;
public XK_HisenceWord()
{
}
public XK_HisenceWord(string? ocrBar, string? oneblockPath, string? oneblockMainWord, string? oneblockText, string? twoRect, bool? twoIFWhile, string? twoblockPath, string? twoblockMainWord, string? twoblockText, string? threeblockPath, string? threeblockMainWord, string? threeblockText, string? fourblockPath, string? fourblockMainWord, string? fourblockText, string? fiveblockPath, string? fiveblockMainWord, string? fiveblockText, string? sixblockPath, string? sixblockMainWord, string? sixblockText, string? sevenblockPath, string? sevenblockMainWord, string? sevenblockText, string? eightblockPath, string? eightblockMainWord, string? eightblockText)
{
OcrBar = ocrBar;
OneblockPath = oneblockPath;
OneblockMainWord = oneblockMainWord;
OneblockText = oneblockText;
TwoRect = twoRect;
TwoIFWhile = twoIFWhile;
TwoblockPath = twoblockPath;
TwoblockMainWord = twoblockMainWord;
TwoblockText = twoblockText;
ThreeblockPath = threeblockPath;
ThreeblockMainWord = threeblockMainWord;
ThreeblockText = threeblockText;
FourblockPath = fourblockPath;
FourblockMainWord = fourblockMainWord;
FourblockText = fourblockText;
FiveblockPath = fiveblockPath;
FiveblockMainWord = fiveblockMainWord;
FiveblockText = fiveblockText;
SixblockPath = sixblockPath;
SixblockMainWord = sixblockMainWord;
SixblockText = sixblockText;
SevenblockPath = sevenblockPath;
SevenblockMainWord = sevenblockMainWord;
SevenblockText = sevenblockText;
EightblockPath = eightblockPath;
EightblockMainWord = eightblockMainWord;
EightblockText = eightblockText;
}
}
public class XKHisence
{
@ -23,12 +91,13 @@ public class XKHisence
public int MoveTwoZ;
public string ?OcrParm;
public string ?Language;
public string? FuzzyOcrText;
public XKHisence()
{
}
public XKHisence(String type,string ocrBar,int MoveX,int MoveY,int MoveZ,string Detect,string ocrText,int MoveTwoX,int MoveTwoY,int MoveTwoZ,string OcrParm,string Language)
public XKHisence(string type,string ocrBar,int MoveX,int MoveY,int MoveZ,string Detect,string ocrText,int MoveTwoX,int MoveTwoY,int MoveTwoZ,string OcrParm,string Language,string FuzzyOcrText)
{
this.Type = type;
this.OcrBar = ocrBar;
@ -42,6 +111,7 @@ public class XKHisence
this.MoveTwoZ = MoveTwoZ;
this.OcrParm = OcrParm;
this.Language = Language;
this.FuzzyOcrText = FuzzyOcrText;
}
@ -69,12 +139,13 @@ public class MLRequest
public int ResizeImageSize;
public int segmentWidth;
public int ImageWidth;
public float Score;
public MLRequest()
{
}
}
public class DetectionResultDetail
{
@ -111,17 +182,7 @@ public class MLResult
public List<DetectionResultDetail> ResultDetails = new List<DetectionResultDetail>();
}
public class MLResultModel
{
public bool IsSuccess = false;
public string ResultMessage;
public Bitmap ResultMap;
public List<DetectionResultDetail> ResultDetails = new List<DetectionResultDetail>();
public string WashMachineBar;
public string WashMachineBatch;
public string WashMachineSN;
public string WashMachineLanguage;
}
public static class MLEngine
{

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,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();