3978 lines
153 KiB
C#
3978 lines
153 KiB
C#
using DVPCameraType;
|
||
using Microsoft.VisualBasic.Logging;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using OpenCvSharp;
|
||
using OpenCvSharp.Dnn;
|
||
using OpenCvSharp.Extensions;
|
||
using OpenCvSharp.XFeatures2D;
|
||
using STTech.CodePlus.Threading;
|
||
using Sunny.UI;
|
||
using Sunny.UI.Win32;
|
||
using System;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
||
using System.Data.SQLite;
|
||
using System.Diagnostics;
|
||
using System.Diagnostics.Eventing.Reader;
|
||
using System.Drawing;
|
||
using System.Drawing.Drawing2D;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Numerics;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Windows.Forms;
|
||
using System.Xml.Serialization;
|
||
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;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
|
||
|
||
|
||
namespace HisenceYoloDetection
|
||
{
|
||
public partial class MainForm : Form
|
||
{
|
||
enum MeachineState
|
||
{
|
||
machine_opening,
|
||
machine_closing,
|
||
}
|
||
public MainForm()
|
||
{
|
||
InitializeComponent();
|
||
this.Load += (s, e) =>
|
||
{
|
||
// OnDetectionDone -= Defet_OnDetectionDone;
|
||
//OnDetectionDone += Defet_OnDetectionDone;
|
||
};
|
||
}
|
||
MeachineState meachineState = MeachineState.machine_closing;
|
||
MGSCameraDriver Cam1 = new MGSCameraDriver();
|
||
MGSCameraDriver Cam2 = new MGSCameraDriver();
|
||
public static string RootPath = "D:\\Hisence\\SQLImages\\";
|
||
// HikCameraDriver Cam1 = new HikCameraDriver();
|
||
//HikCameraDriver Cam2 = new HikCameraDriver();
|
||
|
||
SQLiteHelper sqlhelper = new SQLiteHelper();
|
||
TCPClienDriver Scanner = new TCPClienDriver();
|
||
MelsecPLCTCPDriver melsecPLCTCPDriver = new MelsecPLCTCPDriver();
|
||
SimboObjectDetection simboObjectDetection = new SimboObjectDetection();
|
||
SimboObjectDetection simboObjectDetButton = new SimboObjectDetection();
|
||
// CheckDiffSciHelper checkDiffSciHelper = new CheckDiffSciHelper();
|
||
// ManagerModelHelper managerModelHelper = new ManagerModelHelper();
|
||
|
||
PaddleOcrModel paddleOcrModel = new PaddleOcrModel();
|
||
PaddleOcrModelCountry paddleOcrModelCountry = new PaddleOcrModelCountry();
|
||
List<XKHisence> xKHisences = new List<XKHisence>();
|
||
|
||
static AutoResetEvent myResetEvent = new AutoResetEvent(false);
|
||
|
||
AutoResetEvent _runHandleBefore = new AutoResetEvent(false);
|
||
ManualResetEvent _runHandleAfter = new ManualResetEvent(false);
|
||
AutoResetEvent _runThreadFormtype = new AutoResetEvent(false);
|
||
bool PLC545 = false;
|
||
private const string CorrectPassword = "12345";
|
||
|
||
bool PLC548 = false;
|
||
string m_sKEYENCEBar;
|
||
string Oldm_sKEYENCEBar;
|
||
string OcrBar = "";//ϴ<>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
|
||
string IfChangeLanguage = "";//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ϴ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD>ͺ<EFBFBD>
|
||
bool bTriger = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
bool bBarTriger = false;//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>λ<EFBFBD><CEBB>
|
||
bool bBar = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
bool IfCam1OneTriger = false;//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
bool IfCam1TwoTriger = false;//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
bool IfCam2Triger = false;//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Mat Cam1ImgOne = new Mat();//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>Ƭ
|
||
Mat Cam1ImgTwo = new Mat();//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>Ƭ
|
||
Mat Cam2ImgShowBar = new Mat();//ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>Ƭ <20><><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
XKHisence xKNow;//<2F><><EFBFBD>ݿ<EFBFBD><DDBF>е<EFBFBD>ϴ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
|
||
XKHisence Old_xKNow;//<2F><><EFBFBD>ݿ<EFBFBD><DDBF>е<EFBFBD>ϴ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
|
||
XK_HisenceWord xK_HisenceSQLWord = new XK_HisenceWord();
|
||
bool bOn = false;
|
||
////////////////////////////
|
||
public static int m_CamCount = 0;
|
||
public int m_n_dev_count = 0;
|
||
public static dvpCameraInfo[] m_info = new dvpCameraInfo[16];
|
||
bool ifXZeroValue = false;
|
||
bool ifYZeroValue = false;
|
||
bool ifZZeroValue = false;
|
||
|
||
bool ifXForward = false;
|
||
bool ifYForward = false;
|
||
bool ifZForward = false;
|
||
|
||
bool ifXBackward = false;
|
||
bool ifYBackward = false;
|
||
bool ifZBackward = false;
|
||
string LablePath = "";
|
||
//¼<><C2BC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
||
string BarPath = "";
|
||
string Cam1OnePath = "";
|
||
string Cam1TwoPath = "";
|
||
string ModelChangePath = "";
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
string GreenLightingAdress = "556";
|
||
string YellowLightingAdress = "554";
|
||
string RedLightingAdress = "552";
|
||
string WaringAdress = "558";
|
||
/// <summary>
|
||
/// <20>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||
/// </summary>
|
||
public void InitDevList()
|
||
{
|
||
dvpStatus status;
|
||
uint i, n = 0;
|
||
dvpCameraInfo dev_info = new dvpCameraInfo();
|
||
|
||
// "n" represents the number of cameras that is enumerated successfully, the drop-down list contains each camera's FriendlyName.
|
||
DevNameCombo.Items.Clear();
|
||
|
||
// Get the number of cameras that has been connected to a computer.
|
||
status = DVPCamera.dvpRefresh(ref n);
|
||
Debug.Assert(status == dvpStatus.DVP_STATUS_OK);
|
||
m_n_dev_count = (int)n;
|
||
if (status == dvpStatus.DVP_STATUS_OK)
|
||
{
|
||
m_CamCount = 0;
|
||
|
||
for (i = 0; i < n; i++)
|
||
{
|
||
// Acquire each camera's information one by one.
|
||
status = DVPCamera.dvpEnum(i, ref dev_info);
|
||
Debug.Assert(status == dvpStatus.DVP_STATUS_OK);
|
||
if (status == dvpStatus.DVP_STATUS_OK)
|
||
{
|
||
m_info[m_CamCount] = dev_info;
|
||
|
||
int item = -1;
|
||
|
||
// add User Define Name
|
||
item = DevNameCombo.Items.Add(dev_info.UserID);
|
||
|
||
if (item == 0)
|
||
{
|
||
DevNameCombo.SelectedIndex = item;
|
||
}
|
||
m_CamCount++;
|
||
|
||
if (item == 0)
|
||
{
|
||
DevNameCombo.SelectedIndex = item;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
System.Timers.Timer SpeedTimer = new System.Timers.Timer();
|
||
System.Timers.Timer PostionTimer = new System.Timers.Timer();
|
||
System.Timers.Timer t;
|
||
public delegate void MyDelegateUI(); //<2F><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
MyDelegateUI myDelegateUI; //<2F><><EFBFBD><EFBFBD>ί<EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
||
|
||
public delegate void MyPosDelegateUI(); //<2F><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
MyPosDelegateUI myPosDelegateUI; //<2F><><EFBFBD><EFBFBD>ί<EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
||
|
||
public delegate void MyLogDelegateUI(); //<2F><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
MyLogDelegateUI myLogDelegateUI; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ί<D6BE>ж<EFBFBD><D0B6><EFBFBD>
|
||
private void Application_ThreadException(Exception e)
|
||
{
|
||
string msg = e.Message;
|
||
|
||
using (StreamWriter sw = new StreamWriter("D://ThreadException.log", true))
|
||
{
|
||
sw.WriteLine("================================");
|
||
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||
sw.WriteLine(msg);
|
||
sw.Flush();
|
||
}
|
||
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// GET<45><54>ʽ<EFBFBD><CABD><EFBFBD>͵ý<CDB5><C3BD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="url"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url</param>
|
||
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD></returns>
|
||
public static string getHttpRequest(string url)
|
||
{
|
||
//Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
||
HttpWebRequest request = null;
|
||
HttpWebResponse response = null;
|
||
StreamReader reader = null;
|
||
|
||
string content = string.Empty;
|
||
|
||
try
|
||
{
|
||
request = (HttpWebRequest)WebRequest.Create(url);
|
||
request.Method = "GET";
|
||
|
||
response = (HttpWebResponse)request.GetResponse();
|
||
using (reader = new StreamReader(response.GetResponseStream()))
|
||
{
|
||
content = reader.ReadToEnd();
|
||
}
|
||
}
|
||
catch (System.Exception err)
|
||
{
|
||
MessageBox.Show("1.GET<45><54><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>" + err.Source + "\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>" + err.Message + "\n" + err);
|
||
Console.WriteLine("1.GET<45><54><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>" + err.Source + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>" + err.Message);
|
||
}
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
response.Dispose();
|
||
reader.Dispose();
|
||
|
||
return content;
|
||
}
|
||
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>http<74><70><EFBFBD><EFBFBD>ʽΪPOST
|
||
/// </summary>
|
||
/// <param name="uri"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>url</param>
|
||
/// <param name="reMsg">Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>Ϣ</param>
|
||
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD></returns>
|
||
public string postHttpRequest(string uri, string msg)
|
||
{
|
||
//Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
||
HttpWebRequest request = null;
|
||
HttpWebResponse response = null;
|
||
Stream requestStream = null;
|
||
StreamReader reader = null;
|
||
|
||
var data = Encoding.UTF8.GetBytes(string.Format("a={0}&b={1}", "message", msg));
|
||
string content = "";
|
||
|
||
try
|
||
{
|
||
request = (HttpWebRequest)WebRequest.Create(uri);
|
||
request.Method = "POST";
|
||
requestStream = request.GetRequestStream();
|
||
|
||
request.ContentType = "application/text";
|
||
|
||
requestStream.Write(data, 0, data.Length);
|
||
response = (HttpWebResponse)request.GetResponse();
|
||
|
||
using (reader = new StreamReader(response.GetResponseStream()))
|
||
{
|
||
content = reader.ReadToEnd();
|
||
}
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
MessageBox.Show("1.POST<53><54><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>" + err.Source + "\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>" + err.Message + "\n" + err);
|
||
Console.WriteLine("1.POST<53><54><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>" + err.Source + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>" + err.Message);
|
||
}
|
||
|
||
//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
requestStream.Dispose();
|
||
response.Dispose();
|
||
reader.Dispose();
|
||
|
||
return content;
|
||
}
|
||
|
||
public static string PostData(string url, string postData)
|
||
{
|
||
byte[] data = Encoding.UTF8.GetBytes(postData);
|
||
|
||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||
request.Method = "POST";
|
||
request.ContentType = "application/x-www-form-urlencoded";
|
||
request.ContentLength = data.Length;
|
||
|
||
using (Stream stream = request.GetRequestStream())
|
||
{
|
||
stream.Write(data, 0, data.Length);
|
||
}
|
||
|
||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
|
||
{
|
||
return reader.ReadToEnd();
|
||
}
|
||
}
|
||
|
||
static string FindStringAfterColon(string response, string targetString)
|
||
{
|
||
int targetIndex = response.IndexOf(targetString);
|
||
if (targetIndex == -1)
|
||
{
|
||
Console.WriteLine($"δ<>ҵ<EFBFBD><D2B5>ַ<EFBFBD><D6B7><EFBFBD>: {targetString}");
|
||
return null;
|
||
}
|
||
|
||
// <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD>
|
||
int colonIndex = response.IndexOf(':', targetIndex);
|
||
if (colonIndex == -1 || colonIndex <= targetIndex)
|
||
{
|
||
Console.WriteLine("<22><>Ŀ<EFBFBD><C4BF><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD>ð<EFBFBD><C3B0>");
|
||
return null;
|
||
}
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD>ʼ<EFBFBD><CABC>λ<EFBFBD><CEBB>
|
||
int startQuoteIndex = response.IndexOf('"', colonIndex + 1);
|
||
if (startQuoteIndex == -1)
|
||
{
|
||
Console.WriteLine("δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>");
|
||
return null;
|
||
}
|
||
|
||
// <20><><EFBFBD>ұպ<D2B1><D5BA><EFBFBD><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
|
||
int endQuoteIndex = response.IndexOf('"', startQuoteIndex + 1);
|
||
if (endQuoteIndex == -1)
|
||
{
|
||
Console.WriteLine("δ<>ҵ<EFBFBD><D2B5>պϵ<D5BA><CFB5><EFBFBD><EFBFBD><EFBFBD>");
|
||
return null;
|
||
}
|
||
|
||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5>ַ<EFBFBD><D6B7><EFBFBD>
|
||
return response.Substring(startQuoteIndex + 1, endQuoteIndex - startQuoteIndex - 1);
|
||
}
|
||
|
||
|
||
#region Post<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// <summary>
|
||
/// http Post<73><74><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="parameterData"><3E><><EFBFBD><EFBFBD></param>
|
||
/// <param name="serviceUrl"><3E><><EFBFBD>ʵ<EFBFBD>ַ</param>
|
||
/// <param name="ContentType">Ĭ<><C4AC> application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param>
|
||
/// <param name="Accept">Ĭ<><C4AC>application/json</param>
|
||
/// <returns></returns>
|
||
public string Post(string parameterData, string serviceUrl, string contentType = "application/x-www-form-urlencoded", string accept = "application/json")
|
||
{
|
||
try
|
||
{
|
||
// <20><><EFBFBD><EFBFBD> Web <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
|
||
byte[] buf = Encoding.UTF8.GetBytes($"inputvalue={Uri.EscapeDataString(parameterData)}");
|
||
|
||
myRequest.Method = "POST";
|
||
myRequest.Accept = accept;
|
||
myRequest.ContentType = contentType;
|
||
myRequest.ContentLength = buf.Length;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
using (Stream stream = myRequest.GetRequestStream())
|
||
{
|
||
stream.Write(buf, 0, buf.Length);
|
||
}
|
||
|
||
// <20><>ȡ<EFBFBD><C8A1>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
|
||
using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
|
||
using (StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8))
|
||
{
|
||
return reader.ReadToEnd();
|
||
}
|
||
}
|
||
catch (WebException ex)
|
||
{
|
||
if (ex.Response != null)
|
||
{
|
||
using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
|
||
{
|
||
string errorResponse = reader.ReadToEnd();
|
||
Console.WriteLine("WebException: " + errorResponse);
|
||
return errorResponse;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Console.WriteLine("WebException: " + ex.Message);
|
||
return null;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Console.WriteLine("Exception: " + ex.Message);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
Dictionary<string, string> DayTypeDics = new Dictionary<string, string>();//<2F><><EFBFBD>ŵ<EFBFBD><C5B5>յ<EFBFBD>SN<53><4E><EFBFBD>ͺ<EFBFBD>ֵ
|
||
public void GetTypeFromPost()
|
||
{
|
||
string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
|
||
string jsonData = @"
|
||
{
|
||
""StartTime"": ""2024-07-1"",
|
||
""EndTime"": ""2024-07-22"",
|
||
""LineBody"": ""BZ-PC""
|
||
}";
|
||
|
||
|
||
string postData = "inputvalue=" + Uri.EscapeDataString(jsonData);
|
||
|
||
try
|
||
{
|
||
string response = PostData(url, postData);
|
||
|
||
|
||
string productType = null;
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
||
string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7); // Ŀ<><C4BF> FinalDefID
|
||
productType = FindStringAfterColon(response, finalDefIdToFind);
|
||
if (productType == null)
|
||
{
|
||
finalDefIdToFind = finalDefIdToFind.Substring(0, finalDefIdToFind.Length - 6);
|
||
productType = FindStringAfterColon(response, finalDefIdToFind);
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Console.WriteLine("Error occurred:");
|
||
Console.WriteLine(ex.Message);
|
||
}
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void MainForm_Load(object sender, EventArgs e)
|
||
{
|
||
//string path22 = "D:\\Hisence\\test2\\222.jpg";
|
||
//Mat pathmat2 = Cv2.ImRead(path22);
|
||
//Mat pathmat2result = Cv2.ImRead(path22);
|
||
//string path222 = "D:\\Hisence\\test2\\111.jpg";
|
||
//Rect rect1 = new Rect(0, 0, 0, 0);
|
||
|
||
|
||
//CheckDiffSciHelper.CheckDiffSci(path222, pathmat2,ref pathmat2result, rect1, rect1, true, "D://Hisence//test2");
|
||
|
||
|
||
Stopwatch sw = new Stopwatch();
|
||
sw.Start();
|
||
|
||
// string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
|
||
|
||
// string jsonData = @"
|
||
//{
|
||
// ""StartTime"": ""2024-07-15"",
|
||
// ""EndTime"": ""2024-07-15"",
|
||
// ""LineBody"": ""BZ-PC""
|
||
// }";
|
||
|
||
|
||
// string postData = "inputvalue=" + Uri.EscapeDataString(jsonData);
|
||
|
||
// try
|
||
// {
|
||
// string response = PostData(url, postData);
|
||
|
||
|
||
|
||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
||
// string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7);
|
||
// string productType = FindStringAfterColon(response, finalDefIdToFind);
|
||
// if (productType != null)
|
||
// {
|
||
// Console.WriteLine($"{finalDefIdToFind}: {productType}");
|
||
|
||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD>
|
||
|
||
|
||
|
||
// }
|
||
// else
|
||
// {
|
||
// Console.WriteLine($"FinalDefID {finalDefIdToFind} not found in response.");
|
||
// }
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// Console.WriteLine("Error occurred:");
|
||
// Console.WriteLine(ex.Message);
|
||
// }
|
||
|
||
|
||
|
||
sw.Stop();
|
||
Console.WriteLine("ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>i<EFBFBD><69>" + sw.ElapsedMilliseconds);
|
||
|
||
if (_runHandleBefore == null)
|
||
{
|
||
_runHandleBefore = new AutoResetEvent(false);
|
||
}
|
||
|
||
if (_runHandleAfter == null)
|
||
{
|
||
_runHandleAfter = new ManualResetEvent(false);
|
||
}
|
||
|
||
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");
|
||
|
||
string vBarPath = "D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\Lp\\202452414231.jpg";
|
||
string vCam1OnePath = "D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\Lp\\001.jpg";
|
||
string vCam1TwoPath = "D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\Lp\\002.jpg";
|
||
string vModelChangePath = "D:\\Hisence\\config\\chinese.json";
|
||
string LablePathstr = "D:\\Hisence\\ClassName.txt";//<2F><>ǩ·<C7A9><C2B7>
|
||
string LablePathButtonstr = "D:\\Hisence\\ClassNameButton.txt";//<2F><>ǩ·<C7A9><C2B7>
|
||
// Mat cameraMat = Cv2.ImRead(vCam1TwoPath);
|
||
//Defet_OnDetectionDone(cameraMat, DefetShow1);
|
||
// canvas1.ImagePath = vCam1TwoPath;
|
||
// DefetShow.ImaMAt = cameraMat;
|
||
if (File.Exists(LablePathButtonstr) && File.Exists(vBarPath) && File.Exists(vCam1OnePath) && File.Exists(vCam1TwoPath) && File.Exists(vModelChangePath))
|
||
{
|
||
|
||
BarPath = vBarPath;
|
||
Cam1OnePath = vCam1OnePath;
|
||
Cam1TwoPath = vCam1TwoPath;
|
||
ModelChangePath = vModelChangePath;
|
||
}
|
||
ifXZeroValue = XZerorbx.Checked;
|
||
ifYZeroValue = YZerorbx.Checked;
|
||
InitDevList();
|
||
this.WindowState = FormWindowState.Maximized;
|
||
|
||
string Dectionstr = "D:\\Hisence\\best.onnx";
|
||
string DectionButtonstr = "D:\\Hisence\\HisenceButton.onnx";
|
||
string CountryStr = "D:\\Hisence\\config\\chinese.json";
|
||
if (File.Exists(LablePathstr) && File.Exists(Dectionstr) && File.Exists(CountryStr) && File.Exists(DectionButtonstr))
|
||
{
|
||
LablePath = LablePathstr;
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD>" + Dectionstr + " " + CountryStr + " " + LablePathstr + "ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
simboObjectDetection.Load(Dectionstr, "CPU", "images", 640, 640);
|
||
simboObjectDetButton.Load(DectionButtonstr, "CPU", "images", 640, 640);
|
||
paddleOcrModelCountry.Load(CountryStr, "CPU");
|
||
paddleOcrModel.Load(CountryStr, "CPU");
|
||
IfChangeLanguage = CountryStr;
|
||
|
||
MLRequest req = new MLRequest();
|
||
string path = "D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\12\\202461417146451.jpg";
|
||
req.currentMat = Cv2.ImRead(path);
|
||
|
||
string BarT = DetMachineBar(ref req);
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
StartDecBtn.Enabled = false;
|
||
|
||
myDelegateUI = new MyDelegateUI(initAll);//<2F><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF>
|
||
|
||
|
||
myPosDelegateUI = new MyPosDelegateUI(initAll2);//<2F><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF>
|
||
|
||
myLogDelegateUI = new MyLogDelegateUI(initAll3);//<2F><><EFBFBD><EFBFBD>ί<EFBFBD><CEAF>
|
||
|
||
Scanner.Strart();
|
||
Scanner.OnClientDataReceived -= OnDataReceived;
|
||
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);
|
||
//<2F><>ʼ<EFBFBD><CABC>PLC
|
||
melsecPLCTCPDriver.Start();
|
||
|
||
melsecPLCTCPDriver.Heartbeat -= PLcHeratAdress;
|
||
melsecPLCTCPDriver.Heartbeat += PLcHeratAdress;
|
||
|
||
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>
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);//<2F>̵<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><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><>
|
||
//t.Enabled = true;//<2F>Ƿ<EFBFBD>ִ<EFBFBD><D6B4>System.Timers.Timer.Elapsed<65>¼<EFBFBD><C2BC><EFBFBD>
|
||
//t.Start(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||
|
||
}
|
||
public void Execute(object source, System.Timers.ElapsedEventArgs e)
|
||
{
|
||
|
||
t.Stop(); //<2F>ȹرն<D8B1>ʱ<EFBFBD><CAB1>
|
||
//melsecPLCTCPDriver.WriteInt("548", 1);
|
||
//Thread.Sleep(1000);
|
||
//melsecPLCTCPDriver.WriteInt("548", 0);
|
||
//myLog("д" + WriteAdress.Text.ToString() + "<22><><EFBFBD><EFBFBD>", DateTime.Now);
|
||
MessageBox.Show("OK!");
|
||
t.Start(); //ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD>Ϻ<EFBFBD><CFBA>ٿ<EFBFBD><D9BF><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
|
||
|
||
private string DetMachineBar(ref MLRequest req)
|
||
{
|
||
|
||
// req.currentMat = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\Lp\\202453015229201.jpg");
|
||
MLResult mL = paddleOcrModelCountry.RunInferenceFixed(req);
|
||
// DisplayResult(mL);
|
||
|
||
//<2F><><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||
string IOcrBAr = string.Empty;
|
||
string[] BarListOne = new string[10];
|
||
int Ypos = 0;
|
||
int mid = 9999999;
|
||
for (int v = 0; v < Enumerable.Count<DetectionResultDetail>(mL.ResultDetails); v++)
|
||
{
|
||
if (mL.ResultDetails.Count() > 0)
|
||
{
|
||
int Pos = mL.ResultDetails[v].Rect.Y;
|
||
if (Pos < mid)
|
||
{
|
||
mid = Pos;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
for (int v = 0; v < Enumerable.Count<DetectionResultDetail>(mL.ResultDetails); v++)
|
||
{
|
||
if (mL.ResultDetails.Count() > 0)
|
||
{
|
||
int Pos = mL.ResultDetails[v].Rect.Y;
|
||
|
||
|
||
|
||
if (Math.Abs(Pos - mid) < 80)
|
||
{
|
||
string iv = mL.ResultDetails[v].LabelDisplay;
|
||
string result = Regex.Replace(iv, "[ \\[ \\] \\^ \\-_*<2A><><EFBFBD>D<EFBFBD>D(^)$%~!@#$<24><>&%<25><><EFBFBD><EFBFBD>+=<><3E><><EFBFBD><EFBFBD>!<21><>??<3F><>:<3A><>?`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,.;/\"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-]", "");
|
||
|
||
IOcrBAr += result;
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
}
|
||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪBAr
|
||
return IOcrBAr;
|
||
|
||
}
|
||
private void initAll() //<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
//richTextBox1.AppendText("TEST line \r");
|
||
if (HspeedList.Count == 33)
|
||
{
|
||
|
||
lnEditmiXHS.Text = HspeedList[1].ToString();
|
||
lnEditmiYHS.Text = HspeedList[6].ToString();
|
||
lnEditmiZHS.Text = HspeedList[11].ToString();
|
||
//<2F><>λ<EFBFBD>ٶ<EFBFBD>
|
||
lnEditmiXS.Text = HspeedList[0].ToString();
|
||
lnEditmiYS.Text = HspeedList[5].ToString();
|
||
lnEditmiZS.Text = HspeedList[10].ToString();
|
||
}
|
||
if (disShow != 0)
|
||
{
|
||
//TODOʵʱ<CAB5><CAB1>ʽ ֪<><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
|
||
double disreal = disShow * (-0.54054) + 1324.3232;
|
||
DistanceShow.Text = Math.Ceiling(disreal).ToString();
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һԪһ<D4AA><D2BB><EFBFBD><EFBFBD>
|
||
//y = -0.54054x + 1324.3232
|
||
|
||
}
|
||
}
|
||
private void initAll2() //<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
if (relPosStrList.Count == 31)
|
||
{
|
||
|
||
|
||
// XPostion.Text = "";
|
||
XPostion.Text = relPosStrList[0].ToString();
|
||
//YPostion.Text = "";
|
||
YPostion.Text = relPosStrList[5].ToString();
|
||
// ZPostion.Text = "";
|
||
ZPostion.Text = relPosStrList[10].ToString();
|
||
|
||
}
|
||
}
|
||
string Logtxt = "";
|
||
private void initAll3() //<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
richTextBox1.AppendText(Logtxt);
|
||
AllDSum.Text = AllDsums.ToString();
|
||
OKDNum.Text = OKDsums.ToString();
|
||
NGDNum.Text = NGDsums.ToString();
|
||
textBox1.Text = WUsums.ToString();
|
||
textBox4.Text = WAIsums.ToString();
|
||
using (StreamWriter stream = new StreamWriter("D://information.log", true))
|
||
{
|
||
stream.WriteLine(Logtxt);
|
||
stream.Flush();
|
||
}
|
||
}
|
||
|
||
private void OnSpeedShow()
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
while (true)
|
||
{
|
||
try
|
||
{
|
||
UpDatePlcValue(600, 2);
|
||
//<2F><>404 <20><>ַ <20><>33<33><33><EFBFBD><EFBFBD>ַ
|
||
UpDatePlcValue(404, 33);
|
||
if (HspeedList.Count == 33)
|
||
{
|
||
|
||
//<2F>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
|
||
|
||
this.Invoke(myDelegateUI); //richTextBox1.AppendText("TEST line \r");
|
||
Application.DoEvents();
|
||
}
|
||
if (disShow != 0)
|
||
{
|
||
this.Invoke(myDelegateUI); //richTextBox1.AppendText("TEST line \r");
|
||
Application.DoEvents();
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
|
||
Thread.Sleep(200);
|
||
}
|
||
});
|
||
}
|
||
|
||
private void OnPostionShow()
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
while (true)
|
||
{
|
||
try
|
||
{
|
||
UpDatePlcValue(102, 31);
|
||
if (relPosStrList.Count == 31)
|
||
{
|
||
this.Invoke(myPosDelegateUI); //richTextBox1.AppendText("TEST line \r");
|
||
Application.DoEvents();
|
||
|
||
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
|
||
|
||
Thread.Sleep(200);
|
||
}
|
||
});
|
||
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void CamOpenBtn_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
|
||
Cam1.Start("Cam1");
|
||
|
||
bnGetParam.Enabled = true;
|
||
SetCtrlWhenOpen();
|
||
Cam1OpenBtn.BackColor = Color.Green;
|
||
|
||
}
|
||
private void SetCtrlWhenOpen()
|
||
{
|
||
|
||
|
||
tbExposure.Enabled = true;
|
||
tbGain.Enabled = true;
|
||
// tbFrameRate.Enabled = true;
|
||
bnGetParam.Enabled = true;
|
||
bnSetParam.Enabled = true;
|
||
}
|
||
private void bnGetParam_Click(object sender, EventArgs e)
|
||
{
|
||
// tbExposure.Text = Cam1.dvpGetExposure().ToString();
|
||
// tbGain.Text = Cam1.dvpGetAnalogGain().ToString();
|
||
|
||
}
|
||
|
||
private void bnGetParam2_Click(object sender, EventArgs e)
|
||
{
|
||
//tbExposure2.Text = Cam1.dvpGetExposure().ToString();
|
||
//tbGain2.Text = Cam1.dvpGetAnalogGain().ToString();
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Cam2OpenBtn_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
// Cam2.Start("Cam2");
|
||
// bnGetParam2.Enabled = true;
|
||
// Cam2OpenBtn.BackColor = Color.Green;
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
Cam1.Stop();
|
||
SetCtrlWhenClose();
|
||
}
|
||
private void SetCtrlWhenClose()
|
||
{
|
||
|
||
tbExposure.Enabled = false;
|
||
tbGain.Enabled = false;
|
||
// tbFrameRate.Enabled = false;
|
||
bnGetParam.Enabled = false;
|
||
bnSetParam.Enabled = false;
|
||
|
||
}
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
Cam2.Stop();
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void SnapshotCam1_Click(object sender, EventArgs e)
|
||
{
|
||
Cam1.Snapshot();
|
||
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void SnapshotCam2_Click(object sender, EventArgs e)
|
||
{
|
||
//Cam2.Snapshot();
|
||
}
|
||
int TimesCalled = 0;
|
||
Bitmap OKbitmap = new Bitmap("OK.jpg");
|
||
Bitmap NGbitmap = new Bitmap("NG.jpg");
|
||
Mat OKMat = Cv2.ImRead("OK.jpg");
|
||
Mat NGMat = Cv2.ImRead("OK.jpg");
|
||
Mat whiteMat = Cv2.ImRead("white.jpg");
|
||
/// <summary>
|
||
/// <20><><EFBFBD>̵߳<DFB3><CCB5><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void InitMachine_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
meachineState = MeachineState.machine_opening;//״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>OPen
|
||
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
||
//dataGridView1.DataSource = dataSet.Tables[0];
|
||
|
||
Cam1.Start("Cam1");
|
||
if (Cam1.IfSuccess)
|
||
{
|
||
myLog("Cam1<6D><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
//Cam2.Start("Cam2");
|
||
//if (Cam2.IfSuccess)
|
||
//{
|
||
// myLog("Cam2<6D><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", DateTime.Now);
|
||
//}
|
||
Cam1.OnHImageOutput -= OnCameraMatOutPut;
|
||
Cam1.OnHImageOutput += OnCameraMatOutPut;
|
||
//Cam2.OnHImageOutput -= OnCameraMatOutPut2;
|
||
// Cam2.OnHImageOutput += OnCameraMatOutPut2;
|
||
|
||
OKOrNGShow.Image = OKbitmap;
|
||
//<2F><>ʼ<EFBFBD><CABC>ɨ<EFBFBD><C9A8>ǹ
|
||
|
||
|
||
//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("426", 10000);
|
||
melsecPLCTCPDriver.WriteInt("404", 100000); //д<>붨λ<EBB6A8>ٶ<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("414", 10000);
|
||
melsecPLCTCPDriver.WriteInt("424", 10000);
|
||
|
||
|
||
melsecPLCTCPDriver.WriteInt("500", 0);
|
||
|
||
melsecPLCTCPDriver.WriteInt("500", 1);
|
||
Thread.Sleep(200);
|
||
|
||
bOn = true;
|
||
melsecPLCTCPDriver.WriteInt("580", 0);//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("580", 1);//<2F><><EFBFBD><EFBFBD>
|
||
Thread.Sleep(200);
|
||
melsecPLCTCPDriver.WriteInt("580", 0);
|
||
Thread.Sleep(200);
|
||
melsecPLCTCPDriver.WriteInt("550", 0);
|
||
while (true)
|
||
{
|
||
int IfXZeros = melsecPLCTCPDriver.ReadInt("102");
|
||
int IfYZeros = melsecPLCTCPDriver.ReadInt("112");
|
||
int IfZZeros = melsecPLCTCPDriver.ReadInt("122");
|
||
if (IfXZeros <= 140 && IfYZeros <= 140 && IfZZeros <= 140)
|
||
{
|
||
StartDecBtn.Enabled = true;
|
||
break;
|
||
}
|
||
Thread.Sleep(10);
|
||
}
|
||
|
||
|
||
|
||
myLog("<22>豸ȫ<E8B1B8><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", DateTime.Now);
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Application_ThreadException(ex);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// ȫͼϴ<CDBC>»<EFBFBD> <20>ü<EFBFBD>֮<EFBFBD><D6AE> OCRʶ<52><CAB6><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="currentMatC">ȫͼͼƬ</param>
|
||
/// <param name="cam1TwoML">ȫ<><C8AB>ͼƬ<CDBC>ϵ<EFBFBD>Ŀ<EFBFBD>궨λ<EAB6A8><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ο<EFBFBD><CEBF><EFBFBD></param>
|
||
/// <param name="strMatListList"><3E><><EFBFBD>صĶ<D8B5>λ<EFBFBD><CEBB><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD></param>
|
||
private void InsertSqlRunData2(ref Mat currentMatC, MLResult cam1TwoML, ref List<string> strMatListList, ref PaddleOcrModel IOcrModel)
|
||
{
|
||
|
||
|
||
|
||
#if true
|
||
try
|
||
{
|
||
List<Mat> mats = new List<Mat>();
|
||
|
||
Mat mResultCut = currentMatC.Clone();
|
||
string OcrTextinsert = "";
|
||
for (int i = 0; i < cam1TwoML.ResultDetails.Count; i++)
|
||
{
|
||
Mat mResultCuti = mResultCut.Clone();
|
||
int rectsx = cam1TwoML.ResultDetails[i].Rect.X;
|
||
int rectsy = cam1TwoML.ResultDetails[i].Rect.Y;
|
||
int rectsWidth = cam1TwoML.ResultDetails[i].Rect.Width;
|
||
int rectsHeight = cam1TwoML.ResultDetails[i].Rect.Height;
|
||
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
|
||
Mat matroi = new Mat(mResultCuti, area);
|
||
mats.Add(matroi);
|
||
//OCRʶ<52><CAB6><EFBFBD>ü<EFBFBD>ͼƬ
|
||
MLRequest reqcut = new MLRequest();
|
||
reqcut.currentMat = matroi.Clone();
|
||
MLResult mLcut = paddleOcrModel.RunInference(reqcut);
|
||
|
||
|
||
for (int j = 0; j < mLcut.ResultDetails.Count; j++)
|
||
{
|
||
string jdetial = mLcut.ResultDetails[j].LabelDisplay;
|
||
string result = Regex.Replace(jdetial, "[ \\[ \\] \\^ \\-_*<2A><><EFBFBD>D<EFBFBD>D(^)$%~!@#$<24><>&%<25><><EFBFBD><EFBFBD>+=<><3E><><EFBFBD><EFBFBD>!<21><>??<3F><>:<3A><>?`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,.;/\"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-]", "");
|
||
|
||
|
||
strMatListList.Add(result);
|
||
OcrTextinsert += result + "##";
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
#endif
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>OCR<43>ı<EFBFBD><C4B1>Ƿ<EFBFBD><C7B7><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="WashBar"></param>
|
||
/// <param name="DetMatstrList"></param>
|
||
/// <returns></returns>
|
||
private bool IsMatchOcrText(string WashBar, List<string> DetMatstrList)
|
||
{
|
||
try
|
||
{
|
||
|
||
List<string> strMatListListB = new List<string>();
|
||
if (WashBar.Contains("##"))
|
||
{
|
||
|
||
string[] sArray = Regex.Split(WashBar, "##", RegexOptions.IgnoreCase);
|
||
|
||
|
||
for (int i = 0; i < sArray.Count(); i++)
|
||
{
|
||
if (sArray[i] != "")
|
||
{
|
||
strMatListListB.Add(sArray[i]);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
var firstNotSecond = DetMatstrList.Except(strMatListListB, StringComparer.OrdinalIgnoreCase).ToList();
|
||
var secondNotFirst = strMatListListB.Except(DetMatstrList, StringComparer.OrdinalIgnoreCase).ToList();
|
||
if (firstNotSecond.Count() == 0 && secondNotFirst.Count() == 0)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
private bool IsFuzzyMatchOcrText(string WashBar, List<string> DetMatstrList)
|
||
{
|
||
try
|
||
{
|
||
|
||
List<string> strMatListListB = new List<string>();
|
||
if (WashBar.Contains("##"))
|
||
{
|
||
|
||
string[] sArray = Regex.Split(WashBar, "##", RegexOptions.IgnoreCase);
|
||
|
||
|
||
for (int i = 0; i < sArray.Count(); i++)
|
||
{
|
||
if (sArray[i] != "")
|
||
{
|
||
strMatListListB.Add(sArray[i]);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
var firstNotSecond = DetMatstrList.Intersect(strMatListListB, StringComparer.OrdinalIgnoreCase).ToList();
|
||
//var secondNotFirst = strMatListListB.Except(DetMatstrList, StringComparer.OrdinalIgnoreCase).ToList();
|
||
if (firstNotSecond.Count() > (strMatListListB.Count) / 2)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// ʵʱ<CAB5>ƶ<EFBFBD>ģ<EFBFBD><C4A3>
|
||
/// </summary>
|
||
public void MoveToP(int currentXP, int currentYP, int currentZP)
|
||
{
|
||
|
||
melsecPLCTCPDriver.WriteInt("581", 0);
|
||
melsecPLCTCPDriver.WriteInt("402", currentXP);
|
||
melsecPLCTCPDriver.WriteInt("412", currentYP);
|
||
melsecPLCTCPDriver.WriteInt("422", currentZP);
|
||
melsecPLCTCPDriver.WriteInt("581", 1);
|
||
Thread.Sleep(200);
|
||
melsecPLCTCPDriver.WriteInt("581", 0);
|
||
while (true)
|
||
{
|
||
int IfXZeros = melsecPLCTCPDriver.ReadInt("102");
|
||
int IfYZeros = melsecPLCTCPDriver.ReadInt("112");
|
||
int IfZZeros = melsecPLCTCPDriver.ReadInt("122");
|
||
if ((IfXZeros < currentXP + 20) && (IfXZeros > currentXP - 20) && (IfYZeros <= currentYP + 20) && (IfYZeros >= currentYP - 20) && (IfZZeros <= currentZP + 20) && (IfZZeros >= currentZP - 20))//TODO:<3A><><EFBFBD>õ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||
{
|
||
|
||
break;
|
||
}
|
||
Thread.Sleep(10);
|
||
}
|
||
}
|
||
public int disShow = new int();
|
||
public List<int> MonitorValues { get; set; } = new List<int>();
|
||
public List<int> relPosStrList { get; set; } = new List<int>();
|
||
public List<int> HspeedList { get; set; } = new List<int>();
|
||
/// <summary>
|
||
/// ʵʱˢ<CAB1><CBA2>PLC<4C><43>ַ<EFBFBD><D6B7>ֵ
|
||
/// </summary>
|
||
///
|
||
public void UpDatePlcValue(int Address, int length)
|
||
{
|
||
//Task.Run(() =>
|
||
//{
|
||
// while (true)
|
||
// {
|
||
try
|
||
{
|
||
//ʵʱˢ<CAB1>»<EFBFBD>е<EFBFBD>ֵ<EFBFBD>λ<EFBFBD><CEBB>
|
||
List<int> newValues = melsecPLCTCPDriver.GetMonitorValues(Address, length);
|
||
if (newValues == null || newValues.Count == 0)
|
||
return;
|
||
|
||
Stopwatch sw = new Stopwatch();
|
||
sw.Start();
|
||
if (Address == 600)
|
||
{
|
||
disShow = melsecPLCTCPDriver.ReadInt(Convert.ToString(Address));
|
||
}
|
||
if (Address == 102) //<2F><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַΪ102
|
||
{
|
||
if (relPosStrList.Count == newValues.Count)
|
||
{
|
||
var tempNew = new List<int>(newValues);
|
||
var tempOld = new List<int>(relPosStrList);
|
||
//MonitorCheckAndInvoke(tempNew, tempOld);
|
||
}
|
||
relPosStrList = new List<int>(newValues);
|
||
// relPosStrList = MonitorValues;
|
||
//ʵʱ<CAB5><CAB1>ʾ<EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
if (Address == 404)
|
||
{
|
||
if (HspeedList.Count == newValues.Count)
|
||
{
|
||
var tempNew = new List<int>(newValues);
|
||
var tempOld = new List<int>(HspeedList);
|
||
//MonitorCheckAndInvoke(tempNew, tempOld);
|
||
}
|
||
HspeedList = new List<int>(newValues);
|
||
//HspeedList = MonitorValues;
|
||
//ʵʱ<CAB5><CAB1>ʾ<EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
sw.Stop();
|
||
|
||
if (sw.ElapsedMilliseconds > 20)
|
||
{
|
||
//LogAsync(DateTime.Now, LogLevel.Detail, $"{this.Name}<7D><>ѯʱ<D1AF>䣺{sw.ElapsedMilliseconds}");
|
||
}
|
||
Thread.Sleep(20);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
|
||
// }
|
||
//});
|
||
}
|
||
|
||
|
||
#region <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// <summary>
|
||
/// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="detectResult"></param>
|
||
private void DisplayResult(MLResult detectResult)
|
||
{
|
||
string displayTxt = "";
|
||
detectResult.ResultDetails.ForEach(d =>
|
||
{
|
||
displayTxt += $"{d.LabelName} score:{d.Score.ToString("f2")} area:{d.Area.ToString("f2")}\r\n";
|
||
});
|
||
|
||
var resultMask = detectResult.ResultMap;
|
||
//Clone(new Rectangle(0, 0, detectResult.VisionImageSet.DetectionResultImage.Width, detectResult.VisionImageSet.DetectionResultImage.Height), detectResult.VisionImageSet.DetectionResultImage.PixelFormat);
|
||
|
||
// List<IShapeElement> detectionResultShapes = new List<IShapeElement>(detectResult.DetectionResultShapes);
|
||
DetectResultDisplay resultDisplay = new DetectResultDisplay(detectResult.ResultDetails, resultMask, displayTxt);
|
||
// detectionResultShapes.Add(resultDisplay);
|
||
|
||
Graphics g = Graphics.FromImage(resultMask);
|
||
resultDisplay.Draw(g);
|
||
// resultMask.Save("D://save.png");
|
||
// var resultMap = GetResultImage(resultMask, detectionResultShapes);
|
||
}
|
||
#endregion
|
||
int YPos = 14957;
|
||
int ZPos = 1695;
|
||
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>
|
||
public void TriggerCameral2()
|
||
{
|
||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>̼߳<DFB3><CCBC><EFBFBD>PLC<4C><43>ֵ
|
||
Task.Run(() =>
|
||
{
|
||
try
|
||
{
|
||
int iNum1 = 0;
|
||
int iNum0 = 0;
|
||
int iNum3 = 0;
|
||
Thread.CurrentThread.Priority = ThreadPriority.Highest;
|
||
while (meachineState == MeachineState.machine_opening)
|
||
{
|
||
// myResetEvent.Set();
|
||
PLC548 = true;
|
||
int m_iCureent548 = melsecPLCTCPDriver.ReadInt("548");
|
||
|
||
if (m_iCureent548 != 0)
|
||
{
|
||
iNum0++;
|
||
}
|
||
else
|
||
{
|
||
iNum0 = 0;
|
||
}
|
||
if (iNum0 >= 1)
|
||
{
|
||
while (meachineState == MeachineState.machine_opening)
|
||
{
|
||
|
||
bTriger = false;
|
||
//<2F><><EFBFBD><EFBFBD>544һֱ<D2BB><D6B1>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>s <20><><EFBFBD><EFBFBD>
|
||
m_iCureent548 = melsecPLCTCPDriver.ReadInt("548");
|
||
if (m_iCureent548 == 0)
|
||
{
|
||
iNum1++;
|
||
}
|
||
else
|
||
{
|
||
iNum1 = 0;
|
||
iNum3++;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>û<EFBFBD>ﵽϴ<EFB5BD>»<EFBFBD><C2BB>ϵĴ<CFB5><C4B4><EFBFBD>
|
||
|
||
}
|
||
if (iNum1 >= 2)
|
||
{
|
||
//myLog("ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + iNum3, DateTime.Now);
|
||
if (!StopM)
|
||
{
|
||
melsecPLCTCPDriver.WriteInt("550", 1);//<2F><><EFBFBD><EFBFBD>
|
||
StopM = true;
|
||
|
||
}
|
||
if (bBar)
|
||
{
|
||
_runHandleBefore.WaitOne();
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ijɺͺ<C9BA><CDBA>ŵĶԽ<C4B6><D4BD><EFBFBD><EFBFBD><EFBFBD>
|
||
string OcrBar = "";
|
||
string FinalDefIDToFind = m_sKEYENCEBar;// Ŀ<><C4BF> FinalDefID
|
||
OcrBar = FormBarType(FinalDefIDToFind);
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
|
||
ScannerBox.Text = FinalDefIDToFind;
|
||
textBox3.Text = OcrBar;
|
||
|
||
}));
|
||
//myLog("ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + m_sKEYENCEBar, DateTime.Now);
|
||
//#if false
|
||
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>Pos<6F><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䳬ʱ
|
||
|
||
//#else
|
||
// OcrBar = "OZ.ϴ<>»<EFBFBD>.WF3G7014-NVW001CZA.WSG374A.<2E><>";
|
||
//#endif
|
||
// if(Oldm_sKEYENCEBar!= m_sKEYENCEBar)
|
||
|
||
|
||
if (OcrBar.IsNullOrEmpty())
|
||
{
|
||
myLog("Mesϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>" + m_sKEYENCEBar, DateTime.Now);
|
||
//break;
|
||
}
|
||
xKNow = GetModeFromBar(OcrBar);//<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>ֵ
|
||
|
||
|
||
|
||
|
||
//if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$"))
|
||
//{
|
||
|
||
// // myLog("<22>ͺ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ɹ<EFBFBD>" + xKNow.OcrBar, DateTime.Now);
|
||
|
||
|
||
//}
|
||
|
||
}
|
||
// Thread.Sleep(2);
|
||
bBar = false;
|
||
#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);
|
||
// Thread.Sleep(2000);//ɾ
|
||
|
||
|
||
|
||
List<int> DisList = new List<int>();
|
||
for (int i = 0; i < 5; i++)
|
||
{
|
||
int m600 = melsecPLCTCPDriver.ReadInt("600");
|
||
DisList.Add(m600);
|
||
}
|
||
DisList.Remove(DisList.Max());
|
||
DisList.Remove(DisList.Min());
|
||
// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>ֵ<EFBFBD><D6B5>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||
double average = DisList.Average();
|
||
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)
|
||
{
|
||
MoveToP(5815, YPos, ZPos + (int)(dismove));
|
||
}
|
||
|
||
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);
|
||
//}
|
||
|
||
// MoveToP(51043, YPos, ZPos + (int)(dismove));
|
||
//Cam1.Snapshot();
|
||
MoveToP(5815, YPos, ZPos);
|
||
//melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
|
||
|
||
|
||
|
||
//Thread.Sleep(1000);//ϴ<>»<EFBFBD><C2BB><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>ȥ
|
||
|
||
//if (xKNow != null)
|
||
//{
|
||
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
|
||
//}
|
||
myLog("<22>ɼ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ɹ<EFBFBD>", DateTime.Now);
|
||
//ģ<>鸴λ
|
||
|
||
bTriger = true;//<2F><><EFBFBD>Խ<EFBFBD><D4BD>м<EFBFBD><D0BC><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>
|
||
|
||
iNum0 = 0;
|
||
iNum1 = 0;
|
||
break;
|
||
}
|
||
#else
|
||
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);
|
||
Thread.Sleep(1000);//ɾ
|
||
|
||
|
||
|
||
//List<int> DisList = new List<int>();
|
||
//for (int i = 0; i < 5; i++)
|
||
//{
|
||
// int m600 = melsecPLCTCPDriver.ReadInt("600");
|
||
// DisList.Add(m600);
|
||
//}
|
||
//DisList.Remove(DisList.Max());
|
||
//DisList.Remove(DisList.Min());
|
||
//// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>ֵ<EFBFBD><D6B5>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||
//double average = DisList.Average();
|
||
//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 > 0 && dismove < 4000)
|
||
//{
|
||
// MoveToP(5815, YPos, ZPos + (int)(dismove));
|
||
//}
|
||
Thread.Sleep(1000);//ɾ
|
||
// Thread.Sleep(500);
|
||
Cam1.SnapshotCount = 0;
|
||
Cam1.Snapshot();
|
||
|
||
// Cam2.SnapshotCount = 0;
|
||
//Cam2.Snapshot();
|
||
IfCam2Triger = true;
|
||
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);
|
||
//if (xKNow != null)
|
||
//{
|
||
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
|
||
//}
|
||
myLog("<22>ɼ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ɹ<EFBFBD>", DateTime.Now);
|
||
//ģ<>鸴λ
|
||
|
||
bTriger = true;//<2F><><EFBFBD>Խ<EFBFBD><D4BD>м<EFBFBD><D0BC><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>
|
||
bBarTriger = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
iNum0 = 0;
|
||
iNum1 = 0;
|
||
break;
|
||
|
||
#endif
|
||
|
||
|
||
|
||
|
||
}
|
||
if (iNum3 >= 10)
|
||
{
|
||
melsecPLCTCPDriver.WriteInt("550", 1);//<2F><><EFBFBD><EFBFBD>
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
Thread.Sleep(10);
|
||
|
||
|
||
}
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
|
||
}
|
||
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// PLC<4C><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="ifPlcHeart"></param>
|
||
public void PLcHeratAdress(int ifPlcHeart)
|
||
{
|
||
if (ifPlcHeart == 1)
|
||
{
|
||
txtSetValue.Text = "PLC<4C><43><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>" + " ʱ<>䣺" + DateTime.Now.ToString();
|
||
myLog("PLC<4C><43><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>", DateTime.Now);
|
||
PLCPowerON.BackColor = Color.Red;
|
||
}
|
||
else
|
||
{
|
||
PLCPowerON.BackColor = Color.Green;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <20><>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB>
|
||
/// </summary>
|
||
/// <param name="dt"></param>
|
||
/// <param name="cameraMat"></param>
|
||
/// <param name="SnapshotCount"></param>
|
||
public void OnCameraMatOutPut(DateTime dt, Mat cameraMat, int SnapshotCount)
|
||
{
|
||
string fitImageFolder = "D://cam1//";
|
||
if (!Directory.Exists(fitImageFolder))
|
||
{
|
||
Directory.CreateDirectory(fitImageFolder);
|
||
}
|
||
|
||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if (SnapshotCount == 1)
|
||
{
|
||
|
||
|
||
// Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\1\\001.jpg"); ;
|
||
Cam1ImgOne = cameraMat;
|
||
IfCam1OneTriger = true;
|
||
originMatShow.Image = cameraMat.ToBitmap();
|
||
//pictureBox1.Image = cameraMat.ToBitmap();
|
||
_runHandleAfter.Set();
|
||
_runThreadFormtype.Set();
|
||
|
||
}
|
||
//<2F>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if (SnapshotCount == 2)
|
||
{
|
||
|
||
Cam1ImgTwo = Cv2.ImRead("D:\\Hisence\\<5C><><EFBFBD><EFBFBD>\\1\\002.jpg");
|
||
//Cam1ImgTwo = cameraMat;
|
||
|
||
IfCam1TwoTriger = true;
|
||
//originMatShow2.Image = cameraMat.ToBitmap();
|
||
|
||
}
|
||
string SN = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 1);
|
||
string pathfile = fitImageFolder + SN + ".jpg";
|
||
//CamShow1.ImaMAt = cameraMat;
|
||
cameraMat.ImWrite(pathfile);
|
||
CheckDiffSciHelper1.ResizeImage(pathfile, pathfile, 640, 480, 75);
|
||
}
|
||
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
||
/// </summary>
|
||
/// <param name="dt"></param>
|
||
/// <param name="cameraMat"></param>
|
||
/// <param name="SnapshotCount"></param>
|
||
|
||
public volatile int AllDsums = 0;
|
||
public volatile int NGDsums = 0;
|
||
public volatile int OKDsums = 0;
|
||
public volatile int WUsums = 0;
|
||
public volatile int WAIsums = 0;
|
||
/// <summary>
|
||
/// <20><>ʼʶ<CABC><CAB6>
|
||
/// </summary>
|
||
///
|
||
public void ReadyDetect()
|
||
{
|
||
_ = Task.Run((Action)(() =>
|
||
{
|
||
Thread.CurrentThread.Priority = ThreadPriority.Highest;
|
||
while (true)
|
||
{
|
||
try
|
||
{
|
||
//<2F>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʹ<>䲻<EFBFBD><E4B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD>˸
|
||
_runHandleAfter.WaitOne();
|
||
//melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
|
||
//2<><32>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
//if (IfCam2Triger)
|
||
//{
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ȶ<EFBFBD>
|
||
_runHandleAfter.Reset();
|
||
//if (xKNow == null)
|
||
//{
|
||
// myLog("δƥ<CEB4><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", DateTime.Now);
|
||
// break;
|
||
//}
|
||
|
||
//if (xKNow.OcrBar == null)
|
||
//{
|
||
// myLog("δƥ<CEB4><C6A5><EFBFBD>ɹ<EFBFBD>" + xKNow.OcrBar, DateTime.Now);
|
||
// myLog("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>", DateTime.Now);
|
||
// Insert_auto(true, Cam1ImgOne, m_sKEYENCEBar, 8974, 0, 0);
|
||
|
||
// break;
|
||
//}
|
||
|
||
|
||
if (m_sKEYENCEBar != null)
|
||
{
|
||
if (xKNow == null)
|
||
{
|
||
myLog("<22><><EFBFBD>ݿ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>" + m_sKEYENCEBar, DateTime.Now);
|
||
myLog("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>", DateTime.Now);
|
||
Insert_auto(true, Cam1ImgOne, m_sKEYENCEBar, 8974, 0, 0);
|
||
Thread.Sleep(2000);
|
||
OcrBar = FormBarType(m_sKEYENCEBar);
|
||
xKNow = GetModeFromBar(OcrBar); // <20><><EFBFBD>»<EFBFBD>ȡ
|
||
if (xKNow != null)
|
||
{
|
||
myLog("<22><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>", DateTime.Now);
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
}
|
||
bool MatchStr = false;
|
||
if (xKNow != null)
|
||
{
|
||
string IOcrBAr = xKNow.OcrBar;
|
||
//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>ֵ
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ijɺͺ<C9BA><CDBA>ŵĶԽ<C4B6><D4BD><EFBFBD><EFBFBD><EFBFBD>
|
||
IfCam1TwoTriger = false;
|
||
|
||
|
||
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
||
if (xkWordList.Count() == 1)
|
||
{
|
||
xK_HisenceSQLWord = xkWordList[0];
|
||
}
|
||
|
||
if (xKNow.Detect != "")
|
||
{
|
||
|
||
myLog("<22>ͺ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ɹ<EFBFBD>" + IOcrBAr, DateTime.Now);
|
||
|
||
}
|
||
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF>Խ<EFBFBD><D4BD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>ƶ<EFBFBD>
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺź<CDBA><C5BA>ϴε<CFB4><CEB5>ͺ<EFBFBD>һ<EFBFBD><D2BB> <20>Ͳ<EFBFBD><CDB2>û<EFBFBD>ʶ<EFBFBD><CAB6>ģ<EFBFBD><C4A3>ll
|
||
|
||
|
||
|
||
//}
|
||
//<2F><><EFBFBD><EFBFBD>1<EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// if (IfCam1TwoTriger && bBarTriger)
|
||
//{
|
||
|
||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||
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_MatchDet.TwoIFWhile = xK_HisenceSQLWord.TwoIFWhile;
|
||
AllDsums++;
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
MLRequest req = new MLRequest();
|
||
req.currentMat = Cam1ImgOne;
|
||
req.ResizeWidth = 640;
|
||
req.ResizeHeight = 640;
|
||
req.Score = 0.3f;
|
||
req.in_lable_path = LablePath;//<2F><>ǩ·<C7A9><C2B7>
|
||
req.confThreshold = 0.3f;//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD>
|
||
req.iouThreshold = 0.4f;//<2F><><EFBFBD><EFBFBD>IOU
|
||
req.out_node_name = "output";
|
||
MLResult mL = simboObjectDetection.RunInferenceFixed(req);
|
||
MLResult mLButton = simboObjectDetButton.RunInferenceFixed(req);
|
||
|
||
DateTime dt = DateTime.Now;
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>еĿ<D0B5><C4BF>ü<EFBFBD> ʶ<><CAB6><EFBFBD>ַ<EFBFBD><D6B7>Ա<EFBFBD><D4B1>ַ<EFBFBD><D6B7><EFBFBD>
|
||
List<string> strMatListOne = new List<string>();
|
||
List<string> strMatFuzzyListOne = new List<string>();
|
||
Mat mResultCut = req.currentMat.Clone();
|
||
|
||
if (mL.ResultMap != null)
|
||
{
|
||
string SN = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 1);
|
||
string filepath = "D://rect//" + SN + "result.jpg";
|
||
mL.ResultMap.Save(filepath);
|
||
ResultMatShow.Image = mL.ResultMap;
|
||
CheckDiffSciHelper1.ResizeImage(filepath, filepath, 640, 480, 75);
|
||
|
||
}
|
||
|
||
|
||
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(",");
|
||
|
||
MLResult MLsum = mL;
|
||
//for (int i = 0; i < mL2.ResultDetails.Count; i++)
|
||
//{
|
||
// MLsum.ResultDetails.Add((DetectionResultDetail)mL2.ResultDetails[i]);
|
||
//}
|
||
|
||
string[] RealCFLabels = new string[MLsum.ResultDetails.Count];
|
||
|
||
for (int i = 0; i < MLsum.ResultDetails.Count; i++)
|
||
{
|
||
RealCFLabels[i] = MLsum.ResultDetails[i].LabelName;
|
||
|
||
|
||
}
|
||
|
||
RealCFLabels = RealCFLabels.Distinct().ToArray();//ȥ<><C8A5>
|
||
string detstr = string.Join(",", RealCFLabels); //<2F><><EFBFBD><EFBFBD>Ϊabc-def-ghi <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-,Ҳ<><D2B2><EFBFBD><EFBFBD>ʡ
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ȶԿ<C8B6>
|
||
|
||
MatchStr = listLabels.SequenceEqual(RealCFLabels);
|
||
if (MatchStr == false)
|
||
|
||
{
|
||
WAIsums++;
|
||
}
|
||
#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)
|
||
{
|
||
//<2F>жϿ<D0B6>ֵ<EFBFBD>Ƿ<EFBFBD><C7B7>к<EFBFBD><D0BA><EFBFBD>ƥ<EFBFBD><C6A5>false
|
||
bool containsFalseValue = keyValueResult.ContainsValue(false);
|
||
|
||
if (containsFalseValue)
|
||
MatchStr = false;
|
||
|
||
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MatchStr = true;
|
||
}
|
||
///ִ<>бȶ<D0B1> Сͼ
|
||
//bool MatchStr = ManagerModelHelper.IsMatchSQLText(ref mCut, ref xK_HisenceSQLWord, ref xK_MatchDet);
|
||
|
||
|
||
|
||
if (MatchStr)
|
||
{
|
||
|
||
OKDsums++;
|
||
myLog("ƥ<><C6A5><EFBFBD>ɹ<EFBFBD>", DateTime.Now);
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||
// InsertXK_HisenceWordMatchData(xK_MatchDet, true);
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
OKOrNGShow.Image = OKbitmap;
|
||
}));
|
||
melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
|
||
|
||
}
|
||
else
|
||
{
|
||
|
||
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 1);//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);//<2F>Ƶ<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);//<2F>̵<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(WaringAdress, 1);//<2F><><EFBFBD><EFBFBD>
|
||
|
||
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>NGϴ<47>»<EFBFBD>
|
||
DialogResult dr = MessageBox.Show("<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>죿", "<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||
if (dr == DialogResult.OK)
|
||
{
|
||
|
||
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//<2F>̵<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("550", 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;
|
||
}));
|
||
myLog("ƥ<><C6A5>ʧ<EFBFBD><CAA7>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
NGDsums++;
|
||
|
||
melsecPLCTCPDriver.WriteInt(WaringAdress, 0);//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(RedLightingAdress, 0);//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//<2F>̵<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("550", 0);//<2F><><EFBFBD><EFBFBD>
|
||
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
OKOrNGShow.Image = NGbitmap;
|
||
}));
|
||
myLog("ƥ<><C6A5><EFBFBD>ɹ<EFBFBD>", DateTime.Now);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
//}
|
||
|
||
}
|
||
|
||
finally
|
||
{
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
Thread.Sleep(10);
|
||
}
|
||
|
||
}));
|
||
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>
|
||
/// </summary>
|
||
public void ThreadPost()
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
while (true)
|
||
{
|
||
|
||
_runThreadFormtype.WaitOne();
|
||
GetTypeFromPost();
|
||
|
||
}
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>л<EFBFBD>ȡ<EFBFBD>ͺ<EFBFBD>
|
||
/// </summary>
|
||
/// <param name="SkBar"></param>
|
||
/// <returns></returns>
|
||
public XKHisence GetModeFromBar(string SkBar)
|
||
{
|
||
//<2F><>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
DataSet ds = SQLiteHelper.Query($"select * from XK_Hisence where OCRBar='{SkBar}' ");
|
||
|
||
|
||
|
||
|
||
XKHisence XK_hisence = new XKHisence();
|
||
|
||
//cbx.DataSource = ds;
|
||
DataTableReader rdr = ds.CreateDataReader();
|
||
|
||
//autxRecords = new List<AuxRecord>();
|
||
|
||
|
||
|
||
|
||
//cbx.Rows.Clear();
|
||
while (rdr.Read())//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
{
|
||
|
||
// xKOCROfficeWord.ID = (int)rdr["ID"];
|
||
XK_hisence.Type = (string)rdr["Type"];
|
||
XK_hisence.OcrBar = (string)rdr["OcrBar"];
|
||
XK_hisence.MoveX = (int)rdr["MoveX"];
|
||
XK_hisence.MoveY = (int)rdr["MoveY"];
|
||
XK_hisence.MoveZ = (int)rdr["MoveZ"];
|
||
XK_hisence.Detect = (string)rdr["Detect"];
|
||
XK_hisence.OcrText = (string)rdr["OcrText"];
|
||
XK_hisence.MoveTwoX = (int)rdr["MoveTwoX"];
|
||
XK_hisence.MoveTwoY = (int)rdr["MoveTwoY"];
|
||
XK_hisence.MoveTwoZ = (int)rdr["MoveTwoZ"];
|
||
XK_hisence.OcrParm = (string)rdr["OcrParm"];
|
||
XK_hisence.Language = (string)rdr["Language"];
|
||
XK_hisence.FuzzyOcrText = (string)rdr["FuzzyOcrText"];
|
||
//xKHisences.Add(XK_hisence);
|
||
return XK_hisence;
|
||
//additem(XK_hisence);
|
||
|
||
|
||
}
|
||
return null;
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="data"></param>
|
||
public void OnDataReceived(byte[] data)
|
||
{
|
||
//
|
||
if (data.Length > 10)
|
||
{
|
||
m_sKEYENCEBar = string.Empty;
|
||
m_sKEYENCEBar = System.Text.Encoding.UTF8.GetString(data);
|
||
// myLog("<22>ͺ<EFBFBD>Ocr" + m_sKEYENCEBar, DateTime.Now);
|
||
_runHandleBefore.Set();
|
||
bBar = true;
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// PLC<4C>ij<EFBFBD>ʼ<EFBFBD><CABC>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void button4_Click(object sender, EventArgs e)
|
||
{
|
||
melsecPLCTCPDriver.Start();
|
||
myLog("<22><><EFBFBD><EFBFBD>PLC<4C>ɹ<EFBFBD>", DateTime.Now);
|
||
}
|
||
/// <summary>
|
||
/// <20><>־
|
||
/// </summary>
|
||
/// <param name="txt"></param>
|
||
/// <param name="date"></param>
|
||
private void myLog(string txt, DateTime date)
|
||
{
|
||
Logtxt = txt + " ʱ<>䣺" + date.ToString() + "\n";
|
||
this.Invoke(myLogDelegateUI); //richTextBox1.AppendText("TEST line \r");
|
||
Application.DoEvents();
|
||
}
|
||
private void readAdress_Click(object sender, EventArgs e)
|
||
{
|
||
if (Regex.IsMatch(readPLc.Text.ToString(), @"^[0-9]+$"))
|
||
{
|
||
int m_iCureent545 = melsecPLCTCPDriver.ReadInt(readPLc.Text.ToString());
|
||
showPLC.Text = m_iCureent545.ToString();
|
||
myLog("<22><>ȡ" + readPLc.Text.ToString() + "<22><><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
|
||
}
|
||
|
||
private void wirteAdress_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (Regex.IsMatch(WriteAdress.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(PLCValue.Text.ToString(), @"^[0-9]+$"))
|
||
{
|
||
melsecPLCTCPDriver.WriteInt(WriteAdress.Text.ToString(), Convert.ToInt16(PLCValue.Text));
|
||
myLog("д" + WriteAdress.Text.ToString() + "<22><><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
|
||
|
||
}
|
||
catch (Exception ex) { }
|
||
|
||
}
|
||
|
||
private void ScanDevList_Click(object sender, EventArgs e)
|
||
{
|
||
InitDevList();
|
||
}
|
||
|
||
|
||
private void PLCPowerON_Click(object sender, EventArgs e)
|
||
{
|
||
if (bOn == true)
|
||
{
|
||
melsecPLCTCPDriver.WriteInt("500", 0);
|
||
// PLCcontrol->WritePlc(500, 0);
|
||
bOn = false;
|
||
PLCPowerON.Text = "ʹ<><CAB9>On";
|
||
myLog("<22><>ʹ<EFBFBD><CAB9>", DateTime.Now);
|
||
PLCPowerON.BackColor = Color.Red;
|
||
}
|
||
else
|
||
{
|
||
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", 8000);
|
||
melsecPLCTCPDriver.WriteInt("426", 10000);
|
||
melsecPLCTCPDriver.WriteInt("404", 100000); //д<>붨λ<EBB6A8>ٶ<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("414", 8000);
|
||
melsecPLCTCPDriver.WriteInt("424", 10000);
|
||
|
||
|
||
melsecPLCTCPDriver.WriteInt("500", 0);
|
||
|
||
melsecPLCTCPDriver.WriteInt("500", 1);
|
||
melsecPLCTCPDriver.WriteInt("500", 1);
|
||
bOn = true;
|
||
PLCPowerON.Text = "ʹ<><CAB9>Off";
|
||
PLCPowerON.BackColor = Color.Green;
|
||
myLog("<22><>ʹ<EFBFBD><CAB9>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
|
||
bool IfPLCDiskZero = false;
|
||
bool IfPLCPostion = false;
|
||
private void PLCDiskZero_Click(object sender, EventArgs e)
|
||
{
|
||
//if (!IfPLCDiskZero)
|
||
//{
|
||
melsecPLCTCPDriver.WriteInt("580", 0);
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("580", 1);
|
||
|
||
Thread.Sleep(200);
|
||
melsecPLCTCPDriver.WriteInt("580", 0);
|
||
IfPLCDiskZero = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("580<38><30>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
//}
|
||
//else
|
||
//{
|
||
// melsecPLCTCPDriver.WriteInt("580", 0);
|
||
// IfPLCDiskZero = false;
|
||
// this.txtSetValue.Text = "0";
|
||
// myLog("580ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
//}
|
||
}
|
||
|
||
private void PLCPostion_Click(object sender, EventArgs e)
|
||
{
|
||
//if (!IfPLCPostion)
|
||
//{
|
||
|
||
|
||
|
||
try
|
||
{
|
||
if (Regex.IsMatch(lnEditmiXOP.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(lnEditmiYOP.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(lnEditmiZOP.Text.ToString(), @"^[0-9]+$"))
|
||
{
|
||
if (lnEditmiXOP.Text != "" && lnEditmiYOP.Text != "" && lnEditmiZOP.Text != "")
|
||
{
|
||
//ͨ<><CDA8><EFBFBD><EFBFBD>ȡ<EFBFBD>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ <20><>ΪĿ<CEAA><C4BF>λ<EFBFBD><CEBB>
|
||
int iXTPosition = Convert.ToInt16(lnEditmiXOP.Text); //<2F><>λX<CEBB><58>λ<EFBFBD><CEBB>
|
||
int iYTPosition = Convert.ToInt16(lnEditmiYOP.Text);
|
||
int iZTPosition = Convert.ToInt16(lnEditmiZOP.Text);
|
||
|
||
//<2F><>Ҫ<EFBFBD><D2AA>λ<EFBFBD><CEBB>λ<EFBFBD><CEBB>д<EFBFBD><D0B4>
|
||
melsecPLCTCPDriver.WriteInt("402", iXTPosition);
|
||
melsecPLCTCPDriver.WriteInt("412", iYTPosition);
|
||
melsecPLCTCPDriver.WriteInt("422", iZTPosition);
|
||
|
||
string logs = "д<>붨λλ<CEBB><CEBB> X" + iXTPosition + "Y:" + iYTPosition + "Z:" + iZTPosition + " ";
|
||
myLog(logs, DateTime.Now);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
melsecPLCTCPDriver.WriteInt("581", 1);
|
||
Thread.Sleep(1000);
|
||
melsecPLCTCPDriver.WriteInt("581", 0);
|
||
IfPLCPostion = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("XYZ<59><5A>ʼ<EFBFBD><CABC>λ581", DateTime.Now);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
//}
|
||
//else
|
||
//{
|
||
// melsecPLCTCPDriver.WriteInt("581", 0);
|
||
// IfPLCPostion = false;
|
||
// this.txtSetValue.Text = "0";
|
||
// myLog("XYZֹͣ581", DateTime.Now);
|
||
//}
|
||
}
|
||
|
||
|
||
|
||
private void StartDecBtn_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
//string path22 = "D:\\Hisence\\test2\\002.jpg";
|
||
//Mat pathmat2 = Cv2.ImRead(path22);
|
||
//string path222 = "D:\\Hisence\\test2\\001.jpg";
|
||
//Rect rect1 = new Rect(1929, 745, 396, 377);
|
||
|
||
|
||
//CheckDiffSciHelper.CheckDiffSci(path222, pathmat2, rect1, rect1, 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//test2");
|
||
|
||
|
||
|
||
// OnGetBar();
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 1);//<2F>̵<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);//<2F>Ƶ<EFBFBD>
|
||
|
||
meachineState = MeachineState.machine_opening;
|
||
TriggerCameral2();//<2F><><EFBFBD>紥<EFBFBD><E7B4A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>SN<53><4E>ȡ<EFBFBD>ͺ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>еõ<D0B5><C3B5><EFBFBD>ֵ
|
||
ReadyDetect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||
|
||
//ThreadPost();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>յ<EFBFBD><D5B5>ͺ<EFBFBD>
|
||
myLog("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳ɹ<CCB3>", DateTime.Now);
|
||
}
|
||
|
||
private void RefeshData_Click(object sender, EventArgs e)
|
||
{
|
||
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
||
//dataGridView1.DataSource = dataSet.Tables[0];
|
||
}
|
||
|
||
private void panel8_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void SetHandleSpeed_Click(object sender, EventArgs e)
|
||
{
|
||
if (Regex.IsMatch(lnEditmiXHS.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(lnEditmiYHS.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(lnEditmiZHS.Text.ToString(), @"^[0-9]+$"))
|
||
{
|
||
if (SetlnEditmiXH.Text != "" && SetlnEditmiYH.Text != "" && SetlnEditmiZH.Text != "")
|
||
{
|
||
int XHspeed = Convert.ToInt32(SetlnEditmiXH.Text); //X<><58><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
|
||
int YHspeed = Convert.ToInt32(SetlnEditmiYH.Text); //Y<><59><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
|
||
int ZHspeed = Convert.ToInt32(SetlnEditmiZH.Text); //Z<><5A><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
|
||
|
||
melsecPLCTCPDriver.WriteInt("406", XHspeed); //д<><D0B4><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("416", YHspeed);
|
||
melsecPLCTCPDriver.WriteInt("426", ZHspeed);
|
||
string logs = "д<><D0B4><EFBFBD>ֶ<EFBFBD><D6B6>ٶ<EFBFBD> X" + XHspeed + "Y:" + YHspeed + "Z:" + ZHspeed + " ";
|
||
myLog(logs, DateTime.Now);
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
private void SetAutoSpeed_Click(object sender, EventArgs e)
|
||
{
|
||
if (Regex.IsMatch(lnEditmiXS.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(lnEditmiYS.Text.ToString(), @"^[0-9]+$") && Regex.IsMatch(lnEditmiZS.Text.ToString(), @"^[0-9]+$"))
|
||
{
|
||
if (SetlnEditmiXOP.Text != "" && SetlnEditmiYOP.Text != "" && SetlnEditmiZOP.Text != "")
|
||
{
|
||
int Xspeed = Convert.ToInt32(SetlnEditmiXOP.Text); //X<>ᶨλ<E1B6A8>ٶ<EFBFBD>
|
||
int Yspeed = Convert.ToInt32(SetlnEditmiYOP.Text); //Y<>ᶨλ<E1B6A8>ٶ<EFBFBD>
|
||
int Zspeed = Convert.ToInt32(SetlnEditmiZOP.Text); //Z<>ᶨλ<E1B6A8>ٶ<EFBFBD>
|
||
|
||
melsecPLCTCPDriver.WriteInt("404", Xspeed); //д<>붨λ<EBB6A8>ٶ<EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("414", Yspeed);
|
||
melsecPLCTCPDriver.WriteInt("424", Zspeed);
|
||
|
||
string logs = "д<>붨λ<EBB6A8>ٶ<EFBFBD> X" + Xspeed + "Y:" + Yspeed + "Z:" + Zspeed + " ";
|
||
myLog(logs, DateTime.Now);
|
||
}
|
||
}
|
||
}
|
||
//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>ʶ
|
||
private bool m_btnState;
|
||
|
||
|
||
private void YZerorbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifYZeroValue)
|
||
{
|
||
this.YZerorbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("513", 1);
|
||
ifYZeroValue = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("Y<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.YZerorbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("513", 0);
|
||
ifYZeroValue = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("Y<><59>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void ZZerorbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifZZeroValue)
|
||
{
|
||
this.ZZerorbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("523", 1);
|
||
ifZZeroValue = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("Z<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.ZZerorbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("523", 0);
|
||
ifZZeroValue = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("Z<><5A>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void XForwardrbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifXForward)
|
||
{
|
||
this.XForwardrbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("502", 1);
|
||
ifXForward = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("X<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.XForwardrbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("502", 0);
|
||
ifXForward = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("X<><58>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void YForwardrbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifYForward)
|
||
{
|
||
this.YForwardrbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("512", 1);
|
||
ifYForward = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("Y<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.YForwardrbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("512", 0);
|
||
ifYForward = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("Y<><59>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void ZForwardrbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifZForward)
|
||
{
|
||
this.ZForwardrbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("522", 1);
|
||
ifZForward = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("Z<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.ZForwardrbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("522", 0);
|
||
ifZForward = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("Z<><5A>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void XBackwardrbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifXBackward)
|
||
{
|
||
this.XBackwardrbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("501", 1);
|
||
ifXBackward = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("X<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.XBackwardrbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("501", 0);
|
||
ifXBackward = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("X<><58>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void YBackwardrbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifYBackward)
|
||
{
|
||
this.YBackwardrbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("511", 1);
|
||
ifYBackward = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("Y<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.YBackwardrbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("511", 0);
|
||
ifYBackward = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("Y<><59>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void ZBackwardrbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifZBackward)
|
||
{
|
||
this.ZBackwardrbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("521", 1);
|
||
ifZBackward = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("Z<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.ZBackwardrbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("521", 0);
|
||
ifZBackward = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("Z<><5A>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
string ss = "BB0VA5E0000BCQ5L0114";
|
||
|
||
}
|
||
|
||
private void Cam2OpenBtn_Click_1(object sender, EventArgs e)
|
||
{
|
||
|
||
Cam2.Start("Cam2");
|
||
|
||
bnGetParam2.Enabled = true;
|
||
//SetCtrlWhenOpen();
|
||
Cam2OpenBtn.BackColor = Color.Green;
|
||
}
|
||
|
||
private void button4_Click_1(object sender, EventArgs e)
|
||
{
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ";
|
||
|
||
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
string fName = openFileDialog.FileName;
|
||
//File fileOpen = new File(fName);
|
||
//isFileHaveName = true;
|
||
//richTextBox1.Text = fileOpen.ReadFile();
|
||
//richTextBox1.AppendText("");
|
||
//DetectBArMatbox.Text = fName;
|
||
BarPath = fName;
|
||
}
|
||
}
|
||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>
|
||
private void InsertBtn_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
|
||
try
|
||
{
|
||
string SNText = OcrBarBox.Text;
|
||
string type = TypeBox.Text;
|
||
string OcrBar = OcrBarBox.Text;
|
||
string moveX = moveXbox.Text;
|
||
string moveY = moveYbox.Text;
|
||
string moveZ = moveZbox.Text;
|
||
// string Detect = DetectBArMatbox.Text;
|
||
// string movetwoX = moveTwoXbox.Text;
|
||
// string movetwoY = moveTwoYbox.Text;
|
||
// string movetwoZ = moveTwoZbox.Text;
|
||
bool whiteBan = true;
|
||
if (WhiteBanCbx.CheckState == CheckState.Checked)//ѡ<><D1A1>
|
||
{
|
||
whiteBan = true;
|
||
|
||
}
|
||
else if (WhiteBanCbx.CheckState == CheckState.Unchecked)//ûѡ<C3BB><D1A1>
|
||
{
|
||
whiteBan = false;
|
||
}
|
||
else
|
||
{
|
||
whiteBan = false;
|
||
}
|
||
|
||
if (!Regex.IsMatch(moveX, @"^[0-9]+$"))
|
||
{
|
||
MessageBox.Show("<22><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Xֻ<58><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
if (!Regex.IsMatch(moveY, @"^[0-9]+$"))
|
||
{
|
||
MessageBox.Show("<22><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Yֻ<59><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
if (!Regex.IsMatch(moveZ, @"^[0-9]+$"))
|
||
{
|
||
MessageBox.Show("<22><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Zֻ<5A><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
return;
|
||
}
|
||
//if (!Regex.IsMatch(movetwoX, @"^[0-9]+$"))
|
||
//{
|
||
// MessageBox.Show("<22>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Xֻ<58><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
// return;
|
||
//}
|
||
//if (!Regex.IsMatch(movetwoY, @"^[0-9]+$"))
|
||
//{
|
||
// MessageBox.Show("<22>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Yֻ<59><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
// return;
|
||
//}
|
||
//if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$"))
|
||
//{
|
||
// MessageBox.Show("<22>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Zֻ<5A><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
// return;
|
||
//}
|
||
|
||
if (SNText != "" && BarPath != "" && Cam1OnePath != "" && Cam1TwoPath != "" && ModelChangePath != "")
|
||
{
|
||
int HmoveX = (int)Convert.ToInt64(moveX);
|
||
int HmoveY = (int)Convert.ToInt64(moveY);
|
||
int HmoveZ = (int)Convert.ToInt64(moveZ);
|
||
//int HmovetwoX = (int)Convert.ToInt64(movetwoX);
|
||
//int HmovetwoY = (int)Convert.ToInt64(movetwoY);
|
||
//int HmovetwoZ = (int)Convert.ToInt64(movetwoZ);
|
||
InsertXK_Hisence(whiteBan, SNText, HmoveX, HmoveY, HmoveZ);
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ΪNULL");
|
||
}
|
||
|
||
}
|
||
catch (Exception es)
|
||
{
|
||
MessageBox.Show(es.Message);
|
||
}
|
||
}
|
||
public string FormBarType(string SN)
|
||
{
|
||
string productType = "null";
|
||
string url = "http://172.16.139.146/FCCBOMWebService/FCCBomService.asmx/GetFCCBomInfoPDJson";
|
||
|
||
string jsonData = @"
|
||
{
|
||
""StartTime"": ""2024-07-1"",
|
||
""EndTime"": ""2024-07-20"",
|
||
""LineBody"": ""BZ-PC""
|
||
}";
|
||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
string currentDate = DateTime.Now.ToString("yyyy-MM-dd");
|
||
|
||
// <20><><EFBFBD><EFBFBD>JSON<4F>ַ<EFBFBD><D6B7><EFBFBD>ΪJObject
|
||
JObject jsonObject = JObject.Parse(jsonData);
|
||
|
||
// <20><><EFBFBD><EFBFBD>EndTime<6D>ֶ<EFBFBD>
|
||
jsonObject["EndTime"] = currentDate;
|
||
|
||
// <20><>JObjectת<74><D7AA>JSON<4F>ַ<EFBFBD><D6B7><EFBFBD>
|
||
string updatedJsonData = jsonObject.ToString();
|
||
|
||
|
||
string postData = "inputvalue=" + Uri.EscapeDataString(updatedJsonData);
|
||
|
||
try
|
||
{
|
||
string response = PostData(url, postData);
|
||
|
||
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
||
string finalDefIdToFind = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 7); // Ŀ<><C4BF> FinalDefID
|
||
productType = FindStringAfterColon(response, finalDefIdToFind);
|
||
if (productType == null)
|
||
{
|
||
finalDefIdToFind = finalDefIdToFind.Substring(0, finalDefIdToFind.Length - 6);
|
||
productType = FindStringAfterColon(response, finalDefIdToFind);
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Console.WriteLine("Error occurred:");
|
||
Console.WriteLine(ex.Message);
|
||
}
|
||
return productType;
|
||
// sw.Stop();
|
||
// Console.WriteLine("ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>i<EFBFBD><69>" + sw.ElapsedMilliseconds);
|
||
}
|
||
public void Insert_auto(bool ifwhiteBan, Mat img, string SNtext, int MoveX, int MoveY, int MoveZ)
|
||
{
|
||
|
||
|
||
string IOcrBAr = FormBarType(SNtext);
|
||
XK_HisenceWord xkWord = new XK_HisenceWord();
|
||
xkWord.OcrBar = IOcrBAr;
|
||
xkWord.TwoIFWhile = ifwhiteBan;
|
||
using (StreamWriter sw = new StreamWriter("D://123.log", true))
|
||
{
|
||
sw.WriteLine("\n");
|
||
sw.WriteLine(IOcrBAr);
|
||
sw.Flush();
|
||
}
|
||
|
||
//<2F>ӵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫͼ<C8AB><CDBC>Χ<EFBFBD><CEA7>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>OCRʶ<52><CAB6>
|
||
MLRequest CamOneI = new MLRequest();
|
||
CamOneI.currentMat = img;
|
||
CamOneI.ResizeWidth = 640;
|
||
CamOneI.ResizeHeight = 640;
|
||
CamOneI.Score = 0.3f;
|
||
CamOneI.in_lable_path = LablePath;//<2F><>ǩ·<C7A9><C2B7>
|
||
CamOneI.confThreshold = 0.3f;//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD>
|
||
CamOneI.iouThreshold = 0.4f;//<2F><><EFBFBD><EFBFBD>IOU
|
||
CamOneI.out_node_name = "output";
|
||
MLResult mL3 = simboObjectDetection.RunInferenceFixed(CamOneI);
|
||
MLResult mLButton = simboObjectDetButton.RunInferenceFixed(CamOneI);
|
||
//if (mL3.IsSuccess)
|
||
//{
|
||
// DateTime dt = DateTime.Now;
|
||
// mL3.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
|
||
|
||
//}
|
||
List<string> strMatListOne = new List<string>();
|
||
List<string> strMatFuzzyListOne = new List<string>();
|
||
Mat mResultCut = CamOneI.currentMat.Clone();
|
||
//Mat mCut = new Mat();
|
||
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
|
||
InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||
|
||
|
||
|
||
|
||
//if (xkWord.OneblockText.)
|
||
//{ }
|
||
InsertXKHisenceWordData(xkWord);//<2F><><EFBFBD>ؼ<EFBFBD><D8BC>ֱ<EFBFBD><D6B1>в<EFBFBD><D0B2><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
string OcrTextone = strMatListOne.Join("##");
|
||
string OcrTextTwo = strMatFuzzyListOne.Join("##");
|
||
|
||
|
||
string detstr = "";
|
||
if (keyValueResult.Count <= 1)
|
||
{
|
||
return;
|
||
}
|
||
|
||
for (int v = 0; v < keyValueResult.Count; v++)
|
||
{
|
||
var item = keyValueResult.ElementAt(v);
|
||
if (v < keyValueResult.Count - 1)
|
||
{
|
||
detstr += item.Key + ",";
|
||
}
|
||
else
|
||
{
|
||
detstr += item.Key;
|
||
}
|
||
|
||
}
|
||
|
||
DateTime dt2 = DateTime.Now;
|
||
XKHisence xK = new XKHisence("1", IOcrBAr, MoveX, MoveY, MoveZ, detstr, OcrTextone, MoveX, MoveY, MoveZ, ModelChangePath, "", OcrTextTwo);
|
||
|
||
|
||
string sql = "insert into XK_Hisence VALUES('" + xK.Type + "','" + xK.OcrBar + "'," + xK.MoveX + "," + xK.MoveY + "," + xK.MoveZ + ",'" + xK.Detect + "','" + xK.OcrText + "'," + xK.MoveTwoX + "," + xK.MoveTwoY + "," + xK.MoveTwoZ + ",'" + xK.OcrParm + "','" + xK.Language + "','" + xK.FuzzyOcrText + "')";
|
||
int i = SQLiteHelper.ExecuteSql(sql);
|
||
if (i == 1)
|
||
{
|
||
myLog("<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", DateTime.Now);
|
||
//MessageBox.Show("XK_Hisence<63><65><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
}
|
||
//bool ismatch = IsMatchOcrText("WF3S7021BB", strMatListListOne);
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
||
}
|
||
public void InsertXK_Hisence(bool ifwhiteBan, string SNtext, int MoveX, int MoveY, int MoveZ)
|
||
{
|
||
// PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel();
|
||
// IpaddleOcrModel.Load(ModelChangePath, "CPU");
|
||
|
||
|
||
string IOcrBAr = FormBarType(SNtext);
|
||
XK_HisenceWord xkWord = new XK_HisenceWord();
|
||
xkWord.OcrBar = IOcrBAr;
|
||
xkWord.TwoIFWhile = ifwhiteBan;
|
||
using (StreamWriter sw = new StreamWriter("D://123.log", true))
|
||
{
|
||
sw.WriteLine("\n");
|
||
sw.WriteLine(IOcrBAr);
|
||
sw.Flush();
|
||
}
|
||
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>еĿ<D0B5><C4BF>ü<EFBFBD> ʶ<><CAB6><EFBFBD>ַ<EFBFBD><D6B7>Ա<EFBFBD><D4B1>ַ<EFBFBD><D6B7><EFBFBD>
|
||
|
||
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
|
||
|
||
|
||
|
||
//<2F>ӵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫͼ<C8AB><CDBC>Χ<EFBFBD><CEA7>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>OCRʶ<52><CAB6>
|
||
MLRequest CamOneI = new MLRequest();
|
||
CamOneI.currentMat = Cv2.ImRead(Cam1OnePath);
|
||
CamOneI.ResizeWidth = 640;
|
||
CamOneI.ResizeHeight = 640;
|
||
CamOneI.Score = 0.3f;
|
||
CamOneI.in_lable_path = LablePath;//<2F><>ǩ·<C7A9><C2B7>
|
||
CamOneI.confThreshold = 0.3f;//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD>
|
||
CamOneI.iouThreshold = 0.4f;//<2F><><EFBFBD><EFBFBD>IOU
|
||
CamOneI.out_node_name = "output";
|
||
MLResult mL3 = simboObjectDetection.RunInferenceFixed(CamOneI);
|
||
MLResult mLButton = simboObjectDetButton.RunInferenceFixed(CamOneI);
|
||
//if (mL3.IsSuccess)
|
||
//{
|
||
// DateTime dt = DateTime.Now;
|
||
// mL3.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
|
||
|
||
//}
|
||
List<string> strMatListOne = new List<string>();
|
||
List<string> strMatFuzzyListOne = new List<string>();
|
||
Mat mResultCut = CamOneI.currentMat.Clone();
|
||
//Mat mCut = new Mat();
|
||
Dictionary<string, bool> keyValueResult = new Dictionary<string, bool>();
|
||
InsertSqlRunDataButton(ref keyValueResult, true, ref mResultCut, mL3, mLButton, ref xK_HisenceSQLWord, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||
|
||
|
||
|
||
//MLRequest CamTwoI = new MLRequest();
|
||
//CamTwoI.currentMat = Cv2.ImRead(Cam1TwoPath);
|
||
//CamTwoI.ResizeWidth = 640;
|
||
//CamTwoI.ResizeHeight = 640;
|
||
//CamTwoI.Score = 0.3f;
|
||
//CamTwoI.in_lable_path = LablePath;//<2F><>ǩ·<C7A9><C2B7>
|
||
//CamTwoI.confThreshold = 0.3f;//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD>
|
||
//CamTwoI.iouThreshold = 0.4f;//<2F><><EFBFBD><EFBFBD>IOU
|
||
//CamTwoI.out_node_name = "output";
|
||
//MLResult mL4 = simboObjectDetection.RunInferenceFixed(CamTwoI);
|
||
////if (mL4.IsSuccess)
|
||
////{
|
||
//// DateTime dt = DateTime.Now;
|
||
//// mL4.ResultMap.Save("D:\\Hisence\\detImages\\" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg");
|
||
|
||
////}
|
||
//List<string> strMatListTwo = new List<string>();
|
||
//List<string> strMatFuzzyListTwo = new List<string>();
|
||
//Mat mResultCut2 = CamTwoI.currentMat.Clone();
|
||
//Dictionary<string, bool> keyValueResult2 = new Dictionary<string, bool>();
|
||
//InsertSqlRunData(ref keyValueResult2, true, ref mResultCut2, mL4, ref xK_HisenceSQLWord, ref xkWord, ref strMatListTwo, ref strMatFuzzyListTwo, ref paddleOcrModel);
|
||
|
||
|
||
|
||
InsertXKHisenceWordData(xkWord);//<2F><><EFBFBD>ؼ<EFBFBD><D8BC>ֱ<EFBFBD><D6B1>в<EFBFBD><D0B2><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
//<2F>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
||
//List<string> bingji = strMatListOne.Union(strMatListTwo).ToList();//<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||
//List<string> Fuzzybingji = strMatFuzzyListOne.Union(strMatFuzzyListTwo).ToList();//<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||
string OcrTextone = strMatListOne.Join("##");
|
||
string OcrTextTwo = strMatFuzzyListOne.Join("##");
|
||
|
||
//string OcrTextinsert = "";
|
||
//List<string> bingji = strMatListListOne.Union(strMatListListTwo).ToList();//<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||
//for (int j = 0; j < bingji.Count; j++)
|
||
//{
|
||
// string jdetial = bingji[j];
|
||
// OcrTextinsert += jdetial + "##";
|
||
//}
|
||
string detstr = "";
|
||
|
||
for (int v = 0; v < keyValueResult.Count; v++)
|
||
{
|
||
var item = keyValueResult.ElementAt(v);
|
||
if (v < keyValueResult.Count - 1)
|
||
{
|
||
detstr += item.Key + ",";
|
||
}
|
||
else
|
||
{
|
||
detstr += item.Key;
|
||
}
|
||
|
||
}
|
||
|
||
DateTime dt2 = DateTime.Now;
|
||
XKHisence xK = new XKHisence("1", IOcrBAr, MoveX, MoveY, MoveZ, detstr, OcrTextone, MoveX, MoveY, MoveZ, ModelChangePath, "", OcrTextTwo);
|
||
//string log="D:\\Hisence\\detImages\\" + dt2.Year.ToString() + dt2.Month.ToString() + dt2.Day.ToString() + dt2.Hour.ToString() + dt2.Minute.ToString() + dt2.Millisecond.ToString() + "2result.log";
|
||
// using (StreamWriter sw=new StreamWriter(log, true))
|
||
// {
|
||
// // sw.WriteLine(xK.OcrBar+"\n");
|
||
// sw.WriteLine(xK.OcrText);
|
||
// sw.WriteLine(xK.FuzzyOcrText);
|
||
// }
|
||
//IpaddleOcrModel.FreeModel();
|
||
|
||
string sql = "insert into XK_Hisence VALUES('" + xK.Type + "','" + xK.OcrBar + "'," + xK.MoveX + "," + xK.MoveY + "," + xK.MoveZ + ",'" + xK.Detect + "','" + xK.OcrText + "'," + xK.MoveTwoX + "," + xK.MoveTwoY + "," + xK.MoveTwoZ + ",'" + xK.OcrParm + "','" + xK.Language + "','" + xK.FuzzyOcrText + "')";
|
||
int i = SQLiteHelper.ExecuteSql(sql);
|
||
if (i == 1)
|
||
{
|
||
MessageBox.Show("XK_Hisence<63><65><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
}
|
||
//bool ismatch = IsMatchOcrText("WF3S7021BB", strMatListListOne);
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
||
}
|
||
public void InsertXKHisenceWordData(XK_HisenceWord xkWord)
|
||
{
|
||
StringBuilder strSql = new StringBuilder();
|
||
strSql.Append("insert into XK_HisenceWord(");
|
||
strSql.Append("OcrBar,OneblockPath,OneblockMainWord,OneblockText,TwoRect,TwoIFWhile,TwoblockPath,TwoblockMainWord,TwoblockText,ThreeblockPath," +
|
||
"ThreeblockMainWord,ThreeblockText,FourblockPath,FourblockMainWord,FourblockText,FiveblockPath,FiveblockMainWord,FiveblockText," +
|
||
"SixblockPath,SixblockMainWord,SixblockText,SevenblockPath,SevenblockMainWord,SevenblockText,EightblockPath,EightblockMainWord,EightblockText)");
|
||
strSql.Append(" values (");
|
||
strSql.Append("@OcrBar,@OneblockPath,@OneblockMainWord,@OneblockText,@TwoRect,@TwoIFWhile,@TwoblockPath,@TwoblockMainWord,@TwoblockText,@ThreeblockPath," +
|
||
"@ThreeblockMainWord,@ThreeblockText,@FourblockPath,@FourblockMainWord,@FourblockText,@FiveblockPath,@FiveblockMainWord,@FiveblockText," +
|
||
"@SixblockPath,@SixblockMainWord,@SixblockText,@SevenblockPath,@SevenblockMainWord,@SevenblockText,@EightblockPath,@EightblockMainWord,@EightblockText)");
|
||
SQLiteParameter[] parameters = {
|
||
new SQLiteParameter("@OcrBar", DbType.String),
|
||
new SQLiteParameter("@OneblockPath", DbType.String),
|
||
new SQLiteParameter("@OneblockMainWord", DbType.String),
|
||
new SQLiteParameter("@OneblockText", DbType.String),
|
||
new SQLiteParameter("@TwoRect",DbType.String),
|
||
new SQLiteParameter("@TwoIFWhile",DbType.String),
|
||
new SQLiteParameter("@TwoblockPath", DbType.String),
|
||
new SQLiteParameter("@TwoblockMainWord",DbType.String),
|
||
new SQLiteParameter("@TwoblockText", DbType.String),
|
||
new SQLiteParameter("@ThreeblockPath", DbType.String),
|
||
new SQLiteParameter("@ThreeblockMainWord", DbType.String),
|
||
new SQLiteParameter("@ThreeblockText", DbType.String),
|
||
new SQLiteParameter("@FourblockPath", DbType.String),
|
||
new SQLiteParameter("@FourblockMainWord", DbType.String),
|
||
new SQLiteParameter("@FourblockText", DbType.String),
|
||
new SQLiteParameter("@FiveblockPath", DbType.String),
|
||
new SQLiteParameter("@FiveblockMainWord", DbType.String),
|
||
new SQLiteParameter("@FiveblockText", DbType.String),
|
||
new SQLiteParameter("@SixblockPath", DbType.String),
|
||
new SQLiteParameter("@SixblockMainWord", DbType.String),
|
||
new SQLiteParameter("@SixblockText", DbType.String),
|
||
new SQLiteParameter("@SevenblockPath", DbType.String),
|
||
new SQLiteParameter("@SevenblockMainWord", DbType.String),
|
||
new SQLiteParameter("@SevenblockText", DbType.String),
|
||
new SQLiteParameter("@EightblockPath", DbType.String),
|
||
new SQLiteParameter("@EightblockMainWord", DbType.String),
|
||
new SQLiteParameter("@EightblockText", DbType.String)};
|
||
|
||
parameters[0].Value = xkWord.OcrBar;
|
||
parameters[1].Value = xkWord.OneblockPath;
|
||
parameters[2].Value = xkWord.OneblockMainWord;
|
||
parameters[3].Value = xkWord.OneblockText;
|
||
|
||
parameters[4].Value = xkWord.TwoRect;
|
||
parameters[5].Value = xkWord.TwoIFWhile;
|
||
parameters[6].Value = xkWord.TwoblockPath;
|
||
parameters[7].Value = xkWord.TwoblockMainWord;
|
||
parameters[8].Value = xkWord.TwoblockText;
|
||
|
||
parameters[9].Value = xkWord.ThreeblockPath;
|
||
parameters[10].Value = xkWord.ThreeblockMainWord;
|
||
parameters[11].Value = xkWord.ThreeblockText;
|
||
|
||
parameters[12].Value = xkWord.FourblockPath;
|
||
parameters[13].Value = xkWord.FourblockMainWord;
|
||
parameters[14].Value = xkWord.FourblockText;
|
||
|
||
parameters[15].Value = xkWord.FiveblockPath;
|
||
parameters[16].Value = xkWord.FiveblockMainWord;
|
||
parameters[17].Value = xkWord.FiveblockText;
|
||
|
||
|
||
parameters[18].Value = xkWord.SixblockPath;
|
||
parameters[19].Value = xkWord.SixblockMainWord;
|
||
parameters[20].Value = xkWord.SixblockText;
|
||
|
||
parameters[21].Value = xkWord.SevenblockPath;
|
||
parameters[22].Value = xkWord.SevenblockMainWord;
|
||
parameters[23].Value = xkWord.SevenblockText;
|
||
|
||
parameters[24].Value = xkWord.EightblockPath;
|
||
parameters[25].Value = xkWord.EightblockMainWord;
|
||
parameters[26].Value = xkWord.EightblockText;
|
||
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
||
if (iv == 1)
|
||
{
|
||
//MessageBox.Show("<22>ؼ<EFBFBD><D8BC><EFBFBD>XK_HisenceWord<72><64><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
}
|
||
}
|
||
public void InsertXK_HisenceWordMatchData(XK_HisenceWord xkWord, bool ifMatch)
|
||
{
|
||
StringBuilder strSql = new StringBuilder();
|
||
strSql.Append("insert into XK_HisenceWordMatch(");
|
||
strSql.Append("OcrBar,OneblockPath,OneblockMainWord,OneblockText,TwoRect,TwoIFWhile,TwoblockPath,TwoblockMainWord,TwoblockText,ThreeblockPath," +
|
||
"ThreeblockMainWord,ThreeblockText,FourblockPath,FourblockMainWord,FourblockText,FiveblockPath,FiveblockMainWord,FiveblockText," +
|
||
"SixblockPath,SixblockMainWord,SixblockText,SevenblockPath,SevenblockMainWord,SevenblockText,EightblockPath,EightblockMainWord,EightblockText,Datetime,IfMatch)");
|
||
strSql.Append(" values (");
|
||
strSql.Append("@OcrBar,@OneblockPath,@OneblockMainWord,@OneblockText,@TwoRect,@TwoIFWhile,@TwoblockPath,@TwoblockMainWord,@TwoblockText,@ThreeblockPath," +
|
||
"@ThreeblockMainWord,@ThreeblockText,@FourblockPath,@FourblockMainWord,@FourblockText,@FiveblockPath,@FiveblockMainWord,@FiveblockText," +
|
||
"@SixblockPath,@SixblockMainWord,@SixblockText,@SevenblockPath,@SevenblockMainWord,@SevenblockText,@EightblockPath,@EightblockMainWord,@EightblockText,@Datetime,@IfMatch)");
|
||
SQLiteParameter[] parameters = {
|
||
new SQLiteParameter("@OcrBar", DbType.String),
|
||
new SQLiteParameter("@OneblockPath", DbType.String),
|
||
new SQLiteParameter("@OneblockMainWord", DbType.String),
|
||
new SQLiteParameter("@OneblockText", DbType.String),
|
||
new SQLiteParameter("@TwoRect",DbType.String),
|
||
new SQLiteParameter("@TwoIFWhile",DbType.String),
|
||
new SQLiteParameter("@TwoblockPath", DbType.String),
|
||
new SQLiteParameter("@TwoblockMainWord",DbType.String),
|
||
new SQLiteParameter("@TwoblockText", DbType.String),
|
||
new SQLiteParameter("@ThreeblockPath", DbType.String),
|
||
new SQLiteParameter("@ThreeblockMainWord", DbType.String),
|
||
new SQLiteParameter("@ThreeblockText", DbType.String),
|
||
new SQLiteParameter("@FourblockPath", DbType.String),
|
||
new SQLiteParameter("@FourblockMainWord", DbType.String),
|
||
new SQLiteParameter("@FourblockText", DbType.String),
|
||
new SQLiteParameter("@FiveblockPath", DbType.String),
|
||
new SQLiteParameter("@FiveblockMainWord", DbType.String),
|
||
new SQLiteParameter("@FiveblockText", DbType.String),
|
||
new SQLiteParameter("@SixblockPath", DbType.String),
|
||
new SQLiteParameter("@SixblockMainWord", DbType.String),
|
||
new SQLiteParameter("@SixblockText", DbType.String),
|
||
new SQLiteParameter("@SevenblockPath", DbType.String),
|
||
new SQLiteParameter("@SevenblockMainWord", DbType.String),
|
||
new SQLiteParameter("@SevenblockText", DbType.String),
|
||
new SQLiteParameter("@EightblockPath", DbType.String),
|
||
new SQLiteParameter("@EightblockMainWord", DbType.String),
|
||
new SQLiteParameter("@EightblockText", DbType.String),
|
||
new SQLiteParameter("@Datetime", DbType.String),
|
||
new SQLiteParameter("@IfMatch", DbType.Boolean)};
|
||
|
||
parameters[0].Value = xkWord.OcrBar;
|
||
parameters[1].Value = xkWord.OneblockPath;
|
||
parameters[2].Value = xkWord.OneblockMainWord;
|
||
parameters[3].Value = xkWord.OneblockText;
|
||
|
||
parameters[4].Value = xkWord.TwoRect;
|
||
parameters[5].Value = xkWord.TwoIFWhile;
|
||
parameters[6].Value = xkWord.TwoblockPath;
|
||
parameters[7].Value = xkWord.TwoblockMainWord;
|
||
parameters[8].Value = xkWord.TwoblockText;
|
||
|
||
parameters[9].Value = xkWord.ThreeblockPath;
|
||
parameters[10].Value = xkWord.ThreeblockMainWord;
|
||
parameters[11].Value = xkWord.ThreeblockText;
|
||
|
||
parameters[12].Value = xkWord.FourblockPath;
|
||
parameters[13].Value = xkWord.FourblockMainWord;
|
||
parameters[14].Value = xkWord.FourblockText;
|
||
|
||
parameters[15].Value = xkWord.FiveblockPath;
|
||
parameters[16].Value = xkWord.FiveblockMainWord;
|
||
parameters[17].Value = xkWord.FiveblockText;
|
||
|
||
|
||
parameters[18].Value = xkWord.SixblockPath;
|
||
parameters[19].Value = xkWord.SixblockMainWord;
|
||
parameters[20].Value = xkWord.SixblockText;
|
||
|
||
parameters[21].Value = xkWord.SevenblockPath;
|
||
parameters[22].Value = xkWord.SevenblockMainWord;
|
||
parameters[23].Value = xkWord.SevenblockText;
|
||
|
||
parameters[24].Value = xkWord.EightblockPath;
|
||
parameters[25].Value = xkWord.EightblockMainWord;
|
||
parameters[26].Value = xkWord.EightblockText;
|
||
|
||
parameters[27].Value = DateTime.Now;
|
||
parameters[28].Value = ifMatch;
|
||
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
||
if (iv == 1)
|
||
{
|
||
MessageBox.Show("<22>ؼ<EFBFBD><D8BC><EFBFBD>XK_HisenceWordMatch<63><68><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
}
|
||
}
|
||
|
||
public void InsertXKHisenceDET(XKHisence xkWord)
|
||
{
|
||
StringBuilder strSql = new StringBuilder();
|
||
strSql.Append("insert into XKHisenceDet(");
|
||
strSql.Append("Type,OcrBar,MoveX,MoveY,MoveZ,Detect,OcrText,MoveTwoX,MoveTwoY,MoveTwoZ,Datetime,IfMatch)");
|
||
strSql.Append(" values (");
|
||
strSql.Append("@Type,@OcrBar,@MoveX,@MoveY,@MoveZ,@Detect,@OcrText,@MoveTwoX,@MoveTwoY,@MoveTwoZ,@Datetime,@IfMatch)");
|
||
SQLiteParameter[] parameters = {
|
||
new SQLiteParameter("@OcrBar", DbType.String),
|
||
new SQLiteParameter("@MoveX", DbType.String),
|
||
new SQLiteParameter("@MoveY", DbType.String),
|
||
new SQLiteParameter("@MoveZ", DbType.String),
|
||
new SQLiteParameter("@Detect",DbType.String),
|
||
new SQLiteParameter("@OcrText", DbType.String),
|
||
new SQLiteParameter("@MoveTwoX",DbType.String),
|
||
new SQLiteParameter("@MoveTwoY", DbType.String),
|
||
new SQLiteParameter("@MoveTwoZ", DbType.String),
|
||
new SQLiteParameter("@Datetime", DbType.String),
|
||
new SQLiteParameter("@IfMatch", DbType.String)};
|
||
parameters[0].Value = xkWord.OcrBar;
|
||
parameters[1].Value = xkWord.MoveX;
|
||
parameters[2].Value = xkWord.MoveY;
|
||
parameters[3].Value = xkWord.MoveZ;
|
||
|
||
parameters[4].Value = xkWord.Detect;
|
||
parameters[5].Value = xkWord.OcrText;
|
||
parameters[6].Value = xkWord.MoveTwoX;
|
||
parameters[7].Value = xkWord.MoveTwoY;
|
||
|
||
parameters[8].Value = xkWord.MoveTwoZ;
|
||
|
||
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
||
if (iv == 1)
|
||
{
|
||
MessageBox.Show("<22>ؼ<EFBFBD><D8BC><EFBFBD>XK_HisenceWord<72><64><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
}
|
||
}
|
||
#endregion
|
||
private void queryALLBtn_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
DataSet dataSet = SQLiteHelper.Query("select * from XK_Hisence");
|
||
InsertDataDgv.DataSource = dataSet.Tables[0];
|
||
|
||
|
||
}
|
||
catch (Exception es)
|
||
{
|
||
}
|
||
}
|
||
|
||
private void QueryoneBtn_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
|
||
|
||
}
|
||
catch (Exception es)
|
||
{
|
||
}
|
||
}
|
||
|
||
private void OpenDirBtn_Click(object sender, EventArgs e)
|
||
{
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ";
|
||
|
||
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
string fName = openFileDialog.FileName;
|
||
//File fileOpen = new File(fName);
|
||
//isFileHaveName = true;
|
||
//richTextBox1.Text = fileOpen.ReadFile();
|
||
//richTextBox1.AppendText("");
|
||
Cam1MatCbx.Text = fName;
|
||
Cam1OnePath = fName;
|
||
}
|
||
}
|
||
|
||
private void OpenTwoDirBtn_Click(object sender, EventArgs e)
|
||
{
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ";
|
||
|
||
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
string fName = openFileDialog.FileName;
|
||
//File fileOpen = new File(fName);
|
||
//isFileHaveName = true;
|
||
//richTextBox1.Text = fileOpen.ReadFile();
|
||
//richTextBox1.AppendText("");
|
||
Cam2MatCbx.Text = fName;
|
||
Cam1TwoPath = fName;
|
||
}
|
||
}
|
||
|
||
private void openModelBtn_Click(object sender, EventArgs e)
|
||
{
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>json";
|
||
|
||
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
string fName = openFileDialog.FileName;
|
||
//File fileOpen = new File(fName);
|
||
//isFileHaveName = true;
|
||
//richTextBox1.Text = fileOpen.ReadFile();
|
||
//richTextBox1.AppendText("");
|
||
modelChangeCbx.Text = fName;
|
||
ModelChangePath = fName;
|
||
}
|
||
}
|
||
|
||
private void SnapshotCam2_Click_1(object sender, EventArgs e)
|
||
{
|
||
Cam2.Snapshot();
|
||
}
|
||
private async void Defet_OnDetectionDone(Mat detectionImage, int BlockId)
|
||
{
|
||
|
||
await Task.Run(() =>
|
||
{
|
||
if (!this.IsHandleCreated)
|
||
return;
|
||
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
if (this.IsDisposed)
|
||
return;
|
||
switch (BlockId)
|
||
{
|
||
case 1:
|
||
{
|
||
canvas1.ImaMAt = detectionImage;
|
||
}
|
||
break;
|
||
case 2:
|
||
{
|
||
canvas2.ImaMAt = detectionImage;
|
||
}
|
||
break;
|
||
case 3:
|
||
{
|
||
canvas3.ImaMAt = detectionImage;
|
||
}
|
||
break;
|
||
//case 4:
|
||
// {
|
||
// canvas4.ImaMAt = detectionImage;
|
||
// }
|
||
// break;
|
||
//case 5:
|
||
// {
|
||
// canvas5.ImaMAt = detectionImage;
|
||
// }
|
||
// break;
|
||
case 6:
|
||
{
|
||
//canvas6.ImaMAt = detectionImage;
|
||
}
|
||
break;
|
||
case 7:
|
||
{
|
||
// canvas7.ImaMAt = detectionImage;
|
||
}
|
||
break;
|
||
case 8:
|
||
{
|
||
//DefetShow8.ImaMAt = detectionImage;
|
||
}
|
||
break;
|
||
|
||
}
|
||
//var display = displayList.FirstOrDefault(u => u.DetectionId == detectionId);
|
||
//if (display != null)
|
||
//{
|
||
// display.RefreshDetectionResult(image, detectionResults);
|
||
//}
|
||
}));
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// ȫͼϴ<CDBC>»<EFBFBD> <20>ü<EFBFBD>֮<EFBFBD><D6AE> OCRʶ<52><CAB6><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="saveimage"></param>
|
||
/// <param name="CutMat"></param>
|
||
/// <param name="currentMatC">ȫͼͼƬ</param>
|
||
/// <param name="cam1TwoML">ȫ<><C8AB>ͼƬ<CDBC>ϵ<EFBFBD>Ŀ<EFBFBD>궨λ<EAB6A8><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ο<EFBFBD><CEBF><EFBFBD></param>
|
||
/// <param name="cam1Button"></param>
|
||
/// <param name="xK_HisenceWord"></param>
|
||
/// <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)
|
||
{
|
||
#if true
|
||
//try
|
||
//{
|
||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>־<EFBFBD><D6BE>¼
|
||
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();
|
||
}
|
||
|
||
// <20><>¡<EFBFBD><C2A1>ǰͼ<C7B0><CDBC>
|
||
Mat mResultCut = currentMatC.Clone();
|
||
Rect areaBlack = new Rect();
|
||
|
||
// <20><>ť<EFBFBD><C5A5>λ<EFBFBD><CEBB>
|
||
if (cam1Button.ResultDetails.Count == 1)
|
||
{
|
||
int rectsx = cam1Button.ResultDetails[0].Rect.X;
|
||
int rectsy = cam1Button.ResultDetails[0].Rect.Y;
|
||
int rectsWidth = cam1Button.ResultDetails[0].Rect.Width;
|
||
int rectsHeight = cam1Button.ResultDetails[0].Rect.Height;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ťλ<C5A5>ã<EFBFBD><C3A3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||
rectsx = Math.Max(rectsx, 0);
|
||
rectsy = Math.Max(rectsy, 0);
|
||
rectsWidth = Math.Min(rectsWidth, currentMatC.Width - rectsx);
|
||
rectsHeight = Math.Min(rectsHeight, currentMatC.Height - rectsy);
|
||
|
||
areaBlack = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
|
||
}
|
||
|
||
for (int i = 0; i < cam1TwoML.ResultDetails.Count; i++)
|
||
{
|
||
int rectsx = cam1TwoML.ResultDetails[i].Rect.X;
|
||
int rectsy = cam1TwoML.ResultDetails[i].Rect.Y;
|
||
int rectsWidth = cam1TwoML.ResultDetails[i].Rect.Width;
|
||
int rectsHeight = cam1TwoML.ResultDetails[i].Rect.Height;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||
rectsx = Math.Max(rectsx, 0);
|
||
rectsy = Math.Max(rectsy, 0);
|
||
rectsWidth = Math.Min(rectsWidth, currentMatC.Width - rectsx);
|
||
rectsHeight = Math.Min(rectsHeight, currentMatC.Height - rectsy);
|
||
|
||
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
|
||
//<2F><>ֹ<EFBFBD><D6B9>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>ұߵ<D2B1><DFB5>¶<EFBFBD>λ<EFBFBD><CEBB>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>2 + <20><>ֹ<EFBFBD><D6B9>λ<EFBFBD><CEBB>Ч<EFBFBD><D0A7><EFBFBD>͵<EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>Ч<EFBFBD><D0A7><EFBFBD>ij<EFBFBD>4
|
||
if (keyValueResult.Keys.Contains(blockIndex))
|
||
{
|
||
int indexof = keyValueResult.Keys.ToList().IndexOf(blockIndex);
|
||
int rectsxof = cam1TwoML.ResultDetails[indexof].Rect.X;
|
||
int rectsYof = cam1TwoML.ResultDetails[indexof].Rect.Y;
|
||
if (rectsx > rectsxof)
|
||
{
|
||
blockIndex = "3";
|
||
}
|
||
if (rectsy > rectsYof)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
}
|
||
|
||
Rect area2 = new Rect(0, 0, 0, 0);
|
||
if (blockIndex == "2") // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
|
||
{
|
||
if ((areaBlack.X + areaBlack.Width) < (rectsx + rectsWidth))
|
||
{
|
||
areaBlack.X = Math.Max(areaBlack.X - rectsx, 0);
|
||
areaBlack.Y = Math.Max(areaBlack.Y - rectsy, 0);
|
||
areaBlack.Width = Math.Min(areaBlack.Width, currentMatC.Width - areaBlack.X);
|
||
areaBlack.Height = Math.Min(areaBlack.Height, currentMatC.Height - areaBlack.Y);
|
||
area2 = areaBlack;
|
||
}
|
||
string TwoRectStr = CheckDiffSciHelper.rectChangeStr(area2);
|
||
xK_HisenceWord.TwoRect = TwoRectStr;
|
||
}
|
||
|
||
Stopwatch sw = Stopwatch.StartNew();
|
||
sw.Start();
|
||
int extendHeight = 50;
|
||
rectsHeight += extendHeight;
|
||
rectsHeight = Math.Min(rectsHeight, currentMatC.Height - rectsy);
|
||
|
||
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
|
||
Mat matCut = new Mat(mResultCut, area);
|
||
|
||
// OCRʶ<52><CAB6><EFBFBD>ü<EFBFBD>ͼƬ
|
||
MLRequest reqcut = new MLRequest();
|
||
reqcut.currentMat = matCut.Clone();
|
||
MLResult mLCut = paddleOcrModel.RunInference(reqcut);
|
||
|
||
bool blockMatchI = BlockChangeFun(saveimage, blockIndex, ref matCut, ref mLCut, ref SQlxK_HisenceWord, ref xK_HisenceWord);
|
||
sw.Stop();
|
||
//myLog("<22><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʱ<EFBFBD><CAB1>" + sw.ElapsedMilliseconds, DateTime.Now);
|
||
|
||
keyValueResult.Add(blockIndex, blockMatchI);
|
||
}
|
||
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
|
||
//}
|
||
#endif
|
||
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// ȫͼϴ<CDBC>»<EFBFBD> <20>ü<EFBFBD>֮<EFBFBD><D6AE> OCRʶ<52><CAB6><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
||
/// </summary>
|
||
/// <param name="currentMatC">ȫͼͼƬ</param>
|
||
/// <param name="cam1TwoML">ȫ<><C8AB>ͼƬ<CDBC>ϵ<EFBFBD>Ŀ<EFBFBD>궨λ<EAB6A8><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ο<EFBFBD><CEBF><EFBFBD></param>
|
||
/// <param name="strMatList"><3E><><EFBFBD>صĶ<D8B5>λ<EFBFBD><CEBB><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD></param>
|
||
public void InsertSqlRunData(ref Dictionary<string, bool> keyValueResult2, bool saveimage, ref Mat currentMatC, MLResult cam1TwoML, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord, ref List<string> strMatList, ref List<string> strMatRefList, ref PaddleOcrModel IOcrModel)
|
||
{
|
||
#if true
|
||
//try
|
||
//{
|
||
|
||
|
||
Mat mResultCut = currentMatC.Clone();
|
||
|
||
for (int i = 0; i < cam1TwoML.ResultDetails.Count; i++)
|
||
{
|
||
Mat mResultCuti = mResultCut.Clone();
|
||
int rectsx = cam1TwoML.ResultDetails[i].Rect.X;
|
||
int rectsy = cam1TwoML.ResultDetails[i].Rect.Y;
|
||
int rectsWidth = cam1TwoML.ResultDetails[i].Rect.Width;
|
||
int rectsHeight = cam1TwoML.ResultDetails[i].Rect.Height;
|
||
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
|
||
Rect area = new Rect(rectsx, rectsy, rectsWidth, rectsHeight);
|
||
Mat matCut = new Mat(mResultCuti, area);
|
||
|
||
Stopwatch sw = new Stopwatch();
|
||
sw.Start();
|
||
//OCRʶ<52><CAB6><EFBFBD>ü<EFBFBD>ͼƬ
|
||
MLRequest reqcut = new MLRequest();
|
||
reqcut.currentMat = matCut.Clone();
|
||
MLResult mLCut = paddleOcrModel.RunInference(reqcut);
|
||
|
||
bool blockMatchI = BlockChangeFun(saveimage, blockIndex, ref matCut, ref mLCut, ref SQlxK_HisenceWord, ref xK_HisenceWord);
|
||
keyValueResult2.Add(blockIndex, blockMatchI);
|
||
sw.Stop();
|
||
//myLog("<22><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʱ<EFBFBD><CAB1>" + sw.ElapsedMilliseconds, DateTime.Now);
|
||
}
|
||
|
||
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
|
||
//}
|
||
#endif
|
||
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>ȶ<EFBFBD><C8B6>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
|
||
/// </summary>
|
||
/// <param name="saveimage"><3E>Ƿ<C7B7></param>
|
||
/// <param name="blockIndex"><3E>ü<EFBFBD><C3BC><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
||
/// <param name="CutBlockMat"><3E>ü<EFBFBD><C3BC><EFBFBD>һ<EFBFBD><D2BB>ͼƬ</param>
|
||
/// <param name="mLcut"><3E>ü<EFBFBD>ͼƬ<CDBC><C6AC>һЩ<D2BB><D0A9>Ϣ</param>
|
||
/// <param name="xK_HisenceWord">Ҫ<>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>Ķ<EFBFBD><C4B6><EFBFBD></param>
|
||
public bool BlockChangeFun(bool saveimage, string blockIndex, ref Mat CutBlockMat, ref MLResult mLcut, ref XK_HisenceWord SQlxK_HisenceWord, ref XK_HisenceWord xK_HisenceWord)
|
||
{
|
||
bool OneIF = false;
|
||
string CutSavePath = "";
|
||
//<2F>ڵ<EFBFBD>һ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2 ͼƬ<CDBC><C6AC>Ŀ¼
|
||
if (saveimage)
|
||
{
|
||
string OcrBar = xK_HisenceWord.OcrBar;
|
||
string namecutSavepath = OcrBar + "\\" + blockIndex + "\\" + OcrBar + "result.jpg";
|
||
|
||
CutSavePath = Path.Combine(RootPath, namecutSavepath);
|
||
//<2F>õ<EFBFBD>Ŀ¼
|
||
if (!Directory.Exists(Path.GetDirectoryName(CutSavePath)))
|
||
{
|
||
Directory.CreateDirectory(Path.GetDirectoryName(CutSavePath));
|
||
}
|
||
|
||
Cv2.ImWrite(CutSavePath, CutBlockMat);
|
||
}
|
||
|
||
//<2F><><EFBFBD>Źؼ<C5B9><D8BC>ֺ<EFBFBD><D6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||
List<string> OcrTextinsert = new List<string>();//<2F><><EFBFBD>Źؼ<C5B9><D8BC><EFBFBD>
|
||
List<string> OcrFuzzyTextInsert = new List<string>();//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>
|
||
|
||
//<2F><>һ<EFBFBD><D2BB>ͼƬ<CDBC>ϵĹؼ<C4B9><D8BC>ֱȶ<D6B1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ<EFBFBD>ע
|
||
//MatMessage(saveimage, ocrBar, blockIndex, ref CutBlockMat, ref mLcut, ref OcrTextinsert, ref OcrFuzzyTextInsert, ref CutSavePath);
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵĹؼ<C4B9><D8BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
||
for (int j = 0; j < mLcut.ResultDetails.Count; j++)
|
||
{
|
||
var resultDetail = mLcut.ResultDetails[j];
|
||
if (resultDetail.Score > 0.7)
|
||
{
|
||
string jdetial = mLcut.ResultDetails[j].LabelDisplay;
|
||
string result = Regex.Replace(jdetial, "[ \\[ \\] \\^ \\-_*<2A><><EFBFBD>D<EFBFBD>D(^)$%~!@#$<24><>&%<25><><EFBFBD><EFBFBD>+=<><3E><><EFBFBD><EFBFBD>!<21><>??<3F><>:<3A><>?`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,.;/\"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-]", "");
|
||
if (Regex.IsMatch(result, @"\d"))
|
||
{
|
||
OcrTextinsert.Add(result);
|
||
}
|
||
OcrFuzzyTextInsert.Add(result);
|
||
}
|
||
}
|
||
DateTime dt = DateTime.Now;
|
||
|
||
|
||
string MainWoidStr = OcrTextinsert.Join("##"); //ʵ<>ʵĹؼ<C4B9><D8BC><EFBFBD>
|
||
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 SN = m_sKEYENCEBar.Substring(0, m_sKEYENCEBar.Length - 1);
|
||
switch (blockIndex)
|
||
{
|
||
case "1"://<2F><>ȫƥ<C8AB><C6A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||
{
|
||
xK_HisenceWord.OneblockPath = CutSavePath;
|
||
xK_HisenceWord.OneblockMainWord = MainWoidStr;
|
||
xK_HisenceWord.OneblockText = TextWoidStr;
|
||
SQLStr = SQlxK_HisenceWord.OneblockText;
|
||
string SQLStr2 = 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 = 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", SN + "_res.png");
|
||
Cv2.ImWrite(Path_1, mLcut.ResultMap.ToMat());
|
||
//CheckDiffSciHelper1.ResizeImage(Path_1, Path_1, 640, 480, 75);
|
||
|
||
}
|
||
else
|
||
{
|
||
OneIF = true;
|
||
Defet_OnDetectionDone(OKMat, 1);
|
||
string Path_2 = Path.Combine("D:\\Hisence\\Test\\1\\ok", SN + "_res.png");
|
||
Cv2.ImWrite(Path_2, OKMat);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
case "2"://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ƥ<><C6A5>
|
||
{
|
||
xK_HisenceWord.TwoblockPath = CutSavePath;
|
||
xK_HisenceWord.TwoblockMainWord = MainWoidStr;
|
||
xK_HisenceWord.TwoblockText = TextWoidStr;
|
||
if (!saveimage)
|
||
{
|
||
SQLStr = SQlxK_HisenceWord.TwoblockMainWord;
|
||
bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.TwoblockMainWord, SQlxK_HisenceWord.TwoblockMainWord);
|
||
OneIF1 = true;
|
||
//<2F>ڶ<EFBFBD><DAB6><EFBFBD> <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
|
||
string PathSql = SQlxK_HisenceWord.TwoblockPath;
|
||
//
|
||
|
||
Rect rectsql = CheckDiffSciHelper.strChangeRect(SQlxK_HisenceWord.TwoRect);
|
||
Rect rectDet = CheckDiffSciHelper.strChangeRect(xK_HisenceWord.TwoRect);
|
||
bool iswhite = IsMostlyWhite(PathSql);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ݿ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>鱳<EFBFBD><E9B1B3>ɫ
|
||
|
||
Mat SqlImg = Cv2.ImRead(PathSql);
|
||
Mat SqlBtn = GetCroppedImage(SqlImg, rectsql);
|
||
|
||
Mat BtnImg = GetCroppedImage(CutBlockMat, rectDet);//<2F><>ȡʵʱͼ<CAB1><CDBC><EFBFBD><EFBFBD>ťͼƬ
|
||
Bitmap bitmap = MatToBitmap(BtnImg);
|
||
|
||
pictureBox1.Image = bitmap;//չʾʵʱ<CAB5><CAB1>ťͼƬ
|
||
Rect newRect = GetCenterCroppedRect(SqlBtn, 30);
|
||
string color = BtnColor(SqlBtn, newRect);
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
|
||
textBox2.Text = color;//<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ť<EFBFBD><C5A5>ɫ
|
||
|
||
}));
|
||
Mat matresult = CutBlockMat.Clone();
|
||
|
||
juanjiMatch = CheckDiffSciHelper.CheckDiffSci(PathSql, CutBlockMat, ref matresult, rectsql, rectDet, iswhite, "D://Hisence//Test", SN);
|
||
// juanjiMatch = true;
|
||
|
||
if (!OneIF1 || !juanjiMatch)
|
||
{
|
||
OneIF = false;
|
||
//DisplayResult(mLcut);
|
||
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
|
||
// mLcut.ResultMap;
|
||
Defet_OnDetectionDone(matresult, 2);
|
||
}
|
||
else
|
||
{
|
||
OneIF = true;
|
||
Defet_OnDetectionDone(OKMat, 2);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "3"://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
|
||
{
|
||
xK_HisenceWord.ThreeblockPath = CutSavePath;
|
||
xK_HisenceWord.ThreeblockMainWord = MainWoidStr;
|
||
xK_HisenceWord.ThreeblockText = TextWoidStr;
|
||
if (!saveimage)
|
||
{
|
||
SQLStr = 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;
|
||
bool iswhite = IsMostlyWhite(PathSql);
|
||
juanjiMatch = CheckDiffSciHelper1.CheckDiffSci(PathSql, CutBlockMat, rect, rect, iswhite, "D://Hisence//Test1", m_sKEYENCEBar);
|
||
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);
|
||
}
|
||
|
||
}
|
||
}
|
||
break;
|
||
//case "4"://<2F><>ֽƥ<D6BD><C6A5>
|
||
// {
|
||
// xK_HisenceWord.FourblockPath = CutSavePath;
|
||
// xK_HisenceWord.FourblockMainWord = MainWoidStr;
|
||
// xK_HisenceWord.FourblockText = TextWoidStr;
|
||
// if (!saveimage)
|
||
// {
|
||
// SQLStr = 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;
|
||
|
||
// 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;
|
||
// Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 4);
|
||
// }
|
||
// else
|
||
// {
|
||
// OneIF = true;
|
||
// Defet_OnDetectionDone(OKMat, 4);
|
||
// }
|
||
|
||
// }
|
||
// }
|
||
// break;
|
||
//case "5"://<2F><>ֽƥ<D6BD><C6A5>
|
||
// {
|
||
// xK_HisenceWord.FiveblockPath = CutSavePath;
|
||
// xK_HisenceWord.FiveblockMainWord = MainWoidStr;
|
||
// xK_HisenceWord.FiveblockText = TextWoidStr;
|
||
// if (!saveimage)
|
||
// {
|
||
// SQLStr = SQlxK_HisenceWord.FiveblockMainWord;
|
||
// bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.FiveblockMainWord, SQlxK_HisenceWord.FiveblockMainWord);
|
||
// 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);
|
||
// //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
|
||
// // mLcut.ResultMap;
|
||
// Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 5);
|
||
// }
|
||
// else
|
||
// {
|
||
// OneIF = true;
|
||
// Defet_OnDetectionDone(OKMat, 5);
|
||
// }
|
||
// }
|
||
// }
|
||
// break;
|
||
//case "6"://<2F><>ֽƥ<D6BD><C6A5>
|
||
// {
|
||
// xK_HisenceWord.SixblockPath = CutSavePath;
|
||
// xK_HisenceWord.SixblockMainWord = MainWoidStr;
|
||
// xK_HisenceWord.SixblockText = TextWoidStr;
|
||
// if (!saveimage)
|
||
// {
|
||
// SQLStr = SQlxK_HisenceWord.SixblockMainWord;
|
||
// bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SixblockMainWord, SQlxK_HisenceWord.SixblockMainWord);
|
||
// OneIF1 = false;//<2F><><EFBFBD><EFBFBD>
|
||
// 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)
|
||
// {
|
||
// OneIF = false;
|
||
// // DisplayResult(mLcut);
|
||
// //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
|
||
// // mLcut.ResultMap;
|
||
// Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 6);
|
||
// }
|
||
// else
|
||
// {
|
||
// OneIF = true;
|
||
// Defet_OnDetectionDone(OKMat, 6);
|
||
// }
|
||
|
||
// }
|
||
// }
|
||
// break;
|
||
//case "7"://<2F><>ֽƥ<D6BD><C6A5>
|
||
// {
|
||
// xK_HisenceWord.SevenblockPath = CutSavePath;
|
||
// xK_HisenceWord.SevenblockMainWord = MainWoidStr;
|
||
// xK_HisenceWord.SevenblockText = TextWoidStr;
|
||
// if (!saveimage)
|
||
// {
|
||
// SQLStr = SQlxK_HisenceWord.SevenblockMainWord;
|
||
// bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.SevenblockMainWord, SQlxK_HisenceWord.SevenblockMainWord);
|
||
|
||
// Rect rect = new Rect(0, 0, 0, 0);
|
||
// string PathSql = SQlxK_HisenceWord.SevenblockPath;
|
||
|
||
// 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;
|
||
// Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 7);
|
||
// }
|
||
// else
|
||
// {
|
||
// OneIF = true;
|
||
// Defet_OnDetectionDone(OKMat, 7);
|
||
// }
|
||
// }
|
||
// }
|
||
// break;
|
||
//case "8"://<2F><>ֽƥ<D6BD><C6A5>
|
||
// {
|
||
// xK_HisenceWord.EightblockPath = CutSavePath;
|
||
// xK_HisenceWord.EightblockMainWord = MainWoidStr;
|
||
// xK_HisenceWord.EightblockText = TextWoidStr;
|
||
// if (!saveimage)
|
||
// {
|
||
// SQLStr = SQlxK_HisenceWord.EightblockMainWord;
|
||
// bool OneIF1 = ManagerModelHelper.StrMatch2(xK_HisenceWord.EightblockMainWord, SQlxK_HisenceWord.EightblockMainWord);
|
||
// 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);
|
||
// //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>
|
||
// // mLcut.ResultMap;
|
||
// Defet_OnDetectionDone(mLcut.ResultMap.ToMat(), 8);
|
||
// }
|
||
// else
|
||
// {
|
||
// OneIF = true;
|
||
// Defet_OnDetectionDone(OKMat, 8);
|
||
// }
|
||
// }
|
||
// }
|
||
// break;
|
||
}
|
||
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))
|
||
{
|
||
|
||
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");
|
||
|
||
sw.Flush();
|
||
}
|
||
return OneIF;
|
||
|
||
|
||
}
|
||
static bool IsMostlyWhite(string imagePath)
|
||
{
|
||
Bitmap bitmap = new Bitmap(imagePath);
|
||
int width = bitmap.Width;
|
||
int height = bitmap.Height;
|
||
|
||
int blackCount = 0;
|
||
int whiteCount = 0;
|
||
int rectSize = 30;
|
||
|
||
for (int y = height - rectSize; y < height; y++)
|
||
{
|
||
for (int x = 0; x < rectSize; x++)
|
||
{
|
||
Color pixelColor = bitmap.GetPixel(x, y);
|
||
int r = pixelColor.R;
|
||
int g = pixelColor.G;
|
||
int b = pixelColor.B;
|
||
|
||
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>ɫ
|
||
if (r <= 100 && g <= 100 && b <= 100)
|
||
{
|
||
blackCount++;
|
||
}
|
||
else
|
||
{
|
||
whiteCount++;
|
||
}
|
||
}
|
||
}
|
||
|
||
int totalPixels = width * height;
|
||
double blackRatio = (double)blackCount / totalPixels;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>0.6<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true
|
||
return blackRatio < 0.6;
|
||
}
|
||
//Mat תBitmap
|
||
private Bitmap MatToBitmap(Mat mat)
|
||
{
|
||
// Convert OpenCV Mat to Bitmap
|
||
Bitmap bitmap;
|
||
using (var ms = new System.IO.MemoryStream(mat.ToBytes()))
|
||
{
|
||
bitmap = new Bitmap(ms);
|
||
}
|
||
return bitmap;
|
||
}
|
||
static Mat GetCroppedImage(Mat picture, Rect rectDet)
|
||
{
|
||
// ȷ<><C8B7> rectDet <20><> picture <20><>Χ<EFBFBD><CEA7>
|
||
Rect validRect = new Rect(
|
||
Math.Max(rectDet.X, 0),
|
||
Math.Max(rectDet.Y, 0),
|
||
Math.Min(rectDet.Width, picture.Width - rectDet.X),
|
||
Math.Min(rectDet.Height, picture.Height - rectDet.Y)
|
||
);
|
||
|
||
// <20><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
||
Mat croppedImage = new Mat(picture, validRect);
|
||
|
||
return croppedImage;
|
||
}
|
||
private void bnGetParam2_Click_1(object sender, EventArgs e)
|
||
{
|
||
// tbExposure2.Text = Cam2.dvpGetExposure().ToString();
|
||
//tbGain2.Text = Cam2.dvpGetAnalogGain().ToString();
|
||
}
|
||
|
||
private void panel2_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void bnSetParam_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void groupBox2_Enter(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void XZerorbx_Click(object sender, EventArgs e)
|
||
{
|
||
if (!ifXZeroValue)
|
||
{
|
||
this.XZerorbx.Checked = true;
|
||
//<2F><><EFBFBD><EFBFBD>
|
||
melsecPLCTCPDriver.WriteInt("503", 1);
|
||
ifXZeroValue = true;
|
||
this.txtSetValue.Text = "1";
|
||
myLog("X<>Ὺʼ<E1BFAA><CABC><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
else
|
||
{
|
||
this.XZerorbx.Checked = false;
|
||
melsecPLCTCPDriver.WriteInt("503", 0);
|
||
ifXZeroValue = false;
|
||
this.txtSetValue.Text = "0";
|
||
myLog("X<><58>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>", DateTime.Now);
|
||
}
|
||
}
|
||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>ܵľ<DCB5><C4BE>ο<CEBF>ֹ<EFBFBD><D6B9>ť<EFBFBD><C5A5><EFBFBD>ܲ<EFBFBD>ͬ<EFBFBD><CDAC>ɫ<EFBFBD><C9AB>Ӱ<EFBFBD>죩
|
||
private Rect GetCenterCroppedRect(Mat picture, int borderSize)
|
||
{
|
||
// <20><>ȡͼ<C8A1><CDBC><EFBFBD>ߴ<EFBFBD>
|
||
int width = picture.Width;
|
||
int height = picture.Height;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE>ο<EFBFBD>
|
||
int newWidth = width - 2 * borderSize;
|
||
int newHeight = height - 2 * borderSize;
|
||
int x = borderSize;
|
||
int y = borderSize;
|
||
|
||
// ȷ<><C8B7><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>
|
||
Rect validRect = new Rect(x, y, newWidth, newHeight);
|
||
validRect = validRect & new Rect(0, 0, width, height);
|
||
|
||
return validRect;
|
||
}
|
||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5>ɫ
|
||
static string BtnColor(Mat img, Rect rect)
|
||
{
|
||
// <20><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Mat roi = new Mat(img, rect);
|
||
|
||
// <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>ɫ
|
||
Scalar mean = Cv2.Mean(roi);
|
||
|
||
// <20><>ȡƽ<C8A1><C6BD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>RGBֵ
|
||
double r = mean.Val2;
|
||
double g = mean.Val1;
|
||
double b = mean.Val0;
|
||
|
||
// <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>Ҷ<EFBFBD>ֵ
|
||
double averageGray = (r + g + b) / 3;
|
||
|
||
// <20>ж<EFBFBD><D0B6><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
||
if (averageGray < 70)
|
||
{
|
||
return "<22><>ɫ";
|
||
}
|
||
else if (averageGray >= 70 && averageGray <= 150)
|
||
{
|
||
return "<22><>ɫ";
|
||
}
|
||
else
|
||
{
|
||
return "<22><>ɫ";
|
||
}
|
||
}
|
||
private void handStopBtn_Click(object sender, EventArgs e)
|
||
{
|
||
melsecPLCTCPDriver.WriteInt("550", 1);
|
||
}
|
||
|
||
private void HandRuningBtn_Click(object sender, EventArgs e)
|
||
{
|
||
melsecPLCTCPDriver.WriteInt("550", 0);
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
|
||
melsecPLCTCPDriver.WriteInt("550", 0);
|
||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);
|
||
|
||
}
|
||
|
||
private void panel1_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void button1_Click_1(object sender, EventArgs e)
|
||
{
|
||
if (!m_sKEYENCEBar.IsNullOrEmpty())
|
||
{
|
||
OcrBarBox.Text = m_sKEYENCEBar;
|
||
}
|
||
|
||
}
|
||
|
||
private void canvas1_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void canvas7_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void CloseDecBtn_Click(object sender, EventArgs e)
|
||
{
|
||
using (var passwordForm = new Form2())
|
||
{
|
||
if (passwordForm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
if (passwordForm.EnteredPassword == CorrectPassword)
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
||
meachineState = MeachineState.machine_closing;
|
||
melsecPLCTCPDriver.WriteInt("550", 0);
|
||
melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 0);
|
||
melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void label24_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void label25_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void label18_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void canvas2_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void label27_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void label37_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void groupBox9_Enter(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void button6_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
string FolderPath = "D:\\Hisence\\Test\\2\\ng";
|
||
// ȷ<><C8B7><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if (System.IO.Directory.Exists(FolderPath))
|
||
{
|
||
// ʹ<><CAB9> Process <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||
Process.Start("explorer.exe", FolderPath);
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"<22><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>: {ex.Message}", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
|
||
private void button4_Click_2(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
string FolderPath = "D:\\cam1";
|
||
// ȷ<><C8B7><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if (System.IO.Directory.Exists(FolderPath))
|
||
{
|
||
// ʹ<><CAB9> Process <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||
Process.Start("explorer.exe", FolderPath);
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"<22><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>: {ex.Message}", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
|
||
private void button5_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
string FolderPath = "D:\\Hisence\\Test\\1\\ng";
|
||
// ȷ<><C8B7><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if (System.IO.Directory.Exists(FolderPath))
|
||
{
|
||
// ʹ<><CAB9> Process <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||
Process.Start("explorer.exe", FolderPath);
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"<22><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>: {ex.Message}", "<22><><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
}
|
||
}
|