7 Commits

5 changed files with 516 additions and 291 deletions

View File

@ -1,10 +1,12 @@
using OpenCvSharp; using OpenCvSharp;
using Sunny.UI.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using Point = OpenCvSharp.Point; using Point = OpenCvSharp.Point;
using Size = OpenCvSharp.Size; using Size = OpenCvSharp.Size;
@ -14,7 +16,6 @@ namespace HisenceYoloDetection
{ {
public static class CheckDiffSciHelper public static class CheckDiffSciHelper
{ {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -22,9 +23,9 @@ namespace HisenceYoloDetection
/// <param name="path2">要对比的图像</param> /// <param name="path2">要对比的图像</param>
/// <param name="IfWhiteWord"> 白板黑字为true </param> /// <param name="IfWhiteWord"> 白板黑字为true </param>
/// <param name="saveDir">存储路径</param> /// <param name="saveDir">存储路径</param>
public static bool CheckDiffSci(string path1, Mat MatDet,Rect sqlrect,Rect detrect, bool IfWhiteWord, string saveDir) public static bool CheckDiffSci(string path1, Mat MatDet, Rect sqlrect, Rect detrect, bool IfWhiteWord, string saveDir)
{ {
// 读取和处理第一张图片 // 读取和处理第一张图片。。
Mat img1 = Cv2.ImRead(path1, ImreadModes.Color); Mat img1 = Cv2.ImRead(path1, ImreadModes.Color);
if (img1.Empty()) if (img1.Empty())
{ {
@ -36,7 +37,7 @@ namespace HisenceYoloDetection
Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY); Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY);
Mat thr1 = new Mat(); Mat thr1 = new Mat();
if(IfWhiteWord) if (IfWhiteWord)
{ {
Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu); Cv2.Threshold(gimg1, thr1, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
} }
@ -68,13 +69,13 @@ namespace HisenceYoloDetection
{ {
Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu); 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); //Rect area2 = new Rect(148,30,229,222);
sqlrect.Width += 20; sqlrect.Width += 20;
sqlrect.Height += 60;
detrect.Width += 20; detrect.Width += 20;
detrect.Height += 60;
Mat matCutblack1 = new Mat(thr1, sqlrect); Mat matCutblack1 = new Mat(thr1, sqlrect);
if (IfWhiteWord) if (IfWhiteWord)
{ {
@ -95,17 +96,17 @@ namespace HisenceYoloDetection
} }
Cv2.Resize(thr1, thr1, new Size(550, 270)); Cv2.Resize(thr1, thr1, new Size(550, 270));
Cv2.Resize(thr2, thr2, new Size(550, 270)); Cv2.Resize(thr2, thr2, new Size(550, 270));
DateTime dt= DateTime.Now; 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 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); //Cv2.ImWrite(savePath4, thr1);
string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_thr2.png"); //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)); Mat filter1 = new Mat(15, 15, MatType.CV_32F, new Scalar(0));
@ -145,10 +146,17 @@ namespace HisenceYoloDetection
Mat devIMG_ = new Mat(); Mat devIMG_ = new Mat();
Cv2.Subtract(final_result1, final_result2, devIMG); Cv2.Subtract(final_result1, final_result2, devIMG);
Cv2.Subtract(final_result2, final_result1, 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_);
// 对差异图像应用阈值 // 对差异图像应用阈值
Cv2.Threshold(devIMG, devIMG, 50, 255, ThresholdTypes.Binary); Cv2.Threshold(devIMG, devIMG, 20, 255, ThresholdTypes.Binary);
Cv2.Threshold(devIMG_, devIMG_, 50, 255, ThresholdTypes.Binary); Cv2.Threshold(devIMG_, devIMG_, 20, 255, ThresholdTypes.Binary);
// 结合差异 // 结合差异
Mat sumIMG = new Mat(); Mat sumIMG = new Mat();
@ -159,6 +167,240 @@ namespace HisenceYoloDetection
Mat blackhatImg = new Mat(); Mat blackhatImg = new Mat();
Cv2.Dilate(sumIMG, blackhatImg, kernelCL); 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) <= 500)
{
Cv2.DrawContours(blackhatImg, new Point[][] { contour }, -1, Scalar.Black, thickness: Cv2.FILLED);
// 框选轮廓
string savePath2 = Path.Combine("D:\\Hisence\\Test\\2\\ng", Path.GetFileNameWithoutExtension(path1) + filename + "_Rect.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2);
string savePath = Path.Combine("D:\\Hisence\\Test\\2\\ng", Path.GetFileNameWithoutExtension(path1) + filename + "_diff.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath, blackhatImg);
}
else
{
Rect boundingRect = Cv2.BoundingRect(contour);
Cv2.Rectangle(img2, boundingRect, Scalar.Red, thickness: 2);
isMatch = false;
string savePath2 = Path.Combine("D:\\Hisence\\Test\\2\\ok", Path.GetFileNameWithoutExtension(path1) + filename + "_Rect.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2);
string savePath = Path.Combine("D:\\Hisence\\Test\\2\\ok", Path.GetFileNameWithoutExtension(path1) + filename + "_diff.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath, blackhatImg);
}
}
return isMatch;
}
public static Rect strChangeRect(string strrect)
{
if (!string.IsNullOrEmpty(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;
}
else
{
return new Rect(0, 0, 0, 0);
}
}
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 class CheckDiffSciHelper1
{
/// <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, 100, 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, 100, 255, ThresholdTypes.Binary );//| ThresholdTypes.Otsu
}
//Rect area2 = new Rect(148,30,229,222);
sqlrect.Width += 20;
sqlrect.Height += 20;
detrect.Width += 20;
detrect.Height += 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);
}
Cv2.Resize(thr1, thr1, new Size(845, 498));
Cv2.Resize(thr2, thr2, new Size(845, 498));
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");
//// 保存结果
//Cv2.ImWrite(savePath4, thr1);
//string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr2.png");
//// 保存结果
//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 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);
//裁剪才行
//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_);
//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);
// 结合差异
Mat sumIMG = new Mat();
Cv2.Add(devIMG, devIMG_, sumIMG);
//string savePaths = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "sumIMG.png");
//// 保存结果
//Cv2.ImWrite(savePaths, 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][]; Point[][] contours = new Point[10000][];
Cv2.FindContours(blackhatImg, out contours, out _, RetrievalModes.Tree, ContourApproximationModes.ApproxSimple); Cv2.FindContours(blackhatImg, out contours, out _, RetrievalModes.Tree, ContourApproximationModes.ApproxSimple);
@ -175,168 +417,20 @@ namespace HisenceYoloDetection
{ {
Rect boundingRect = Cv2.BoundingRect(contour); Rect boundingRect = Cv2.BoundingRect(contour);
Cv2.Rectangle(img2, boundingRect, Scalar.Red, thickness: 2); Cv2.Rectangle(img2, boundingRect, Scalar.Red, thickness: 2);
isMatch= false; isMatch = false;
} }
} }
string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_Rect.png"); string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_Rect.png");
// 保存结果 // 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png"); //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2); Cv2.ImWrite(savePath2, img2);
string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_diff.png"); string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_diff.png");
// 保存结果 // 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png"); //string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath, blackhatImg); Cv2.ImWrite(savePath, blackhatImg);
return isMatch; return isMatch;
} }
public static Rect strChangeRect(string strrect)
{
if (!string.IsNullOrEmpty(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;
}else
{
return new Rect(0,0,0, 0);
} }
}
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);
//}
} }
} }

View File

@ -31,13 +31,13 @@
components = new System.ComponentModel.Container(); components = new System.ComponentModel.Container();
OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat(); OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat2 = 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();
OpenCvSharp.Mat mat6 = new OpenCvSharp.Mat(); OpenCvSharp.Mat mat6 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat7 = new OpenCvSharp.Mat(); OpenCvSharp.Mat mat7 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat8 = new OpenCvSharp.Mat(); OpenCvSharp.Mat mat8 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat5 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat9 = new OpenCvSharp.Mat(); OpenCvSharp.Mat mat9 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat4 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
tabPage2 = new TabPage(); tabPage2 = new TabPage();
panel1 = new Panel(); panel1 = new Panel();
@ -75,6 +75,8 @@
label12 = new Label(); label12 = new Label();
label11 = new Label(); label11 = new Label();
ModeleShow = new GroupBox(); ModeleShow = new GroupBox();
handStopBtn = new Button();
HandRuningBtn = new Button();
ZBackwardrbx = new RadioButton(); ZBackwardrbx = new RadioButton();
YBackwardrbx = new RadioButton(); YBackwardrbx = new RadioButton();
XBackwardrbx = new RadioButton(); XBackwardrbx = new RadioButton();
@ -128,7 +130,8 @@
tabPage5 = new TabPage(); tabPage5 = new TabPage();
panel4 = new Panel(); panel4 = new Panel();
panel5 = new Panel(); panel5 = new Panel();
DefetShow5 = new XKRS.UI.Canvas(); DefetShow7 = new XKRS.UI.Canvas();
DefetShow6 = new XKRS.UI.Canvas();
panel8 = new Panel(); panel8 = new Panel();
= new Label(); = new Label();
OKOrNGShow = new PictureBox(); OKOrNGShow = new PictureBox();
@ -142,11 +145,12 @@
ScanDevList = new Button(); ScanDevList = new Button();
DevNameCombo = new ComboBox(); DevNameCombo = new ComboBox();
InitMachine = new Button(); InitMachine = new Button();
DefetShow2 = new XKRS.UI.Canvas();
panel6 = new Panel(); panel6 = new Panel();
groupBox2 = new GroupBox(); groupBox2 = new GroupBox();
DefetShow5 = new XKRS.UI.Canvas();
DefetShow4 = new XKRS.UI.Canvas(); DefetShow4 = new XKRS.UI.Canvas();
DefetShow3 = new XKRS.UI.Canvas(); DefetShow3 = new XKRS.UI.Canvas();
DefetShow2 = new XKRS.UI.Canvas();
originMat2Show = new PictureBox(); originMat2Show = new PictureBox();
DefetShow1 = new XKRS.UI.Canvas(); DefetShow1 = new XKRS.UI.Canvas();
ResultMatShow2 = new PictureBox(); ResultMatShow2 = new PictureBox();
@ -198,8 +202,6 @@
richTextBox1 = new RichTextBox(); richTextBox1 = new RichTextBox();
contextMenuStrip1 = new ContextMenuStrip(components); contextMenuStrip1 = new ContextMenuStrip(components);
backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
DefetShow6 = new XKRS.UI.Canvas();
DefetShow7 = new XKRS.UI.Canvas();
tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
panel1.SuspendLayout(); panel1.SuspendLayout();
groupBox5.SuspendLayout(); groupBox5.SuspendLayout();
@ -563,6 +565,8 @@
// //
// ModeleShow // ModeleShow
// //
ModeleShow.Controls.Add(handStopBtn);
ModeleShow.Controls.Add(HandRuningBtn);
ModeleShow.Controls.Add(ZBackwardrbx); ModeleShow.Controls.Add(ZBackwardrbx);
ModeleShow.Controls.Add(YBackwardrbx); ModeleShow.Controls.Add(YBackwardrbx);
ModeleShow.Controls.Add(XBackwardrbx); ModeleShow.Controls.Add(XBackwardrbx);
@ -582,6 +586,26 @@
ModeleShow.TabStop = false; ModeleShow.TabStop = false;
ModeleShow.Text = "模组显示"; ModeleShow.Text = "模组显示";
// //
// handStopBtn
//
handStopBtn.Location = new Point(266, 266);
handStopBtn.Name = "handStopBtn";
handStopBtn.Size = new Size(125, 82);
handStopBtn.TabIndex = 23;
handStopBtn.Text = "手动阻塞";
handStopBtn.UseVisualStyleBackColor = true;
handStopBtn.Click += handStopBtn_Click;
//
// HandRuningBtn
//
HandRuningBtn.Location = new Point(410, 266);
HandRuningBtn.Name = "HandRuningBtn";
HandRuningBtn.Size = new Size(125, 82);
HandRuningBtn.TabIndex = 22;
HandRuningBtn.Text = "手动放行";
HandRuningBtn.UseVisualStyleBackColor = true;
HandRuningBtn.Click += HandRuningBtn_Click;
//
// ZBackwardrbx // ZBackwardrbx
// //
ZBackwardrbx.Appearance = Appearance.Button; ZBackwardrbx.Appearance = Appearance.Button;
@ -1142,26 +1166,47 @@
panel5.Size = new Size(1276, 762); panel5.Size = new Size(1276, 762);
panel5.TabIndex = 0; panel5.TabIndex = 0;
// //
// DefetShow5 // DefetShow7
// //
DefetShow5.AllowSelectDefect = true; DefetShow7.AllowSelectDefect = true;
DefetShow5.BrushColor = null; DefetShow7.BrushColor = null;
DefetShow5.ImagePath = ""; DefetShow7.ImagePath = "";
mat6.IsEnabledDispose = true; mat3.IsEnabledDispose = true;
DefetShow5.ImaMAt = mat6; DefetShow7.ImaMAt = mat3;
DefetShow5.ImgData = null; DefetShow7.ImgData = null;
DefetShow5.Location = new Point(537, 460); DefetShow7.Location = new Point(1021, 464);
DefetShow5.MoveStep = 5F; DefetShow7.MoveStep = 5F;
DefetShow5.Name = "DefetShow5"; DefetShow7.Name = "DefetShow7";
DefetShow5.Route = 0D; DefetShow7.Route = 0D;
DefetShow5.Scale = 1D; DefetShow7.Scale = 1D;
DefetShow5.Size = new Size(209, 196); DefetShow7.Size = new Size(209, 196);
DefetShow5.TabIndex = 10; DefetShow7.TabIndex = 12;
DefetShow5.WholeScale = 0F; DefetShow7.WholeScale = 0F;
DefetShow5.XMove = 0F; DefetShow7.XMove = 0F;
DefetShow5.XScale = 0F; DefetShow7.XScale = 0F;
DefetShow5.YMove = 0F; DefetShow7.YMove = 0F;
DefetShow5.YScale = 0F; DefetShow7.YScale = 0F;
//
// DefetShow6
//
DefetShow6.AllowSelectDefect = true;
DefetShow6.BrushColor = null;
DefetShow6.ImagePath = "";
mat4.IsEnabledDispose = true;
DefetShow6.ImaMAt = mat4;
DefetShow6.ImgData = null;
DefetShow6.Location = new Point(751, 464);
DefetShow6.MoveStep = 5F;
DefetShow6.Name = "DefetShow6";
DefetShow6.Route = 0D;
DefetShow6.Scale = 1D;
DefetShow6.Size = new Size(209, 196);
DefetShow6.TabIndex = 11;
DefetShow6.WholeScale = 0F;
DefetShow6.XMove = 0F;
DefetShow6.XScale = 0F;
DefetShow6.YMove = 0F;
DefetShow6.YScale = 0F;
// //
// panel8 // panel8
// //
@ -1290,6 +1335,27 @@
InitMachine.UseVisualStyleBackColor = true; InitMachine.UseVisualStyleBackColor = true;
InitMachine.Click += InitMachine_Click; InitMachine.Click += InitMachine_Click;
// //
// DefetShow2
//
DefetShow2.AllowSelectDefect = true;
DefetShow2.BrushColor = null;
DefetShow2.ImagePath = "";
mat5.IsEnabledDispose = true;
DefetShow2.ImaMAt = mat5;
DefetShow2.ImgData = null;
DefetShow2.Location = new Point(850, 249);
DefetShow2.MoveStep = 5F;
DefetShow2.Name = "DefetShow2";
DefetShow2.Route = 0D;
DefetShow2.Scale = 1D;
DefetShow2.Size = new Size(285, 196);
DefetShow2.TabIndex = 9;
DefetShow2.WholeScale = 0F;
DefetShow2.XMove = 0F;
DefetShow2.XScale = 0F;
DefetShow2.YMove = 0F;
DefetShow2.YScale = 0F;
//
// panel6 // panel6
// //
panel6.Controls.Add(groupBox2); panel6.Controls.Add(groupBox2);
@ -1318,6 +1384,27 @@
groupBox2.Text = "图片"; groupBox2.Text = "图片";
groupBox2.Enter += groupBox2_Enter; groupBox2.Enter += groupBox2_Enter;
// //
// DefetShow5
//
DefetShow5.AllowSelectDefect = true;
DefetShow5.BrushColor = null;
DefetShow5.ImagePath = "";
mat6.IsEnabledDispose = true;
DefetShow5.ImaMAt = mat6;
DefetShow5.ImgData = null;
DefetShow5.Location = new Point(537, 460);
DefetShow5.MoveStep = 5F;
DefetShow5.Name = "DefetShow5";
DefetShow5.Route = 0D;
DefetShow5.Scale = 1D;
DefetShow5.Size = new Size(209, 196);
DefetShow5.TabIndex = 10;
DefetShow5.WholeScale = 0F;
DefetShow5.XMove = 0F;
DefetShow5.XScale = 0F;
DefetShow5.YMove = 0F;
DefetShow5.YScale = 0F;
//
// DefetShow4 // DefetShow4
// //
DefetShow4.AllowSelectDefect = true; DefetShow4.AllowSelectDefect = true;
@ -1360,27 +1447,6 @@
DefetShow3.YMove = 0F; DefetShow3.YMove = 0F;
DefetShow3.YScale = 0F; DefetShow3.YScale = 0F;
// //
// DefetShow2
//
DefetShow2.AllowSelectDefect = true;
DefetShow2.BrushColor = null;
DefetShow2.ImagePath = "";
mat5.IsEnabledDispose = true;
DefetShow2.ImaMAt = mat5;
DefetShow2.ImgData = null;
DefetShow2.Location = new Point(850, 249);
DefetShow2.MoveStep = 5F;
DefetShow2.Name = "DefetShow2";
DefetShow2.Route = 0D;
DefetShow2.Scale = 1D;
DefetShow2.Size = new Size(285, 196);
DefetShow2.TabIndex = 9;
DefetShow2.WholeScale = 0F;
DefetShow2.XMove = 0F;
DefetShow2.XScale = 0F;
DefetShow2.YMove = 0F;
DefetShow2.YScale = 0F;
//
// originMat2Show // originMat2Show
// //
originMat2Show.Location = new Point(574, 21); originMat2Show.Location = new Point(574, 21);
@ -1817,48 +1883,6 @@
contextMenuStrip1.Name = "contextMenuStrip1"; contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(61, 4); contextMenuStrip1.Size = new Size(61, 4);
// //
// DefetShow6
//
DefetShow6.AllowSelectDefect = true;
DefetShow6.BrushColor = null;
DefetShow6.ImagePath = "";
mat4.IsEnabledDispose = true;
DefetShow6.ImaMAt = mat4;
DefetShow6.ImgData = null;
DefetShow6.Location = new Point(751, 464);
DefetShow6.MoveStep = 5F;
DefetShow6.Name = "DefetShow6";
DefetShow6.Route = 0D;
DefetShow6.Scale = 1D;
DefetShow6.Size = new Size(209, 196);
DefetShow6.TabIndex = 11;
DefetShow6.WholeScale = 0F;
DefetShow6.XMove = 0F;
DefetShow6.XScale = 0F;
DefetShow6.YMove = 0F;
DefetShow6.YScale = 0F;
//
// DefetShow7
//
DefetShow7.AllowSelectDefect = true;
DefetShow7.BrushColor = null;
DefetShow7.ImagePath = "";
mat3.IsEnabledDispose = true;
DefetShow7.ImaMAt = mat3;
DefetShow7.ImgData = null;
DefetShow7.Location = new Point(1021, 464);
DefetShow7.MoveStep = 5F;
DefetShow7.Name = "DefetShow7";
DefetShow7.Route = 0D;
DefetShow7.Scale = 1D;
DefetShow7.Size = new Size(209, 196);
DefetShow7.TabIndex = 12;
DefetShow7.WholeScale = 0F;
DefetShow7.XMove = 0F;
DefetShow7.XScale = 0F;
DefetShow7.YMove = 0F;
DefetShow7.YScale = 0F;
//
// MainForm // MainForm
// //
AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleDimensions = new SizeF(7F, 17F);
@ -2056,7 +2080,7 @@
private Button openModelBtn; private Button openModelBtn;
private TextBox modelChangeCbx; private TextBox modelChangeCbx;
private Label label34; private Label label34;
private Button button1; private Button HandRuningBtn;
private Label label33; private Label label33;
private CheckBox WhiteBanCbx; private CheckBox WhiteBanCbx;
private XKRS.UI.Canvas DefetShow1; private XKRS.UI.Canvas DefetShow1;
@ -2069,5 +2093,6 @@
private PictureBox originMat2Show; private PictureBox originMat2Show;
private XKRS.UI.Canvas DefetShow7; private XKRS.UI.Canvas DefetShow7;
private XKRS.UI.Canvas DefetShow6; private XKRS.UI.Canvas DefetShow6;
private Button handStopBtn;
} }
} }

View File

@ -6,6 +6,7 @@ using OpenCvSharp.Dnn;
using OpenCvSharp.Extensions; using OpenCvSharp.Extensions;
using OpenCvSharp.XFeatures2D; using OpenCvSharp.XFeatures2D;
using Sunny.UI; using Sunny.UI;
using Sunny.UI.Win32;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -24,6 +25,7 @@ using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using XKRS.Device.SimboVision.SimboHelper; using XKRS.Device.SimboVision.SimboHelper;
using XKRS.UI; using XKRS.UI;
using static HisenceYoloDetection.CheckDiffSciHelper;
using static HisenceYoloDetection.MainForm; using static HisenceYoloDetection.MainForm;
using static System.Runtime.InteropServices.JavaScript.JSType; using static System.Runtime.InteropServices.JavaScript.JSType;
using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
@ -190,13 +192,14 @@ namespace HisenceYoloDetection
private void MainForm_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
string s1 = "0##Ec04060##20<32><30>##Rapide15mns"; string s1 = "gorenjeSTEAMTECHSNOWFLAKEDRUM65kg";
string s2 = "ECO4060##20<32><30>C##Rapide15mns"; string s2 = "STEAMTECHSNOWFLAKEDRUM65kg";
bool st = ManagerModelHelper.StrMatch2(s1, s2); bool st = ManagerModelHelper.StrMatch(s1, s2);
bool st1 = ManagerModelHelper.StrMatch2(s1, s2);
//Rect rect = new Rect(0, 0, 0, 0); //Rect rect = new Rect(0, 0, 0, 0);
// string path2 = "D:\\Hisence\\SQLImages\\BatchW81XBModelWNHA62SASUA\\3\\BatchW81XBModelWNHA62SASUAresult.jpg"; //string path2 = "D:\\Hisence\\SQLImages\\W80WXWJ060539V0WW80WX120293\\2\\W80WXWJ060539V0WW80WX120293result.jpg";
//Mat cameraMat = Cv2.ImRead(path2); //Mat cameraMat = Cv2.ImRead(path2);
//bool ifg = CheckDiffSciHelper.CheckDiffSci(path2, cameraMat, rect, rect, false, "D://Hisence//Test"); //bool ifg = CheckDiffSciHelper.CheckDiffSci(path2, cameraMat, rect, rect, false, "D://Hisence//Test");
@ -274,6 +277,7 @@ namespace HisenceYoloDetection
} }
public void Execute(object source, System.Timers.ElapsedEventArgs e) public void Execute(object source, System.Timers.ElapsedEventArgs e)
{ {
t.Stop(); //<2F>ȹرն<D8B1>ʱ<EFBFBD><CAB1> t.Stop(); //<2F>ȹرն<D8B1>ʱ<EFBFBD><CAB1>
//melsecPLCTCPDriver.WriteInt("548", 1); //melsecPLCTCPDriver.WriteInt("548", 1);
//Thread.Sleep(1000); //Thread.Sleep(1000);
@ -521,6 +525,7 @@ namespace HisenceYoloDetection
// tbFrameRate.Enabled = false; // tbFrameRate.Enabled = false;
bnGetParam.Enabled = false; bnGetParam.Enabled = false;
bnSetParam.Enabled = false; bnSetParam.Enabled = false;
} }
private void button3_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)
{ {
@ -594,10 +599,10 @@ namespace HisenceYoloDetection
melsecPLCTCPDriver.WriteInt("514", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD> melsecPLCTCPDriver.WriteInt("514", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD>
melsecPLCTCPDriver.WriteInt("524", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD> melsecPLCTCPDriver.WriteInt("524", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD>
melsecPLCTCPDriver.WriteInt("406", 60000); //д<><D0B4><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD> melsecPLCTCPDriver.WriteInt("406", 60000); //д<><D0B4><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
melsecPLCTCPDriver.WriteInt("416", 8000); melsecPLCTCPDriver.WriteInt("416", 10000);
melsecPLCTCPDriver.WriteInt("426", 10000); melsecPLCTCPDriver.WriteInt("426", 10000);
melsecPLCTCPDriver.WriteInt("404", 100000); //д<>붨λ<EBB6A8>ٶ<EFBFBD> melsecPLCTCPDriver.WriteInt("404", 100000); //д<>붨λ<EBB6A8>ٶ<EFBFBD>
melsecPLCTCPDriver.WriteInt("414", 8000); melsecPLCTCPDriver.WriteInt("414", 10000);
melsecPLCTCPDriver.WriteInt("424", 10000); melsecPLCTCPDriver.WriteInt("424", 10000);
@ -612,6 +617,7 @@ namespace HisenceYoloDetection
Thread.Sleep(200); Thread.Sleep(200);
melsecPLCTCPDriver.WriteInt("580", 0); melsecPLCTCPDriver.WriteInt("580", 0);
Thread.Sleep(200); Thread.Sleep(200);
melsecPLCTCPDriver.WriteInt("550", 0);
while (true) while (true)
{ {
int IfXZeros = melsecPLCTCPDriver.ReadInt("102"); int IfXZeros = melsecPLCTCPDriver.ReadInt("102");
@ -1037,8 +1043,9 @@ namespace HisenceYoloDetection
// var resultMap = GetResultImage(resultMask, detectionResultShapes); // var resultMap = GetResultImage(resultMask, detectionResultShapes);
} }
#endregion #endregion
int YPos = 8715; int YPos = 14957;
int ZPos = 25000; int ZPos = 4382;
bool StopM = false;//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>źŵ<C5BA>
/// <summary> /// <summary>
/// <20><><EFBFBD><EFBFBD>ϴ<EFBFBD>»<EFBFBD>544<34>Ƿ񴥷<C7B7><F1B4A5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B4AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> /// <20><><EFBFBD><EFBFBD>ϴ<EFBFBD>»<EFBFBD>544<34>Ƿ񴥷<C7B7><F1B4A5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B4AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
/// </summary> /// </summary>
@ -1081,6 +1088,7 @@ namespace HisenceYoloDetection
else else
{ {
iNum1 = 0; iNum1 = 0;
melsecPLCTCPDriver.WriteInt("550", 1);//<2F><><EFBFBD><EFBFBD>
} }
if (iNum1 >= 2) if (iNum1 >= 2)
{ {
@ -1088,9 +1096,16 @@ namespace HisenceYoloDetection
{ {
#if true #if true
if(!StopM)
{
melsecPLCTCPDriver.WriteInt("550", 1);//<2F><><EFBFBD><EFBFBD>
StopM = true;
}
myLog("<22><>һ<EFBFBD>βɼ<CEB2>ͼ<EFBFBD><CDBC>", DateTime.Now); myLog("<22><>һ<EFBFBD>βɼ<CEB2>ͼ<EFBFBD><CDBC>", DateTime.Now);
//<2F>ƶ<EFBFBD>ģ<EFBFBD><C4A3> <20><><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ<EFBFBD>ƶ<EFBFBD> //<2F>ƶ<EFBFBD>ģ<EFBFBD><C4A3> <20><><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ<EFBFBD>ƶ<EFBFBD>
MoveToP(5815, YPos, ZPos); MoveToP(7948, YPos, ZPos);
// Thread.Sleep(2000);//ɾ // Thread.Sleep(2000);//ɾ
@ -1110,7 +1125,7 @@ namespace HisenceYoloDetection
double dismove = disreal - 876; double dismove = disreal - 876;
if (dismove > 0 && dismove < 4000) if (dismove > 0 && dismove < 4000)
{ {
MoveToP(5815, YPos, ZPos + (int)(dismove)); MoveToP(7948, YPos, ZPos + (int)(dismove));
} }
//Thread.Sleep(2000);//ɾ //Thread.Sleep(2000);//ɾ
// Thread.Sleep(500); // Thread.Sleep(500);
@ -1126,9 +1141,12 @@ namespace HisenceYoloDetection
//} //}
//currentXP = 54964; //currentXP = 54964;
//Thread.Sleep(2000);//ɾ //Thread.Sleep(2000);//ɾ
MoveToP(51043, YPos, ZPos + (int)(dismove)); //MoveToP(51043, YPos, ZPos + (int)(dismove));
Cam1.Snapshot(); //Cam1.Snapshot();
MoveToP(5815, YPos, ZPos); MoveToP(7948, YPos, ZPos);
melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
//Thread.Sleep(300);//ϴ<>»<EFBFBD><C2BB><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>ȥ
//if (xKNow != null) //if (xKNow != null)
//{ //{
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ); // MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
@ -1144,7 +1162,7 @@ namespace HisenceYoloDetection
#else #else
myLog("<22><>һ<EFBFBD>βɼ<CEB2>ͼ<EFBFBD><CDBC>", DateTime.Now); myLog("<22><>һ<EFBFBD>βɼ<CEB2>ͼ<EFBFBD><CDBC>", DateTime.Now);
//<2F>ƶ<EFBFBD>ģ<EFBFBD><C4A3> <20><><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ<EFBFBD>ƶ<EFBFBD> //<2F>ƶ<EFBFBD>ģ<EFBFBD><C4A3> <20><><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ<EFBFBD>ƶ<EFBFBD>
//MoveToP(5815, YPos, ZPos); //MoveToP(7948, YPos, ZPos);
Thread.Sleep(1000);//ɾ Thread.Sleep(1000);//ɾ
@ -1164,7 +1182,7 @@ namespace HisenceYoloDetection
//double dismove = disreal - 876; //double dismove = disreal - 876;
//if (dismove > 0 && dismove < 4000) //if (dismove > 0 && dismove < 4000)
//{ //{
// MoveToP(5815, YPos, ZPos + (int)(dismove)); // MoveToP(7948, YPos, ZPos + (int)(dismove));
//} //}
Thread.Sleep(1000);//ɾ Thread.Sleep(1000);//ɾ
// Thread.Sleep(500); // Thread.Sleep(500);
@ -1184,7 +1202,7 @@ namespace HisenceYoloDetection
//MoveToP(51043, YPos, ZPos + (int)(dismove)); //MoveToP(51043, YPos, ZPos + (int)(dismove));
Cam1.Snapshot(); Cam1.Snapshot();
//MoveToP(5815, YPos, ZPos); //MoveToP(7948, YPos, ZPos);
//if (xKNow != null) //if (xKNow != null)
//{ //{
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ); // MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
@ -1342,7 +1360,7 @@ namespace HisenceYoloDetection
sw.WriteLine(IOcrBAr + "\n"); sw.WriteLine(IOcrBAr + "\n");
sw.Flush(); sw.Flush();
} }
IOcrBAr = "W821PWMS27106WD2"; IOcrBAr = "BatchW96DHModelWF3S7021BWPl";
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ȶ<EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ȶ<EFBFBD>
xKNow = GetModeFromBar(IOcrBAr);//<2F><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>в<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ xKNow = GetModeFromBar(IOcrBAr);//<2F><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>в<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr); List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
@ -1433,6 +1451,12 @@ namespace HisenceYoloDetection
ResultMatShow.Image = mL.ResultMap; ResultMatShow.Image = mL.ResultMap;
} }
else
{
Mat res_yolo = Cv2.ImRead("ng.jpg");
ResultMatShow.Image = res_yolo.ToBitmap();
}//<2F>޷<EFBFBD><DEB7>򶨵<EFBFBD><F2B6A8B5><EFBFBD>ͼƬ<CDBC><C6AC>˸<EFBFBD><CBB8><EFBFBD><EFBFBD>else<73>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MLRequest req2 = new MLRequest(); MLRequest req2 = new MLRequest();
req2.currentMat = Cam1ImgTwo; req2.currentMat = Cam1ImgTwo;
@ -1503,7 +1527,7 @@ namespace HisenceYoloDetection
bBarTriger = false; bBarTriger = false;
melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
if (MatchStr) if (MatchStr)
{ {
OKDsums++; OKDsums++;
@ -1795,6 +1819,24 @@ namespace HisenceYoloDetection
private void StartDecBtn_Click(object sender, EventArgs e) private void StartDecBtn_Click(object sender, EventArgs e)
{ {
/*
string path22 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628924614_Rect.png";
Mat pathmat2 = Cv2.ImRead(path22);
string path222 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628923102_Rect.png";
Rect rect1 = new Rect(1929, 745, 396, 377);
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(); //OnGetBar();
TriggerCameral2(); TriggerCameral2();
ReadyDetect(); ReadyDetect();
@ -2777,6 +2819,7 @@ namespace HisenceYoloDetection
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay; string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight); Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
Mat matCut = new Mat(mResultCuti, area); Mat matCut = new Mat(mResultCuti, area);
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Start(); sw.Start();
//OCRʶ<52><CAB6><EFBFBD>ü<EFBFBD>ͼƬ //OCRʶ<52><CAB6><EFBFBD>ü<EFBFBD>ͼƬ
@ -2858,6 +2901,7 @@ namespace HisenceYoloDetection
string TextWoidStr = OcrFuzzyTextInsert.Join("##"); //ʵ<>ʵļ<CAB5><C4BC><EFBFBD><EFBFBD><EFBFBD> string TextWoidStr = OcrFuzzyTextInsert.Join("##"); //ʵ<>ʵļ<CAB5><C4BC><EFBFBD><EFBFBD><EFBFBD>
string SQLStr = "";//<2F><>־<EFBFBD><D6BE>ʾ<EFBFBD><CABE><EFBFBD>ݿ<EFBFBD><DDBF>Ĺؼ<C4B9><D8BC><EFBFBD> string SQLStr = "";//<2F><>־<EFBFBD><D6BE>ʾ<EFBFBD><CABE><EFBFBD>ݿ<EFBFBD><DDBF>Ĺؼ<C4B9><D8BC><EFBFBD>
bool juanjiMatch = false; bool juanjiMatch = false;
string filenameone = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
switch (blockIndex) switch (blockIndex)
{ {
case "1"://<2F><>ȫƥ<C8AB><C6A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ case "1"://<2F><>ȫƥ<C8AB><C6A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
@ -2865,19 +2909,31 @@ namespace HisenceYoloDetection
xK_HisenceWord.OneblockPath = CutSavePath; xK_HisenceWord.OneblockPath = CutSavePath;
xK_HisenceWord.OneblockMainWord = MainWoidStr; xK_HisenceWord.OneblockMainWord = MainWoidStr;
xK_HisenceWord.OneblockText = TextWoidStr; xK_HisenceWord.OneblockText = TextWoidStr;
SQLStr = SQlxK_HisenceWord.OneblockMainWord; SQLStr = SQlxK_HisenceWord.OneblockText;
string SQLStr2 = SQlxK_HisenceWord.OneblockMainWord;
if (!saveimage) if (!saveimage)
{ {
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.OneblockMainWord, SQLStr); bool ssD = ManagerModelHelper.StrMatch(SQLStr, xK_HisenceWord.OneblockText);
if (!OneIF) Console.Write(SQLStr);
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.OneblockMainWord, SQLStr2);
if (!OneIF1 || !ssD)
{ {
OneIF = false;
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
DisplayResult(mLcut); DisplayResult(mLcut);
Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 1); Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 1);
string Path_1 = Path.Combine("D:\\Hisence\\Test\\1\\ng", filenameone + "_res.png");
Cv2.ImWrite(Path_1, mLcut.ResultMap.ToMat());
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 1); Defet_OnDetectionDone(OKMat, 1);
string Path_2 = Path.Combine("D:\\Hisence\\Test\\1\\ok", filenameone + "_res.png");
Cv2.ImWrite(Path_2, OKMat);
} }
} }
@ -2927,16 +2983,26 @@ namespace HisenceYoloDetection
if (!saveimage) if (!saveimage)
{ {
SQLStr = SQlxK_HisenceWord.ThreeblockMainWord; SQLStr = SQlxK_HisenceWord.ThreeblockMainWord;
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.ThreeblockMainWord, SQlxK_HisenceWord.ThreeblockMainWord); bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.ThreeblockMainWord, SQlxK_HisenceWord.ThreeblockMainWord);
if (!OneIF)
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.ThreeblockPath;
juanjiMatch = CheckDiffSciHelper1.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test1");
if (!OneIF1 || !juanjiMatch)
{ {
OneIF = true;//<2F><><EFBFBD>޸<EFBFBD>6.28
/*
DisplayResult(mLcut); DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap; // mLcut.ResultMap;
Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 3); Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 3);
*/
Defet_OnDetectionDone(OKMat, 3);
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 3); Defet_OnDetectionDone(OKMat, 3);
} }
@ -2951,9 +3017,15 @@ namespace HisenceYoloDetection
if (!saveimage) if (!saveimage)
{ {
SQLStr = SQlxK_HisenceWord.FourblockMainWord; SQLStr = SQlxK_HisenceWord.FourblockMainWord;
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.FourblockMainWord, SQlxK_HisenceWord.FourblockMainWord); bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FourblockMainWord, SQlxK_HisenceWord.FourblockMainWord);
if (!OneIF)
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.FourblockPath;
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{ {
OneIF = false;
DisplayResult(mLcut); DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap; // mLcut.ResultMap;
@ -2961,6 +3033,7 @@ namespace HisenceYoloDetection
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 4); Defet_OnDetectionDone(OKMat, 4);
} }
@ -2975,9 +3048,14 @@ namespace HisenceYoloDetection
if (!saveimage) if (!saveimage)
{ {
SQLStr = SQlxK_HisenceWord.FiveblockMainWord; SQLStr = SQlxK_HisenceWord.FiveblockMainWord;
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.FiveblockMainWord, SQlxK_HisenceWord.FiveblockMainWord); bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FiveblockMainWord, SQlxK_HisenceWord.FiveblockMainWord);
if (!OneIF) Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.FiveblockMainWord;
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{ {
OneIF = false;
DisplayResult(mLcut); DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap; // mLcut.ResultMap;
@ -2985,6 +3063,7 @@ namespace HisenceYoloDetection
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 5); Defet_OnDetectionDone(OKMat, 5);
} }
} }
@ -2998,9 +3077,16 @@ namespace HisenceYoloDetection
if (!saveimage) if (!saveimage)
{ {
SQLStr = SQlxK_HisenceWord.SixblockMainWord; SQLStr = SQlxK_HisenceWord.SixblockMainWord;
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord); bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord);
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.SixblockPath;
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
if (!OneIF) if (!OneIF)
{ {
OneIF = false;
// DisplayResult(mLcut); // DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap; // mLcut.ResultMap;
@ -3008,6 +3094,7 @@ namespace HisenceYoloDetection
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 6); Defet_OnDetectionDone(OKMat, 6);
} }
@ -3022,9 +3109,14 @@ namespace HisenceYoloDetection
if (!saveimage) if (!saveimage)
{ {
SQLStr = SQlxK_HisenceWord.SevenblockMainWord; SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord); bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
if (!OneIF) Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.SevenblockPath;
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{ {
OneIF = false;
//DisplayResult(mLcut); //DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap; // mLcut.ResultMap;
@ -3032,6 +3124,7 @@ namespace HisenceYoloDetection
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 7); Defet_OnDetectionDone(OKMat, 7);
} }
} }
@ -3045,9 +3138,14 @@ namespace HisenceYoloDetection
if (!saveimage) if (!saveimage)
{ {
SQLStr = SQlxK_HisenceWord.EightblockMainWord; SQLStr = SQlxK_HisenceWord.EightblockMainWord;
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.EightblockMainWord, SQlxK_HisenceWord.EightblockMainWord); bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.EightblockMainWord, SQlxK_HisenceWord.EightblockMainWord);
if (!OneIF) Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.EightblockPath;
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{ {
OneIF = false;
// DisplayResult(mLcut); // DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD> //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap; // mLcut.ResultMap;
@ -3055,6 +3153,7 @@ namespace HisenceYoloDetection
} }
else else
{ {
OneIF = true;
Defet_OnDetectionDone(OKMat, 8); Defet_OnDetectionDone(OKMat, 8);
} }
} }
@ -3067,10 +3166,7 @@ namespace HisenceYoloDetection
using (StreamWriter sw = new StreamWriter(txtLog, true)) using (StreamWriter sw = new StreamWriter(txtLog, true))
{ {
if (blockIndex == "2") sw.WriteLine("<22><>" + blockIndex + "<22><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>" + juanjiMatch);
{
sw.WriteLine("<22><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>" + juanjiMatch);
}
sw.WriteLine("<22><>" + blockIndex + "<22><><EFBFBD>ݿ<EFBFBD>" + SQLStr + "<22>ؼ<EFBFBD><D8BC><EFBFBD>" + MainWoidStr + "<22><><EFBFBD><EFBFBD>" + OneIF + "\n"); sw.WriteLine("<22><>" + blockIndex + "<22><><EFBFBD>ݿ<EFBFBD>" + SQLStr + "<22>ؼ<EFBFBD><D8BC><EFBFBD>" + MainWoidStr + "<22><><EFBFBD><EFBFBD>" + OneIF + "\n");
sw.WriteLine("<22><>" + blockIndex + " <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + TextWoidStr + "\n"); sw.WriteLine("<22><>" + blockIndex + " <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + TextWoidStr + "\n");
@ -3122,5 +3218,15 @@ namespace HisenceYoloDetection
myLog("X<><58>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now); myLog("X<><58>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
} }
} }
private void handStopBtn_Click(object sender, EventArgs e)
{
melsecPLCTCPDriver.WriteInt("550", 1);
}
private void HandRuningBtn_Click(object sender, EventArgs e)
{
melsecPLCTCPDriver.WriteInt("550", 0);
}
} }
} }

View File

@ -142,7 +142,7 @@
<value>733, 17</value> <value>733, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>34</value> <value>25</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <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"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

View File

@ -189,7 +189,7 @@ namespace HisenceYoloDetection
// 计算相似度相似度等于1减去标准化的Levenshtein距离 // 计算相似度相似度等于1减去标准化的Levenshtein距离
double similarity = 1 - ((double)distance / Math.Max(SqlText.Length, DetText.Length)); double similarity = 1 - ((double)distance / Math.Max(SqlText.Length, DetText.Length));
bool areEqual = false; bool areEqual = false;
if (similarity < 0.5) if (similarity < 0.9)
{ {
areEqual = false; areEqual = false;
} }