4 Commits

Author SHA1 Message Date
48e6945bd6 修改卷积 2024-06-28 09:15:00 +08:00
3f9d951e80 修改 2024-06-27 18:02:33 +08:00
00f4b9c95d 修改所有区域卷积 2024-06-27 17:54:35 +08:00
0ed659e482 no message 2024-06-27 16:51:09 +08:00
9 changed files with 780 additions and 1175 deletions

View File

@ -6,7 +6,6 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using Point = OpenCvSharp.Point;
using Size = OpenCvSharp.Size;
@ -14,7 +13,7 @@ using Size = OpenCvSharp.Size;
namespace HisenceYoloDetection
{
public static class CheckDiffSciHelper
public static class CheckDiffSciHelper
{
/// <summary>
///
@ -25,7 +24,7 @@ namespace HisenceYoloDetection
/// <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())
{
@ -69,13 +68,11 @@ namespace HisenceYoloDetection
{
Cv2.Threshold(gimg2, thr2, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu);
}
//Rect area2 = new Rect(148,30,229,222);
sqlrect.Width += 20;
sqlrect.Height += 60;
detrect.Width += 20;
detrect.Height += 60;
Mat matCutblack1 = new Mat(thr1, sqlrect);
if (IfWhiteWord)
{
@ -96,17 +93,17 @@ namespace HisenceYoloDetection
}
Cv2.Resize(thr1, thr1, 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 savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr1.png");
//// 保存结果
string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr1.png");
// 保存结果
//Cv2.ImWrite(savePath4, thr1);
//string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr2.png");
//// 保存结果
Cv2.ImWrite(savePath4, thr1);
string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr2.png");
// 保存结果
//Cv2.ImWrite(savePath3, thr2);
Cv2.ImWrite(savePath3, thr2);
// 创建卷积核
Mat filter1 = new Mat(15, 15, MatType.CV_32F, new Scalar(0));
@ -146,17 +143,10 @@ namespace HisenceYoloDetection
Mat devIMG_ = new Mat();
Cv2.Subtract(final_result1, final_result2, devIMG);
Cv2.Subtract(final_result2, final_result1, devIMG_);
//string savePathd = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "devIMG.png");
//// 保存结果
//Cv2.ImWrite(savePathd, devIMG);
//string savePathd1 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "devIMG_.png");
//// 保存结果
//Cv2.ImWrite(savePathd1, devIMG_);
// 对差异图像应用阈值
Cv2.Threshold(devIMG, devIMG, 20, 255, ThresholdTypes.Binary);
Cv2.Threshold(devIMG_, devIMG_, 20, 255, ThresholdTypes.Binary);
Cv2.Threshold(devIMG, devIMG, 50, 255, ThresholdTypes.Binary);
Cv2.Threshold(devIMG_, devIMG_, 50, 255, ThresholdTypes.Binary);
// 结合差异
Mat sumIMG = new Mat();
@ -173,41 +163,32 @@ namespace HisenceYoloDetection
bool isMatch = true;
foreach (var contour in contours)
{
if (Cv2.ContourArea(contour) <= 500)
if (Cv2.ContourArea(contour) <= 100)
{
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);
}
}
string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_Rect.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2);
string savePath = Path.Combine(saveDir, 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))
@ -220,15 +201,14 @@ namespace HisenceYoloDetection
Rect rect = new Rect(areaX, areaY, areaWidth, areaHeight);
return rect;
}
else
}else
{
return new Rect(0, 0, 0, 0);
return new Rect(0,0,0, 0);
}
}
public static string rectChangeStr(Rect area)
public static string rectChangeStr(Rect area)
{
string[] rectsql = new string[4];
rectsql[0] = Convert.ToString(area.X);
@ -239,198 +219,123 @@ namespace HisenceYoloDetection
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();
//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, 100, 255, ThresholdTypes.Binary );//| ThresholdTypes.Otsu
}
// 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);
// 读取和处理第二张图片
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
}
// 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));
//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();
// // 应用卷积
// 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);
//string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr1.png");
//// 保存结果
// 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.ImWrite(savePath4, thr1);
//string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_thr2.png");
//// 保存结果
// // 计算图像差异
// Mat devIMG = new Mat();
// Mat devIMG_ = new Mat();
// Cv2.Subtract(final_result1, final_result2, devIMG);
// Cv2.Subtract(final_result2, final_result1, devIMG_);
//Cv2.ImWrite(savePath3, thr2);
// // 对差异图像应用阈值
// Cv2.Threshold(devIMG, devIMG, 50, 255, ThresholdTypes.Binary);
// Cv2.Threshold(devIMG_, devIMG_, 50, 255, ThresholdTypes.Binary);
// 创建卷积核
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 sumIMG = new Mat();
// Cv2.Add(devIMG, devIMG_, sumIMG);
// 应用卷积
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 kernelCL = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(3, 3));
// Mat blackhatImg = new Mat();
// Cv2.Dilate(sumIMG, blackhatImg, kernelCL);
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);
//裁剪才行
// // 处理轮廓和保存结果
// 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);
// // 框选轮廓
//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][];
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) + filename + "_Rect.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath2, img2);
string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename + "_diff.png");
// 保存结果
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
Cv2.ImWrite(savePath, blackhatImg);
return isMatch;
}
}
// }
// 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

@ -12,7 +12,6 @@
</PropertyGroup>
<ItemGroup>
<None Remove="MainForm.resx~RF4efdcc4.TMP" />
<None Remove="ManagerModelHelper.cs~RF97ff9f.TMP" />
<None Remove="MelsecPLCTCPDriver.cs~RFacf25a.TMP" />
</ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@ using OpenCvSharp.Dnn;
using OpenCvSharp.Extensions;
using OpenCvSharp.XFeatures2D;
using Sunny.UI;
using Sunny.UI.Win32;
using System;
using System.ComponentModel;
using System.Data;
@ -22,11 +21,9 @@ using System.Net;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using XKRS.Device.SimboVision.SimboHelper;
using XKRS.UI;
using static HisenceYoloDetection.CheckDiffSciHelper;
using static HisenceYoloDetection.MainForm;
using static System.Runtime.InteropServices.JavaScript.JSType;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
@ -65,9 +62,6 @@ namespace HisenceYoloDetection
List<XKHisence> xKHisences = new List<XKHisence>();
static AutoResetEvent myResetEvent = new AutoResetEvent(false);
AutoResetEvent _runHandleBefore = new AutoResetEvent(false);
ManualResetEvent _runHandleAfter = new ManualResetEvent(false);
bool PLC545 = false;
bool PLC548 = false;
@ -107,11 +101,7 @@ namespace HisenceYoloDetection
string Cam1OnePath = "";
string Cam1TwoPath = "";
string ModelChangePath = "";
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string GreenLightingAdress = "";
string YellowLightingAdress = "";
string RedLightingAdress = "";
string WaringAdress = "";
/// <summary>
/// <20><EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
/// </summary>
@ -199,30 +189,17 @@ namespace HisenceYoloDetection
/// <param name="e"></param>
private void MainForm_Load(object sender, EventArgs e)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
if (_runHandleBefore == null)
{
_runHandleBefore = new AutoResetEvent(false);
}
string s1 = "0##Ec04060##20<32><30>##Rapide15mns";
string s2 = "ECO4060##20<32><30>C##Rapide15mns";
if (_runHandleAfter == null)
{
_runHandleAfter = new ManualResetEvent(false);
}
bool st = ManagerModelHelper.StrMatch2(s1, s2);
string s1 = "gorenjeSTEAMTECHSNOWFLAKEDRUM65kg";
string s2 = "STEAMTECHSNOWFLAKEDRUM65kg";
bool st = ManagerModelHelper.StrMatch(s1, s2);
bool st1 = ManagerModelHelper.StrMatch2(s1, s2);
//Rect rect = new Rect(0, 0, 0, 0);
//string path2 = "D:\\Hisence\\SQLImages\\W80WXWJ060539V0WW80WX120293\\2\\W80WXWJ060539V0WW80WX120293result.jpg";
//Mat cameraMat = Cv2.ImRead(path2);
//bool ifg = CheckDiffSciHelper.CheckDiffSci(path2, cameraMat, rect, rect, false, "D://Hisence//Test");
Rect rect = new Rect(0, 0, 0, 0);
string path2 = "D:\\Hisence\\SQLImages\\LR1006G4SILVERWJ060480U0SW901N120105\\4\\LR1006G4SILVERWJ060480U0SW901N120105result.jpg";
string path23 = "D:\\Hisence\\SQLImages\\LR1006G4SILVERWJ060480U0SW901N120105\\4\\L1.jpg";
Mat cameraMat = Cv2.ImRead(path23);
bool ifg = CheckDiffSciHelper.CheckDiffSci(path2, cameraMat, rect, rect, false, "D://Hisence//Test");
string vBarPath = "D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\Lp\\202452414231.jpg";
string vCam1OnePath = "D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\Lp\\001.jpg";
@ -289,8 +266,6 @@ namespace HisenceYoloDetection
OnSpeedShow();//<2F>߳̿<DFB3><CCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>ʾ<EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>
OnPostionShow();//<2F>߳̿<DFB3><CCBF><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ʾ<EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//<2F>Ƶ<EFBFBD>
//t = new System.Timers.Timer(10000);//ʵ<><CAB5><EFBFBD><EFBFBD>Timer<65><EFBFBD><E0A3AC><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ʱ<EFBFBD><CAB1>Ϊ10000<30><30><EFBFBD>
//t.Elapsed += new System.Timers.ElapsedEventHandler(Execute);//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ִ<EFBFBD><D6B4><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
//t.AutoReset = true;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>һ<EFBFBD>Σ<EFBFBD>false<73><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һֱִ<D6B1><D6B4>(true)<29><>
@ -300,7 +275,6 @@ namespace HisenceYoloDetection
}
public void Execute(object source, System.Timers.ElapsedEventArgs e)
{
t.Stop(); //<2F>ȹرն<D8B1>ʱ<EFBFBD><CAB1>
//melsecPLCTCPDriver.WriteInt("548", 1);
//Thread.Sleep(1000);
@ -548,7 +522,6 @@ namespace HisenceYoloDetection
// tbFrameRate.Enabled = false;
bnGetParam.Enabled = false;
bnSetParam.Enabled = false;
}
private void button3_Click(object sender, EventArgs e)
{
@ -615,17 +588,17 @@ namespace HisenceYoloDetection
//Scanner.OnClientDataReceived += OnDataReceived;
//Scanner.btnSendMsg("LON\r");//<2F><><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD>ָ<EFBFBD><D6B8>
//myLog("<22><><EFBFBD>Ͷ<EFBFBD>ʿɨ<CABF><C9A8>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>", DateTime.Now);
//PLCʹ<43>ܿ<EFBFBD><DCBF><EFBFBD>
melsecPLCTCPDriver.WriteInt("581", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD>
melsecPLCTCPDriver.WriteInt("504", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD>
melsecPLCTCPDriver.WriteInt("514", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD>
melsecPLCTCPDriver.WriteInt("524", 0);//<2F><>λ<EFBFBD>ɿ<EFBFBD>
melsecPLCTCPDriver.WriteInt("406", 60000); //д<><D0B4><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
melsecPLCTCPDriver.WriteInt("416", 10000);
melsecPLCTCPDriver.WriteInt("416", 8000);
melsecPLCTCPDriver.WriteInt("426", 10000);
melsecPLCTCPDriver.WriteInt("404", 100000); //д<>붨λ<EBB6A8>ٶ<EFBFBD>
melsecPLCTCPDriver.WriteInt("414", 10000);
melsecPLCTCPDriver.WriteInt("414", 8000);
melsecPLCTCPDriver.WriteInt("424", 10000);
@ -640,7 +613,6 @@ namespace HisenceYoloDetection
Thread.Sleep(200);
melsecPLCTCPDriver.WriteInt("580", 0);
Thread.Sleep(200);
melsecPLCTCPDriver.WriteInt("550", 0);
while (true)
{
int IfXZeros = melsecPLCTCPDriver.ReadInt("102");
@ -1006,12 +978,11 @@ namespace HisenceYoloDetection
}
if (iNum1 >= 2)
{
if (bBar)
{
_runHandleBefore.WaitOne();
bBarTriger = true;//<2F>޸ij<DEB8><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>ȡ<EFBFBD>ͺ<EFBFBD>
Cam2.SnapshotCount = 0;
Cam2.Snapshot();
xKNow = GetModeFromBar("VWJ070633V0WW80F0120356");//<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(m_sKEYENCEBar);//<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>ֵ
@ -1069,7 +1040,6 @@ namespace HisenceYoloDetection
#endregion
int YPos = 8715;
int ZPos = 25000;
bool StopM = false;//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>źŵ<C5BA>
/// <summary>
/// <20><><EFBFBD><EFBFBD>ϴ<EFBFBD>»<EFBFBD>544<34>Ƿ񴥷<C7B7><F1B4A5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B4AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
/// </summary>
@ -1112,21 +1082,13 @@ namespace HisenceYoloDetection
else
{
iNum1 = 0;
melsecPLCTCPDriver.WriteInt("550", 1);//<2F><><EFBFBD><EFBFBD>
}
if (iNum1 >= 2)
{
//if (bBarTriger)
{
#if false
if (!StopM)
{
melsecPLCTCPDriver.WriteInt("550", 1);//<2F><><EFBFBD><EFBFBD>
StopM = true;
}
#if true
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>
MoveToP(5815, YPos, ZPos);
@ -1147,7 +1109,7 @@ namespace HisenceYoloDetection
double disreal = average * (-0.54054) + 1324.3232;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><>ƶ<EFBFBD><C6B6>ľ<EFBFBD><C4BE><EFBFBD>
double dismove = disreal - 876;
if (dismove > -4000 && dismove < 4000)
if (dismove > 0 && dismove < 4000)
{
MoveToP(5815, YPos, ZPos + (int)(dismove));
}
@ -1155,22 +1117,19 @@ namespace HisenceYoloDetection
// Thread.Sleep(500);
Cam1.SnapshotCount = 0;
Cam1.Snapshot();
Cam2.SnapshotCount = 0;
Cam2.Snapshot();
myLog("<22>ڶ<EFBFBD><DAB6>βɼ<CEB2>ͼ<EFBFBD><CDBC>", DateTime.Now);
//if (xKNow != null)
//{
// MoveToP(xKNow.MoveTwoX, xKNow.MoveTwoY, xKNow.MoveTwoZ);
//}
//currentXP = 54964;
//Thread.Sleep(2000);//ɾ
MoveToP(51043, YPos, ZPos + (int)(dismove));
Cam1.Snapshot();
MoveToP(5815, YPos, ZPos);
melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
//Thread.Sleep(300);//ϴ<>»<EFBFBD><C2BB><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>ȥ
//if (xKNow != null)
//{
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
@ -1301,8 +1260,8 @@ namespace HisenceYoloDetection
{
Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\1\\001.jpg"); ;
//Cam1ImgOne = cameraMat;
//Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\1\\001.jpg"); ;
Cam1ImgOne = cameraMat;
IfCam1OneTriger = true;
originMatShow.Image = cameraMat.ToBitmap();
//pictureBox1.Image = cameraMat.ToBitmap();
@ -1312,13 +1271,13 @@ namespace HisenceYoloDetection
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (SnapshotCount == 2)
{
Cam1ImgTwo = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\1\\002.jpg");
//Cam1ImgTwo = cameraMat;
// Mat mat = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\1\\002.jpg");
// Cam1ImgTwo = mat;
Cam1ImgTwo = cameraMat;
IfCam1TwoTriger = true;
originMatShow2.Image = cameraMat.ToBitmap();
_runHandleAfter.Set();
}
@ -1344,9 +1303,8 @@ namespace HisenceYoloDetection
// Mat mat = Cv2.ImRead("F:\\<5C><><EFBFBD><EFBFBD>ϴ<EFBFBD>»<EFBFBD>\\cam1\\2024517161641.jpg");
Cam2ImgShowBar = cameraMat;
IfCam2Triger = true;
originMat2Show.Image = cameraMat.ToBitmap();
//_runHandleAfter.Set();
// CamShow2.ImaMAt = cameraMat;
cameraMat.ImWrite(fitImageFolder + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1.jpg");
@ -1354,7 +1312,6 @@ namespace HisenceYoloDetection
public volatile int AllDsums = 0;
public volatile int NGDsums = 0;
public volatile int OKDsums = 0;
public volatile int WUsums = 0;
/// <summary>
/// <20><>ʼʶ<CABC><CAB6>
/// </summary>
@ -1367,8 +1324,6 @@ namespace HisenceYoloDetection
{
try
{
//<2F>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʹ<><EFBFBD><E4B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD>˸
_runHandleAfter.WaitOne();
//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (IfCam2Triger)
{
@ -1388,7 +1343,6 @@ namespace HisenceYoloDetection
sw.WriteLine(IOcrBAr + "\n");
sw.Flush();
}
// IOcrBAr = "BatchW9659ModelWNHPI74SCPSDE";
IOcrBAr = "W821PWMS27106WD2";
//<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>ֵ
@ -1434,11 +1388,8 @@ namespace HisenceYoloDetection
}
//<2F><><EFBFBD><EFBFBD>1<EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// if (IfCam1TwoTriger && bBarTriger)
if (IfCam1TwoTriger && bBarTriger)
{
IfCam1TwoTriger = false;
bBarTriger = false;
_runHandleAfter.Reset();
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
Defet_OnDetectionDone(whiteMat, 1);
Defet_OnDetectionDone(whiteMat, 2);
@ -1447,7 +1398,8 @@ namespace HisenceYoloDetection
Defet_OnDetectionDone(whiteMat, 5);
Defet_OnDetectionDone(whiteMat, 6);
Defet_OnDetectionDone(whiteMat, 7);
XK_HisenceWord xK_MatchDet = new XK_HisenceWord();
xK_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
AllDsums++;
@ -1469,14 +1421,19 @@ namespace HisenceYoloDetection
List<string> strMatListOne = new List<string>();
List<string> strMatFuzzyListOne = new List<string>();
Mat mResultCut = req.currentMat.Clone();
Mat mCut = new Mat();
Stopwatch sw = new Stopwatch();
sw.Start();
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
InsertSqlRunDataButton(ref keyValueResult, false, ref mCut, ref mResultCut, mL, mLButton, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
sw.Stop();
myLog("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>" + sw.ElapsedMilliseconds, DateTime.Now);
if (mL.ResultMap != null)
{
mL.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
ResultMatShow.Image = mL.ResultMap;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MLRequest req2 = new MLRequest();
req2.currentMat = Cam1ImgTwo;
@ -1488,18 +1445,18 @@ namespace HisenceYoloDetection
req2.iouThreshold = 0.4f;//<2F><><EFBFBD><EFBFBD>IOU
req2.out_node_name = "output";
MLResult mL2 = simboObjectDetection.RunInferenceFixed(req2);
List<string> strMatListTwo = new List<string>();
List<string> strMatFuzzyListTwo = new List<string>();
Mat mResultCut2 = req2.currentMat.Clone();
Dictionary<string, bool> keyValueResult2 = new Dictionary<string, bool>();
InsertSqlRunData(ref keyValueResult2, false, ref mResultCut2, mL2, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
if (mL2.ResultMap != null)
{
mL2.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
ResultMatShow2.Image = mL2.ResultMap;
}
List<string> strMatListTwo = new List<string>();
List<string> strMatFuzzyListTwo = new List<string>();
Mat mResultCut2 = req2.currentMat.Clone();
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
Dictionary<string, bool> keyValueResult2 = new Dictionary<string, bool>();
#region <EFBFBD><EFBFBD>ִ<EFBFBD>ж<EFBFBD>λ<EFBFBD>ȶ<EFBFBD>
//ִ<>ж<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string[] listLabels = xKNow.Detect.Split(",");
@ -1527,25 +1484,6 @@ namespace HisenceYoloDetection
HashSet<string> set1 = new HashSet<string>(listLabels);
HashSet<string> set2 = new HashSet<string>(RealLabels);
bool MatchStr = set1.SetEquals(set2);
#endregion
//<2F><><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>ȶ<EFBFBD>
if (MatchStr)
{
//Mat mCut = new Mat();
Stopwatch sw = new Stopwatch();
sw.Start();
InsertSqlRunDataButton(ref keyValueResult, false, ref mResultCut, mL, mLButton, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
InsertSqlRunData(ref keyValueResult2, false, ref mResultCut2, mL2, ref xK_HisenceSQLWord, ref xK_MatchDet, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
sw.Stop();
myLog("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>" + sw.ElapsedMilliseconds, DateTime.Now);
}
if (MatchStr)
{
@ -1562,9 +1500,11 @@ namespace HisenceYoloDetection
// int sqlblocksum=
IfCam1TwoTriger = false;
bBarTriger = false;
melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
if (MatchStr)
{
OKDsums++;
@ -1580,39 +1520,14 @@ namespace HisenceYoloDetection
}
else
{
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 1);//<2F><><EFBFBD><EFBFBD>
melsecPLCTCPDriver.WriteInt(WaringAdress, 1);//<2F><><EFBFBD><EFBFBD>
NGDsums++;
myLog(<><C6A5>ʧ<EFBFBD><CAA7>", DateTime.Now);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>NGϴ<EFBFBD>»<EFBFBD>
DialogResult dr = MessageBox.Show("<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>죿", "<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
// InsertXK_HisenceWordMatchData(xK_MatchDet, false);
this.Invoke(new Action(() =>
{
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//<2F><><EFBFBD><EFBFBD>
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//<2F><><EFBFBD><EFBFBD>
OKDsums++;
WUsums++;
this.Invoke(new Action(() =>
{
double percent = (double)WUsums/ AllDsums;
string percentText = percent.ToString("0.0%");//<2F><><EFBFBD><EFBFBD>percentText<78><74>ֵΪ10.0%
textBox1.Text = percentText;
OKOrNGShow.Image = OKbitmap;
}));
}
else
{
NGDsums++;
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//<2F><><EFBFBD><EFBFBD>
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//<2F><><EFBFBD><EFBFBD>
this.Invoke(new Action(() =>
{
OKOrNGShow.Image = NGbitmap;
}));
}
OKOrNGShow.Image = NGbitmap;
}));
}
@ -1621,7 +1536,7 @@ namespace HisenceYoloDetection
}
catch (Exception e)
{
throw e;
}
finally
{
@ -1701,7 +1616,7 @@ namespace HisenceYoloDetection
{
m_sKEYENCEBar = System.Text.Encoding.UTF8.GetString(data);
// myLog("<22>ͺ<EFBFBD>Ocr" + m_sKEYENCEBar, DateTime.Now);
_runHandleBefore.Set();
bBar = true;
}
@ -1881,26 +1796,7 @@ namespace HisenceYoloDetection
private void StartDecBtn_Click(object sender, EventArgs e)
{
/*
string path22 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628924614_Rect.png";
Mat pathmat2 = Cv2.ImRead(path22);
string path222 = "D:\\Hisence\\Test2\\BatchW96c0ModelWNHB6X2SDSPresult2024628923102_Rect.png";
Rect rect1 = new Rect(1929, 745, 396, 377);
Rect rect = new Rect(368, 53, 396, 377);
CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect, rect, true, "D://Hisence//Test2");
string path = "D:\\Hisence\\Test1\\1.png";
Mat pathmat =Cv2.ImRead(path);
string path2 = "D:\\Hisence\\Test1\\2.png";
Rect rect2 = new Rect(0, 0, 0, 0);
CheckDiffSciHelper1.CheckDiffSci(path2, pathmat, rect2, rect2, false, "D://Hisence//Test1");
*/
//OnGetBar();
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//<2F>Ƶ<EFBFBD>
TriggerCameral2();
ReadyDetect();
myLog("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳ɹ<CCB3>", DateTime.Now);
@ -2298,9 +2194,9 @@ namespace HisenceYoloDetection
List<string> strMatListOne = new List<string>();
List<string> strMatFuzzyListOne = new List<string>();
Mat mResultCut = CamOneI.currentMat.Clone();
//Mat mCut = new Mat();
Mat mCut = new Mat();
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
InsertSqlRunDataButton(ref keyValueResult, true, ref mCut, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
@ -2704,37 +2600,37 @@ namespace HisenceYoloDetection
{
case 1:
{
canvas1.ImaMAt = detectionImage;
DefetShow1.ImaMAt = detectionImage;
}
break;
case 2:
{
canvas2.ImaMAt = detectionImage;
DefetShow2.ImaMAt = detectionImage;
}
break;
case 3:
{
canvas3.ImaMAt = detectionImage;
DefetShow3.ImaMAt = detectionImage;
}
break;
case 4:
{
canvas4.ImaMAt = detectionImage;
DefetShow4.ImaMAt = detectionImage;
}
break;
case 5:
{
canvas5.ImaMAt = detectionImage;
DefetShow5.ImaMAt = detectionImage;
}
break;
case 6:
{
canvas6.ImaMAt = detectionImage;
DefetShow6.ImaMAt = detectionImage;
}
break;
case 7:
{
// canvas7.ImaMAt = detectionImage;
DefetShow7.ImaMAt = detectionImage;
}
break;
case 8:
@ -2764,7 +2660,7 @@ namespace HisenceYoloDetection
/// <param name="strMatList"><3E><><EFBFBD>صĶ<D8B5>λ<EFBFBD><CEBB><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD></param>
/// <param name="strMatRefList"></param>
/// <param name="IOcrModel"></param>
public void InsertSqlRunDataButton(ref Dictionary<string, bool> keyValueResult, bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List<string> strMatList, ref List<string> strMatRefList, ref PaddleOcrModel IOcrModel)
public void InsertSqlRunDataButton(ref Dictionary<string, bool> keyValueResult, bool saveimage, ref Mat CutMat, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List<string> strMatList, ref List<string> strMatRefList, ref PaddleOcrModel IOcrModel)
{
#if true
//try
@ -2882,7 +2778,6 @@ namespace HisenceYoloDetection
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
Mat matCut = new Mat(mResultCuti, area);
Stopwatch sw = new Stopwatch();
sw.Start();
//OCRʶ<52><CAB6><EFBFBD>ü<EFBFBD>ͼƬ
@ -2964,7 +2859,6 @@ namespace HisenceYoloDetection
string TextWoidStr = OcrFuzzyTextInsert.Join("##"); //ʵ<>ʵļ<CAB5><C4BC><EFBFBD><EFBFBD><EFBFBD>
string SQLStr = "";//<2F><>־<EFBFBD><D6BE>ʾ<EFBFBD><CABE><EFBFBD>ݿ<EFBFBD><DDBF>Ĺؼ<C4B9><D8BC><EFBFBD>
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)
{
case "1"://<2F><>ȫƥ<C8AB><C6A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
@ -2972,31 +2866,19 @@ namespace HisenceYoloDetection
xK_HisenceWord.OneblockPath = CutSavePath;
xK_HisenceWord.OneblockMainWord = MainWoidStr;
xK_HisenceWord.OneblockText = TextWoidStr;
SQLStr = SQlxK_HisenceWord.OneblockText;
string SQLStr2 = SQlxK_HisenceWord.OneblockMainWord;
SQLStr = SQlxK_HisenceWord.OneblockMainWord;
if (!saveimage)
{
bool ssD = ManagerModelHelper.StrMatch(SQLStr, xK_HisenceWord.OneblockText);
Console.Write(SQLStr);
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.OneblockMainWord, SQLStr2);
if (!OneIF1 || !ssD)
OneIF = ManagerModelHelper.StrMatch2(xK_HisenceWord.OneblockMainWord, SQLStr);
if (!OneIF)
{
OneIF = false;
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
DisplayResult(mLcut);
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
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 1);
string Path_2 = Path.Combine("D:\\Hisence\\Test\\1\\ok", filenameone + "_res.png");
Cv2.ImWrite(Path_2, OKMat);
}
}
@ -3046,26 +2928,21 @@ namespace HisenceYoloDetection
if (!saveimage)
{
SQLStr = SQlxK_HisenceWord.ThreeblockMainWord;
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.ThreeblockMainWord, SQlxK_HisenceWord.ThreeblockMainWord);
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.ThreeblockMainWord, SQlxK_HisenceWord.ThreeblockMainWord);
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.ThreeblockPath;
juanjiMatch = CheckDiffSciHelper1.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test1");
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{
OneIF = true;//<2F><><EFBFBD>޸<EFBFBD>6.28
/*
DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap;
Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 3);
*/
Defet_OnDetectionDone(OKMat, 3);
}
else
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 3);
}
@ -3080,7 +2957,7 @@ namespace HisenceYoloDetection
if (!saveimage)
{
SQLStr = SQlxK_HisenceWord.FourblockMainWord;
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FourblockMainWord, SQlxK_HisenceWord.FourblockMainWord);
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FourblockMainWord, SQlxK_HisenceWord.FourblockMainWord);
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.FourblockPath;
@ -3088,7 +2965,6 @@ namespace HisenceYoloDetection
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{
OneIF = false;
DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap;
@ -3096,7 +2972,6 @@ namespace HisenceYoloDetection
}
else
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 4);
}
@ -3118,7 +2993,6 @@ namespace HisenceYoloDetection
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{
OneIF = false;
DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap;
@ -3126,7 +3000,6 @@ namespace HisenceYoloDetection
}
else
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 5);
}
}
@ -3144,12 +3017,11 @@ namespace HisenceYoloDetection
Rect rect = new Rect(0, 0, 0, 0);
string PathSql = SQlxK_HisenceWord.SixblockPath;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һֱΪtrue
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
juanjiMatch = true;
if (!OneIF1 || !juanjiMatch)
if (!OneIF)
{
OneIF = false;
// DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap;
@ -3157,7 +3029,6 @@ namespace HisenceYoloDetection
}
else
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 6);
}
@ -3179,7 +3050,6 @@ namespace HisenceYoloDetection
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{
OneIF = false;
//DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap;
@ -3187,7 +3057,6 @@ namespace HisenceYoloDetection
}
else
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 7);
}
}
@ -3208,7 +3077,6 @@ namespace HisenceYoloDetection
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, rect, rect, false, "D://Hisence//Test");
if (!OneIF1 || !juanjiMatch)
{
OneIF = false;
// DisplayResult(mLcut);
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
// mLcut.ResultMap;
@ -3216,7 +3084,6 @@ namespace HisenceYoloDetection
}
else
{
OneIF = true;
Defet_OnDetectionDone(OKMat, 8);
}
}
@ -3229,7 +3096,9 @@ namespace HisenceYoloDetection
using (StreamWriter sw = new StreamWriter(txtLog, true))
{
sw.WriteLine("<22><>" + blockIndex + "<22><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>" + juanjiMatch);
sw.WriteLine("<22><>" + blockIndex + "<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 + " <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> " + TextWoidStr + "\n");
@ -3281,20 +3150,5 @@ namespace HisenceYoloDetection
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);
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
melsecPLCTCPDriver.WriteInt("550", 0);
}
}
}

View File

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

View File

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

View File

@ -11,7 +11,7 @@ using static OpenCvSharp.FileStorage;
public class MelsecPLCTCPDriver1
public class MelsecPLCTCPDriver
{
private MelsecMcNet melsecMc = new MelsecMcNet();
// private HslCommunication.ModBus.ModbusTcpNet melsecMc = new HslCommunication.ModBus.ModbusTcpNet();

View File

@ -12,7 +12,7 @@ using static OpenCvSharp.FileStorage;
public class MelsecPLCTCPDriver
public class MelsecPLCTCPDriver1
{
// private MelsecMcNet melsecMc = new MelsecMcNet();
// private HslCommunication.ModBus.ModbusTcpNet melsecMc = new HslCommunication.ModBus.ModbusTcpNet();

View File

@ -399,7 +399,6 @@ namespace XKRS.UI
}
#endregion
#region
GPathList.ForEach(path =>
{