Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
326c3c3f5d | ||
|
b970db3b6b | ||
|
a018a8f54d | ||
|
33b32a6c92 | ||
|
a6d2f87095 | ||
d3a08b35f7 | |||
733500850e | |||
2db802c899 | |||
d82f308fed | |||
|
e2dc220aaf |
@ -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>
|
||||||
@ -24,7 +25,7 @@ namespace HisenceYoloDetection
|
|||||||
/// <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())
|
||||||
{
|
{
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
@ -98,14 +99,14 @@ namespace HisenceYoloDetection
|
|||||||
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);
|
||||||
@ -189,154 +431,6 @@ namespace HisenceYoloDetection
|
|||||||
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);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
238
HisenceYoloDetection/MainForm.Designer.cs
generated
238
HisenceYoloDetection/MainForm.Designer.cs
generated
@ -36,6 +36,8 @@
|
|||||||
OpenCvSharp.Mat mat5 = 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 mat9 = 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();
|
||||||
@ -73,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();
|
||||||
@ -126,9 +130,9 @@
|
|||||||
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();
|
||||||
RefeshData = new Button();
|
|
||||||
实时显示 = new Label();
|
实时显示 = new Label();
|
||||||
OKOrNGShow = new PictureBox();
|
OKOrNGShow = new PictureBox();
|
||||||
OKDNum = new TextBox();
|
OKDNum = new TextBox();
|
||||||
@ -137,16 +141,16 @@
|
|||||||
label19 = new Label();
|
label19 = new Label();
|
||||||
AllDSum = new TextBox();
|
AllDSum = new TextBox();
|
||||||
label18 = new Label();
|
label18 = new Label();
|
||||||
InsertSqlBtn = new Button();
|
|
||||||
StartDecBtn = new Button();
|
StartDecBtn = new Button();
|
||||||
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();
|
||||||
@ -561,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);
|
||||||
@ -580,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;
|
||||||
@ -1129,8 +1155,10 @@
|
|||||||
//
|
//
|
||||||
// panel5
|
// panel5
|
||||||
//
|
//
|
||||||
panel5.Controls.Add(DefetShow5);
|
panel5.Controls.Add(DefetShow7);
|
||||||
|
panel5.Controls.Add(DefetShow6);
|
||||||
panel5.Controls.Add(panel8);
|
panel5.Controls.Add(panel8);
|
||||||
|
panel5.Controls.Add(DefetShow2);
|
||||||
panel5.Controls.Add(panel6);
|
panel5.Controls.Add(panel6);
|
||||||
panel5.Dock = DockStyle.Top;
|
panel5.Dock = DockStyle.Top;
|
||||||
panel5.Location = new Point(0, 0);
|
panel5.Location = new Point(0, 0);
|
||||||
@ -1138,30 +1166,50 @@
|
|||||||
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 = "";
|
||||||
mat3.IsEnabledDispose = true;
|
mat3.IsEnabledDispose = true;
|
||||||
DefetShow5.ImaMAt = mat3;
|
DefetShow7.ImaMAt = mat3;
|
||||||
DefetShow5.ImgData = null;
|
DefetShow7.ImgData = null;
|
||||||
DefetShow5.Location = new Point(853, 464);
|
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(254, 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
|
||||||
//
|
//
|
||||||
panel8.Controls.Add(RefeshData);
|
|
||||||
panel8.Controls.Add(实时显示);
|
panel8.Controls.Add(实时显示);
|
||||||
panel8.Controls.Add(OKOrNGShow);
|
panel8.Controls.Add(OKOrNGShow);
|
||||||
panel8.Controls.Add(OKDNum);
|
panel8.Controls.Add(OKDNum);
|
||||||
@ -1170,31 +1218,20 @@
|
|||||||
panel8.Controls.Add(label19);
|
panel8.Controls.Add(label19);
|
||||||
panel8.Controls.Add(AllDSum);
|
panel8.Controls.Add(AllDSum);
|
||||||
panel8.Controls.Add(label18);
|
panel8.Controls.Add(label18);
|
||||||
panel8.Controls.Add(InsertSqlBtn);
|
|
||||||
panel8.Controls.Add(StartDecBtn);
|
panel8.Controls.Add(StartDecBtn);
|
||||||
panel8.Controls.Add(ScanDevList);
|
panel8.Controls.Add(ScanDevList);
|
||||||
panel8.Controls.Add(DevNameCombo);
|
panel8.Controls.Add(DevNameCombo);
|
||||||
panel8.Controls.Add(InitMachine);
|
panel8.Controls.Add(InitMachine);
|
||||||
panel8.Location = new Point(853, 0);
|
panel8.Location = new Point(853, 0);
|
||||||
panel8.Name = "panel8";
|
panel8.Name = "panel8";
|
||||||
panel8.Size = new Size(440, 458);
|
panel8.Size = new Size(440, 244);
|
||||||
panel8.TabIndex = 2;
|
panel8.TabIndex = 2;
|
||||||
panel8.Paint += panel8_Paint;
|
panel8.Paint += panel8_Paint;
|
||||||
//
|
//
|
||||||
// RefeshData
|
|
||||||
//
|
|
||||||
RefeshData.Location = new Point(24, 340);
|
|
||||||
RefeshData.Name = "RefeshData";
|
|
||||||
RefeshData.Size = new Size(94, 43);
|
|
||||||
RefeshData.TabIndex = 13;
|
|
||||||
RefeshData.Text = "刷新";
|
|
||||||
RefeshData.UseVisualStyleBackColor = true;
|
|
||||||
RefeshData.Click += RefeshData_Click;
|
|
||||||
//
|
|
||||||
// 实时显示
|
// 实时显示
|
||||||
//
|
//
|
||||||
实时显示.AutoSize = true;
|
实时显示.AutoSize = true;
|
||||||
实时显示.Location = new Point(326, 175);
|
实时显示.Location = new Point(332, 26);
|
||||||
实时显示.Name = "实时显示";
|
实时显示.Name = "实时显示";
|
||||||
实时显示.Size = new Size(56, 17);
|
实时显示.Size = new Size(56, 17);
|
||||||
实时显示.TabIndex = 12;
|
实时显示.TabIndex = 12;
|
||||||
@ -1202,7 +1239,7 @@
|
|||||||
//
|
//
|
||||||
// OKOrNGShow
|
// OKOrNGShow
|
||||||
//
|
//
|
||||||
OKOrNGShow.Location = new Point(254, 204);
|
OKOrNGShow.Location = new Point(254, 60);
|
||||||
OKOrNGShow.Name = "OKOrNGShow";
|
OKOrNGShow.Name = "OKOrNGShow";
|
||||||
OKOrNGShow.Size = new Size(183, 179);
|
OKOrNGShow.Size = new Size(183, 179);
|
||||||
OKOrNGShow.SizeMode = PictureBoxSizeMode.CenterImage;
|
OKOrNGShow.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||||
@ -1211,7 +1248,7 @@
|
|||||||
//
|
//
|
||||||
// OKDNum
|
// OKDNum
|
||||||
//
|
//
|
||||||
OKDNum.Location = new Point(125, 296);
|
OKDNum.Location = new Point(132, 207);
|
||||||
OKDNum.Name = "OKDNum";
|
OKDNum.Name = "OKDNum";
|
||||||
OKDNum.ReadOnly = true;
|
OKDNum.ReadOnly = true;
|
||||||
OKDNum.Size = new Size(100, 23);
|
OKDNum.Size = new Size(100, 23);
|
||||||
@ -1220,7 +1257,7 @@
|
|||||||
// label20
|
// label20
|
||||||
//
|
//
|
||||||
label20.AutoSize = true;
|
label20.AutoSize = true;
|
||||||
label20.Location = new Point(49, 300);
|
label20.Location = new Point(56, 211);
|
||||||
label20.Name = "label20";
|
label20.Name = "label20";
|
||||||
label20.Size = new Size(50, 17);
|
label20.Size = new Size(50, 17);
|
||||||
label20.TabIndex = 9;
|
label20.TabIndex = 9;
|
||||||
@ -1228,7 +1265,7 @@
|
|||||||
//
|
//
|
||||||
// NGDNum
|
// NGDNum
|
||||||
//
|
//
|
||||||
NGDNum.Location = new Point(125, 249);
|
NGDNum.Location = new Point(132, 160);
|
||||||
NGDNum.Name = "NGDNum";
|
NGDNum.Name = "NGDNum";
|
||||||
NGDNum.ReadOnly = true;
|
NGDNum.ReadOnly = true;
|
||||||
NGDNum.Size = new Size(100, 23);
|
NGDNum.Size = new Size(100, 23);
|
||||||
@ -1237,7 +1274,7 @@
|
|||||||
// label19
|
// label19
|
||||||
//
|
//
|
||||||
label19.AutoSize = true;
|
label19.AutoSize = true;
|
||||||
label19.Location = new Point(49, 253);
|
label19.Location = new Point(56, 164);
|
||||||
label19.Name = "label19";
|
label19.Name = "label19";
|
||||||
label19.Size = new Size(51, 17);
|
label19.Size = new Size(51, 17);
|
||||||
label19.TabIndex = 7;
|
label19.TabIndex = 7;
|
||||||
@ -1245,7 +1282,7 @@
|
|||||||
//
|
//
|
||||||
// AllDSum
|
// AllDSum
|
||||||
//
|
//
|
||||||
AllDSum.Location = new Point(125, 204);
|
AllDSum.Location = new Point(132, 115);
|
||||||
AllDSum.Name = "AllDSum";
|
AllDSum.Name = "AllDSum";
|
||||||
AllDSum.ReadOnly = true;
|
AllDSum.ReadOnly = true;
|
||||||
AllDSum.Size = new Size(100, 23);
|
AllDSum.Size = new Size(100, 23);
|
||||||
@ -1254,26 +1291,15 @@
|
|||||||
// label18
|
// label18
|
||||||
//
|
//
|
||||||
label18.AutoSize = true;
|
label18.AutoSize = true;
|
||||||
label18.Location = new Point(49, 208);
|
label18.Location = new Point(56, 119);
|
||||||
label18.Name = "label18";
|
label18.Name = "label18";
|
||||||
label18.Size = new Size(44, 17);
|
label18.Size = new Size(44, 17);
|
||||||
label18.TabIndex = 5;
|
label18.TabIndex = 5;
|
||||||
label18.Text = "总个数";
|
label18.Text = "总个数";
|
||||||
//
|
//
|
||||||
// InsertSqlBtn
|
|
||||||
//
|
|
||||||
InsertSqlBtn.Location = new Point(54, 56);
|
|
||||||
InsertSqlBtn.Name = "InsertSqlBtn";
|
|
||||||
InsertSqlBtn.Size = new Size(92, 48);
|
|
||||||
InsertSqlBtn.TabIndex = 4;
|
|
||||||
InsertSqlBtn.Text = "型号录入";
|
|
||||||
InsertSqlBtn.UseVisualStyleBackColor = true;
|
|
||||||
InsertSqlBtn.Visible = false;
|
|
||||||
InsertSqlBtn.Click += InsertSqlBtn_Click;
|
|
||||||
//
|
|
||||||
// StartDecBtn
|
// StartDecBtn
|
||||||
//
|
//
|
||||||
StartDecBtn.Location = new Point(160, 127);
|
StartDecBtn.Location = new Point(131, 60);
|
||||||
StartDecBtn.Name = "StartDecBtn";
|
StartDecBtn.Name = "StartDecBtn";
|
||||||
StartDecBtn.Size = new Size(94, 43);
|
StartDecBtn.Size = new Size(94, 43);
|
||||||
StartDecBtn.TabIndex = 3;
|
StartDecBtn.TabIndex = 3;
|
||||||
@ -1283,7 +1309,7 @@
|
|||||||
//
|
//
|
||||||
// ScanDevList
|
// ScanDevList
|
||||||
//
|
//
|
||||||
ScanDevList.Location = new Point(272, 25);
|
ScanDevList.Location = new Point(231, 23);
|
||||||
ScanDevList.Name = "ScanDevList";
|
ScanDevList.Name = "ScanDevList";
|
||||||
ScanDevList.Size = new Size(75, 23);
|
ScanDevList.Size = new Size(75, 23);
|
||||||
ScanDevList.TabIndex = 2;
|
ScanDevList.TabIndex = 2;
|
||||||
@ -1294,14 +1320,14 @@
|
|||||||
// DevNameCombo
|
// DevNameCombo
|
||||||
//
|
//
|
||||||
DevNameCombo.FormattingEnabled = true;
|
DevNameCombo.FormattingEnabled = true;
|
||||||
DevNameCombo.Location = new Point(54, 25);
|
DevNameCombo.Location = new Point(25, 23);
|
||||||
DevNameCombo.Name = "DevNameCombo";
|
DevNameCombo.Name = "DevNameCombo";
|
||||||
DevNameCombo.Size = new Size(200, 25);
|
DevNameCombo.Size = new Size(200, 25);
|
||||||
DevNameCombo.TabIndex = 1;
|
DevNameCombo.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// InitMachine
|
// InitMachine
|
||||||
//
|
//
|
||||||
InitMachine.Location = new Point(54, 127);
|
InitMachine.Location = new Point(24, 60);
|
||||||
InitMachine.Name = "InitMachine";
|
InitMachine.Name = "InitMachine";
|
||||||
InitMachine.Size = new Size(94, 43);
|
InitMachine.Size = new Size(94, 43);
|
||||||
InitMachine.TabIndex = 0;
|
InitMachine.TabIndex = 0;
|
||||||
@ -1309,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);
|
||||||
@ -1320,9 +1367,9 @@
|
|||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
groupBox2.AutoSize = true;
|
groupBox2.AutoSize = true;
|
||||||
|
groupBox2.Controls.Add(DefetShow5);
|
||||||
groupBox2.Controls.Add(DefetShow4);
|
groupBox2.Controls.Add(DefetShow4);
|
||||||
groupBox2.Controls.Add(DefetShow3);
|
groupBox2.Controls.Add(DefetShow3);
|
||||||
groupBox2.Controls.Add(DefetShow2);
|
|
||||||
groupBox2.Controls.Add(originMat2Show);
|
groupBox2.Controls.Add(originMat2Show);
|
||||||
groupBox2.Controls.Add(DefetShow1);
|
groupBox2.Controls.Add(DefetShow1);
|
||||||
groupBox2.Controls.Add(ResultMatShow2);
|
groupBox2.Controls.Add(ResultMatShow2);
|
||||||
@ -1337,20 +1384,41 @@
|
|||||||
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;
|
||||||
DefetShow4.BrushColor = null;
|
DefetShow4.BrushColor = null;
|
||||||
DefetShow4.ImagePath = "";
|
DefetShow4.ImagePath = "";
|
||||||
mat4.IsEnabledDispose = true;
|
mat7.IsEnabledDispose = true;
|
||||||
DefetShow4.ImaMAt = mat4;
|
DefetShow4.ImaMAt = mat7;
|
||||||
DefetShow4.ImgData = null;
|
DefetShow4.ImgData = null;
|
||||||
DefetShow4.Location = new Point(574, 460);
|
DefetShow4.Location = new Point(297, 460);
|
||||||
DefetShow4.MoveStep = 5F;
|
DefetShow4.MoveStep = 5F;
|
||||||
DefetShow4.Name = "DefetShow4";
|
DefetShow4.Name = "DefetShow4";
|
||||||
DefetShow4.Route = 0D;
|
DefetShow4.Route = 0D;
|
||||||
DefetShow4.Scale = 1D;
|
DefetShow4.Scale = 1D;
|
||||||
DefetShow4.Size = new Size(265, 196);
|
DefetShow4.Size = new Size(220, 196);
|
||||||
DefetShow4.TabIndex = 11;
|
DefetShow4.TabIndex = 11;
|
||||||
DefetShow4.WholeScale = 0F;
|
DefetShow4.WholeScale = 0F;
|
||||||
DefetShow4.XMove = 0F;
|
DefetShow4.XMove = 0F;
|
||||||
@ -1363,15 +1431,15 @@
|
|||||||
DefetShow3.AllowSelectDefect = true;
|
DefetShow3.AllowSelectDefect = true;
|
||||||
DefetShow3.BrushColor = null;
|
DefetShow3.BrushColor = null;
|
||||||
DefetShow3.ImagePath = "";
|
DefetShow3.ImagePath = "";
|
||||||
mat5.IsEnabledDispose = true;
|
mat8.IsEnabledDispose = true;
|
||||||
DefetShow3.ImaMAt = mat5;
|
DefetShow3.ImaMAt = mat8;
|
||||||
DefetShow3.ImgData = null;
|
DefetShow3.ImgData = null;
|
||||||
DefetShow3.Location = new Point(303, 460);
|
DefetShow3.Location = new Point(6, 460);
|
||||||
DefetShow3.MoveStep = 5F;
|
DefetShow3.MoveStep = 5F;
|
||||||
DefetShow3.Name = "DefetShow3";
|
DefetShow3.Name = "DefetShow3";
|
||||||
DefetShow3.Route = 0D;
|
DefetShow3.Route = 0D;
|
||||||
DefetShow3.Scale = 1D;
|
DefetShow3.Scale = 1D;
|
||||||
DefetShow3.Size = new Size(265, 196);
|
DefetShow3.Size = new Size(285, 196);
|
||||||
DefetShow3.TabIndex = 10;
|
DefetShow3.TabIndex = 10;
|
||||||
DefetShow3.WholeScale = 0F;
|
DefetShow3.WholeScale = 0F;
|
||||||
DefetShow3.XMove = 0F;
|
DefetShow3.XMove = 0F;
|
||||||
@ -1379,27 +1447,6 @@
|
|||||||
DefetShow3.YMove = 0F;
|
DefetShow3.YMove = 0F;
|
||||||
DefetShow3.YScale = 0F;
|
DefetShow3.YScale = 0F;
|
||||||
//
|
//
|
||||||
// DefetShow2
|
|
||||||
//
|
|
||||||
DefetShow2.AllowSelectDefect = true;
|
|
||||||
DefetShow2.BrushColor = null;
|
|
||||||
DefetShow2.ImagePath = "";
|
|
||||||
mat6.IsEnabledDispose = true;
|
|
||||||
DefetShow2.ImaMAt = mat6;
|
|
||||||
DefetShow2.ImgData = null;
|
|
||||||
DefetShow2.Location = new Point(6, 460);
|
|
||||||
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);
|
||||||
@ -1414,15 +1461,15 @@
|
|||||||
DefetShow1.AllowSelectDefect = true;
|
DefetShow1.AllowSelectDefect = true;
|
||||||
DefetShow1.BrushColor = null;
|
DefetShow1.BrushColor = null;
|
||||||
DefetShow1.ImagePath = "";
|
DefetShow1.ImagePath = "";
|
||||||
mat7.IsEnabledDispose = true;
|
mat9.IsEnabledDispose = true;
|
||||||
DefetShow1.ImaMAt = mat7;
|
DefetShow1.ImaMAt = mat9;
|
||||||
DefetShow1.ImgData = null;
|
DefetShow1.ImgData = null;
|
||||||
DefetShow1.Location = new Point(574, 245);
|
DefetShow1.Location = new Point(574, 245);
|
||||||
DefetShow1.MoveStep = 5F;
|
DefetShow1.MoveStep = 5F;
|
||||||
DefetShow1.Name = "DefetShow1";
|
DefetShow1.Name = "DefetShow1";
|
||||||
DefetShow1.Route = 0D;
|
DefetShow1.Route = 0D;
|
||||||
DefetShow1.Scale = 1D;
|
DefetShow1.Scale = 1D;
|
||||||
DefetShow1.Size = new Size(262, 209);
|
DefetShow1.Size = new Size(254, 209);
|
||||||
DefetShow1.TabIndex = 7;
|
DefetShow1.TabIndex = 7;
|
||||||
DefetShow1.WholeScale = 0F;
|
DefetShow1.WholeScale = 0F;
|
||||||
DefetShow1.XMove = 0F;
|
DefetShow1.XMove = 0F;
|
||||||
@ -1957,7 +2004,6 @@
|
|||||||
private Label label15;
|
private Label label15;
|
||||||
private Button StartDecBtn;
|
private Button StartDecBtn;
|
||||||
private ContextMenuStrip contextMenuStrip1;
|
private ContextMenuStrip contextMenuStrip1;
|
||||||
private Button InsertSqlBtn;
|
|
||||||
private PictureBox ResultMatShow2;
|
private PictureBox ResultMatShow2;
|
||||||
private PictureBox originMatShow2;
|
private PictureBox originMatShow2;
|
||||||
private TextBox OKDNum;
|
private TextBox OKDNum;
|
||||||
@ -1968,7 +2014,6 @@
|
|||||||
private Label label18;
|
private Label label18;
|
||||||
private Label 实时显示;
|
private Label 实时显示;
|
||||||
private PictureBox OKOrNGShow;
|
private PictureBox OKOrNGShow;
|
||||||
private Button RefeshData;
|
|
||||||
private GroupBox groupBox3;
|
private GroupBox groupBox3;
|
||||||
private Button SnapshotCam2;
|
private Button SnapshotCam2;
|
||||||
private Button button3;
|
private Button button3;
|
||||||
@ -2035,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;
|
||||||
@ -2046,5 +2091,8 @@
|
|||||||
private XKRS.UI.Canvas DefetShow3;
|
private XKRS.UI.Canvas DefetShow3;
|
||||||
private XKRS.UI.Canvas DefetShow2;
|
private XKRS.UI.Canvas DefetShow2;
|
||||||
private PictureBox originMat2Show;
|
private PictureBox originMat2Show;
|
||||||
|
private XKRS.UI.Canvas DefetShow7;
|
||||||
|
private XKRS.UI.Canvas DefetShow6;
|
||||||
|
private Button handStopBtn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ using OpenCvSharp;
|
|||||||
using OpenCvSharp.Dnn;
|
using OpenCvSharp.Dnn;
|
||||||
using OpenCvSharp.Extensions;
|
using OpenCvSharp.Extensions;
|
||||||
using OpenCvSharp.XFeatures2D;
|
using OpenCvSharp.XFeatures2D;
|
||||||
|
using Sunny.UI;
|
||||||
|
using Sunny.UI.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -23,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;
|
||||||
@ -189,10 +192,11 @@ namespace HisenceYoloDetection
|
|||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
string s1 = "ECO4060##Coton20¡æ##Rapide15mns";
|
string s1 = "gorenjeSTEAMTECHSNOWFLAKEDRUM65kg";
|
||||||
string s2 = "Eco4060##Coton20¡æ##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\\W80WXWJ060539V0WW80WX120293\\2\\W80WXWJ060539V0WW80WX120293result.jpg";
|
//string path2 = "D:\\Hisence\\SQLImages\\W80WXWJ060539V0WW80WX120293\\2\\W80WXWJ060539V0WW80WX120293result.jpg";
|
||||||
@ -273,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(); //先关闭定时器
|
t.Stop(); //先关闭定时器
|
||||||
//melsecPLCTCPDriver.WriteInt("548", 1);
|
//melsecPLCTCPDriver.WriteInt("548", 1);
|
||||||
//Thread.Sleep(1000);
|
//Thread.Sleep(1000);
|
||||||
@ -520,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)
|
||||||
{
|
{
|
||||||
@ -549,6 +555,7 @@ namespace HisenceYoloDetection
|
|||||||
Bitmap NGbitmap = new Bitmap("NG.jpg");
|
Bitmap NGbitmap = new Bitmap("NG.jpg");
|
||||||
Mat OKMat = Cv2.ImRead("OK.jpg");
|
Mat OKMat = Cv2.ImRead("OK.jpg");
|
||||||
Mat NGMat = Cv2.ImRead("OK.jpg");
|
Mat NGMat = Cv2.ImRead("OK.jpg");
|
||||||
|
Mat whiteMat = Cv2.ImRead("white.jpg");
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主线程调用
|
/// 主线程调用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -592,10 +599,10 @@ namespace HisenceYoloDetection
|
|||||||
melsecPLCTCPDriver.WriteInt("514", 0);//定位松开
|
melsecPLCTCPDriver.WriteInt("514", 0);//定位松开
|
||||||
melsecPLCTCPDriver.WriteInt("524", 0);//定位松开
|
melsecPLCTCPDriver.WriteInt("524", 0);//定位松开
|
||||||
melsecPLCTCPDriver.WriteInt("406", 60000); //写入手动速度
|
melsecPLCTCPDriver.WriteInt("406", 60000); //写入手动速度
|
||||||
melsecPLCTCPDriver.WriteInt("416", 8000);
|
melsecPLCTCPDriver.WriteInt("416", 10000);
|
||||||
melsecPLCTCPDriver.WriteInt("426", 10000);
|
melsecPLCTCPDriver.WriteInt("426", 10000);
|
||||||
melsecPLCTCPDriver.WriteInt("404", 100000); //写入定位速度
|
melsecPLCTCPDriver.WriteInt("404", 100000); //写入定位速度
|
||||||
melsecPLCTCPDriver.WriteInt("414", 8000);
|
melsecPLCTCPDriver.WriteInt("414", 10000);
|
||||||
melsecPLCTCPDriver.WriteInt("424", 10000);
|
melsecPLCTCPDriver.WriteInt("424", 10000);
|
||||||
|
|
||||||
|
|
||||||
@ -610,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");
|
||||||
@ -1035,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;//第一次用信号挡
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 监听洗衣机544是否触发后面对射传感器 相机
|
/// 监听洗衣机544是否触发后面对射传感器 相机
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1079,6 +1088,7 @@ namespace HisenceYoloDetection
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
iNum1 = 0;
|
iNum1 = 0;
|
||||||
|
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
|
||||||
}
|
}
|
||||||
if (iNum1 >= 2)
|
if (iNum1 >= 2)
|
||||||
{
|
{
|
||||||
@ -1086,9 +1096,16 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if true
|
#if true
|
||||||
|
if(!StopM)
|
||||||
|
{
|
||||||
|
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
|
||||||
|
StopM = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
myLog("第一次采集图像", DateTime.Now);
|
myLog("第一次采集图像", DateTime.Now);
|
||||||
//移动模组 读三次测距的地址 看是否往前移动
|
//移动模组 读三次测距的地址 看是否往前移动
|
||||||
MoveToP(5815, YPos, ZPos);
|
MoveToP(7948, YPos, ZPos);
|
||||||
// Thread.Sleep(2000);//删
|
// Thread.Sleep(2000);//删
|
||||||
|
|
||||||
|
|
||||||
@ -1108,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);
|
||||||
@ -1124,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);//方行
|
||||||
|
//Thread.Sleep(300);//洗衣机可能过不去
|
||||||
|
|
||||||
//if (xKNow != null)
|
//if (xKNow != null)
|
||||||
//{
|
//{
|
||||||
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
|
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
|
||||||
@ -1142,7 +1162,7 @@ namespace HisenceYoloDetection
|
|||||||
#else
|
#else
|
||||||
myLog("第一次采集图像", DateTime.Now);
|
myLog("第一次采集图像", DateTime.Now);
|
||||||
//移动模组 读三次测距的地址 看是否往前移动
|
//移动模组 读三次测距的地址 看是否往前移动
|
||||||
//MoveToP(5815, YPos, ZPos);
|
//MoveToP(7948, YPos, ZPos);
|
||||||
Thread.Sleep(1000);//删
|
Thread.Sleep(1000);//删
|
||||||
|
|
||||||
|
|
||||||
@ -1162,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);
|
||||||
@ -1182,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);
|
||||||
@ -1257,7 +1277,7 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\ÀàÐÍ\\1\\202461817464661.jpg"); ;
|
//Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\类型\\1\\001.jpg"); ;
|
||||||
Cam1ImgOne = cameraMat;
|
Cam1ImgOne = cameraMat;
|
||||||
IfCam1OneTriger = true;
|
IfCam1OneTriger = true;
|
||||||
originMatShow.Image = cameraMat.ToBitmap();
|
originMatShow.Image = cameraMat.ToBitmap();
|
||||||
@ -1314,7 +1334,7 @@ namespace HisenceYoloDetection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReadyDetect()
|
public void ReadyDetect()
|
||||||
{
|
{
|
||||||
Task.Run((Action)(() =>
|
_ = Task.Run((Action)(() =>
|
||||||
{
|
{
|
||||||
Thread.CurrentThread.Priority = ThreadPriority.Highest;
|
Thread.CurrentThread.Priority = ThreadPriority.Highest;
|
||||||
while (true)
|
while (true)
|
||||||
@ -1340,7 +1360,7 @@ namespace HisenceYoloDetection
|
|||||||
sw.WriteLine(IOcrBAr + "\n");
|
sw.WriteLine(IOcrBAr + "\n");
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
IOcrBAr = "BatchW825UModelWNHEI74SAS";
|
IOcrBAr = "BatchW96DHModelWF3S7021BWPl";
|
||||||
//根据条码数据库比对
|
//根据条码数据库比对
|
||||||
xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
|
xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
|
||||||
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
||||||
@ -1387,6 +1407,16 @@ namespace HisenceYoloDetection
|
|||||||
//相机1第二次拍照
|
//相机1第二次拍照
|
||||||
if (IfCam1TwoTriger && bBarTriger)
|
if (IfCam1TwoTriger && bBarTriger)
|
||||||
{
|
{
|
||||||
|
//初始化板
|
||||||
|
Defet_OnDetectionDone(whiteMat, 1);
|
||||||
|
Defet_OnDetectionDone(whiteMat, 2);
|
||||||
|
Defet_OnDetectionDone(whiteMat, 3);
|
||||||
|
Defet_OnDetectionDone(whiteMat, 4);
|
||||||
|
Defet_OnDetectionDone(whiteMat, 5);
|
||||||
|
Defet_OnDetectionDone(whiteMat, 6);
|
||||||
|
Defet_OnDetectionDone(whiteMat, 7);
|
||||||
|
|
||||||
|
|
||||||
XK_HisenceWord xK_MatchDet = new XK_HisenceWord();
|
XK_HisenceWord xK_MatchDet = new XK_HisenceWord();
|
||||||
xK_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
|
xK_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
|
||||||
AllDsums++;
|
AllDsums++;
|
||||||
@ -1421,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();
|
||||||
|
}//无法框定导致图片闪烁,加else无法解决
|
||||||
//进行推理
|
//进行推理
|
||||||
MLRequest req2 = new MLRequest();
|
MLRequest req2 = new MLRequest();
|
||||||
req2.currentMat = Cam1ImgTwo;
|
req2.currentMat = Cam1ImgTwo;
|
||||||
@ -1466,34 +1502,32 @@ namespace HisenceYoloDetection
|
|||||||
detstr += RealLabels[i];
|
detstr += RealLabels[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//排序比对块
|
||||||
|
HashSet<string> set1 = new HashSet<string>(listLabels);
|
||||||
|
HashSet<string> set2 = new HashSet<string>(RealLabels);
|
||||||
|
bool MatchStr = set1.SetEquals(set2);
|
||||||
|
|
||||||
|
if (MatchStr)
|
||||||
|
{
|
||||||
|
//判断块值是否有含有匹配false
|
||||||
|
bool containsFalseValue = keyValueResult.ContainsValue(false);
|
||||||
|
bool containsFalseValue2 = keyValueResult2.ContainsValue(false);
|
||||||
|
if (containsFalseValue || containsFalseValue2)
|
||||||
|
MatchStr = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
///执行比对 小图
|
///执行比对 小图
|
||||||
//bool MatchStr = ManagerModelHelper.IsMatchSQLText(ref mCut, ref xK_HisenceSQLWord, ref xK_MatchDet);
|
//bool MatchStr = ManagerModelHelper.IsMatchSQLText(ref mCut, ref xK_HisenceSQLWord, ref xK_MatchDet);
|
||||||
bool MatchStr = true;
|
|
||||||
keyValueResult.ForEach(x =>
|
|
||||||
{
|
|
||||||
if (x.Value == false)
|
|
||||||
{
|
|
||||||
MatchStr = false;
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
keyValueResult2.ForEach(x =>
|
|
||||||
{
|
|
||||||
if (x.Value == false)
|
|
||||||
{
|
|
||||||
MatchStr = false;
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// int sqlblocksum=
|
||||||
IfCam1TwoTriger = false;
|
IfCam1TwoTriger = false;
|
||||||
bBarTriger = false;
|
bBarTriger = false;
|
||||||
|
|
||||||
|
|
||||||
|
melsecPLCTCPDriver.WriteInt("550", 0);//方行
|
||||||
if (MatchStr)
|
if (MatchStr)
|
||||||
{
|
{
|
||||||
OKDsums++;
|
OKDsums++;
|
||||||
@ -1785,17 +1819,30 @@ 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();
|
||||||
myLog("开启流程成功", DateTime.Now);
|
myLog("开启流程成功", DateTime.Now);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertSqlBtn_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RefeshData_Click(object sender, EventArgs e)
|
private void RefeshData_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
||||||
@ -2619,12 +2666,12 @@ namespace HisenceYoloDetection
|
|||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{
|
||||||
// DefetShow6.ImaMAt = detectionImage;
|
DefetShow6.ImaMAt = detectionImage;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
// DefetShow7.ImaMAt = detectionImage;
|
DefetShow7.ImaMAt = detectionImage;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
@ -2659,7 +2706,13 @@ namespace HisenceYoloDetection
|
|||||||
#if true
|
#if true
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
|
string filename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
|
||||||
|
string txtLog = "D://Hisence//" + filename + "logsMatch.log";
|
||||||
|
using (StreamWriter sw = new StreamWriter(txtLog, true))
|
||||||
|
{
|
||||||
|
sw.WriteLine(filename + "\n");
|
||||||
|
sw.Flush();
|
||||||
|
}
|
||||||
Mat mResultCut = currentMatC.Clone();
|
Mat mResultCut = currentMatC.Clone();
|
||||||
Rect areaBlack = new Rect();
|
Rect areaBlack = new Rect();
|
||||||
//旋钮的位置
|
//旋钮的位置
|
||||||
@ -2766,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识别裁剪图片
|
//OCR识别裁剪图片
|
||||||
@ -2847,6 +2901,7 @@ namespace HisenceYoloDetection
|
|||||||
string TextWoidStr = OcrFuzzyTextInsert.Join("##"); //实际的检测字
|
string TextWoidStr = OcrFuzzyTextInsert.Join("##"); //实际的检测字
|
||||||
string SQLStr = "";//日志显示数据库的关键字
|
string SQLStr = "";//日志显示数据库的关键字
|
||||||
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"://完全匹配 重量信息
|
case "1"://完全匹配 重量信息
|
||||||
@ -2854,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;
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2916,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;//待修改6.28
|
||||||
|
/*
|
||||||
DisplayResult(mLcut);
|
DisplayResult(mLcut);
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2940,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);
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
// mLcut.ResultMap;
|
// mLcut.ResultMap;
|
||||||
@ -2950,6 +3033,7 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OneIF = true;
|
||||||
Defet_OnDetectionDone(OKMat, 4);
|
Defet_OnDetectionDone(OKMat, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2964,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);
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
// mLcut.ResultMap;
|
// mLcut.ResultMap;
|
||||||
@ -2974,6 +3063,7 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OneIF = true;
|
||||||
Defet_OnDetectionDone(OKMat, 5);
|
Defet_OnDetectionDone(OKMat, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2987,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);
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
// mLcut.ResultMap;
|
// mLcut.ResultMap;
|
||||||
@ -2997,6 +3094,7 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OneIF = true;
|
||||||
Defet_OnDetectionDone(OKMat, 6);
|
Defet_OnDetectionDone(OKMat, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3011,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);
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
// mLcut.ResultMap;
|
// mLcut.ResultMap;
|
||||||
@ -3021,6 +3124,7 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OneIF = true;
|
||||||
Defet_OnDetectionDone(OKMat, 7);
|
Defet_OnDetectionDone(OKMat, 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3034,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);
|
||||||
//显示错误的板
|
//显示错误的板
|
||||||
// mLcut.ResultMap;
|
// mLcut.ResultMap;
|
||||||
@ -3044,20 +3153,20 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OneIF = true;
|
||||||
Defet_OnDetectionDone(OKMat, 8);
|
Defet_OnDetectionDone(OKMat, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
using (StreamWriter sw = new StreamWriter("D://Hisence//logsMatch.log", true))
|
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString();
|
||||||
|
string txtLog = "D://Hisence//" + filename + "logsMatch.log";
|
||||||
|
|
||||||
|
using (StreamWriter sw = new StreamWriter(txtLog, true))
|
||||||
{
|
{
|
||||||
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
|
|
||||||
sw.WriteLine(filename + "\n");
|
sw.WriteLine("块" + blockIndex + "卷积匹配" + juanjiMatch);
|
||||||
if (blockIndex == "2")
|
|
||||||
{
|
|
||||||
sw.WriteLine("¾í»ýÆ¥Åä" + juanjiMatch);
|
|
||||||
}
|
|
||||||
sw.WriteLine("块" + blockIndex + "数据库" + SQLStr + "关键字" + MainWoidStr + "结果" + OneIF + "\n");
|
sw.WriteLine("块" + blockIndex + "数据库" + SQLStr + "关键字" + MainWoidStr + "结果" + OneIF + "\n");
|
||||||
sw.WriteLine("块" + blockIndex + " 所有字 " + TextWoidStr + "\n");
|
sw.WriteLine("块" + blockIndex + " 所有字 " + TextWoidStr + "\n");
|
||||||
|
|
||||||
@ -3109,5 +3218,15 @@ namespace HisenceYoloDetection
|
|||||||
myLog("X轴停止归零", DateTime.Now);
|
myLog("X轴停止归零", 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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>31</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">
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
@ -227,10 +227,13 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
static bool AreMoreThanHalfEqual(string[] array1, string[] array2)
|
static bool AreMoreThanHalfEqual(string[] array1, string[] array2)
|
||||||
{
|
{
|
||||||
|
string Sqltext = array1.Join("");
|
||||||
|
string Realtext = array2.Join("");
|
||||||
int io = 0;
|
int io = 0;
|
||||||
foreach (string ch1 in array1)
|
|
||||||
|
foreach (char ch2 in Realtext)
|
||||||
{
|
{
|
||||||
foreach (string ch2 in array2)
|
foreach (char ch1 in Sqltext)
|
||||||
{
|
{
|
||||||
if (ch1 == ch2)
|
if (ch1 == ch2)
|
||||||
{
|
{
|
||||||
@ -249,7 +252,7 @@ namespace HisenceYoloDetection
|
|||||||
//int intersectionCount = set1.Intersect(set2).Count();
|
//int intersectionCount = set1.Intersect(set2).Count();
|
||||||
|
|
||||||
// 判断交集数量是否超过一半
|
// 判断交集数量是否超过一半
|
||||||
return io > array1.Length / 2;
|
return io >=Sqltext.Length / 2;
|
||||||
}
|
}
|
||||||
public static bool StrMatch2(string SqlText, string DetText)
|
public static bool StrMatch2(string SqlText, string DetText)
|
||||||
{
|
{
|
||||||
@ -277,7 +280,7 @@ namespace HisenceYoloDetection
|
|||||||
Console.WriteLine("字符串中不包含数字");
|
Console.WriteLine("字符串中不包含数字");
|
||||||
}
|
}
|
||||||
bool areEqual ;
|
bool areEqual ;
|
||||||
if (numbers2.Length>2&& numbers.Length > 2)
|
if (numbers2.Length>0&& numbers.Length > 0)
|
||||||
{
|
{
|
||||||
areEqual = AreMoreThanHalfEqual(numbers, numbers2);
|
areEqual = AreMoreThanHalfEqual(numbers, numbers2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user